Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/ipc/ContentBridgeChild.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/dom/ContentBridgeChild.h"
8
#include "mozilla/dom/ContentChild.h"
9
#include "mozilla/dom/File.h"
10
#include "mozilla/dom/TabChild.h"
11
#include "mozilla/dom/TabGroup.h"
12
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
13
#include "mozilla/ipc/InputStreamUtils.h"
14
#include "base/task.h"
15
16
using namespace mozilla::ipc;
17
using namespace mozilla::jsipc;
18
19
namespace mozilla {
20
namespace dom {
21
22
NS_IMPL_ISUPPORTS(ContentBridgeChild,
23
                  nsIContentChild)
24
25
ContentBridgeChild::ContentBridgeChild()
26
0
{}
27
28
ContentBridgeChild::~ContentBridgeChild()
29
0
{
30
0
}
31
32
void
33
ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
34
0
{
35
0
  MessageLoop::current()->PostTask(
36
0
    NewRunnableMethod("dom::ContentBridgeChild::DeferredDestroy",
37
0
                      this,
38
0
                      &ContentBridgeChild::DeferredDestroy));
39
0
}
40
41
/*static*/ void
42
ContentBridgeChild::Create(Endpoint<PContentBridgeChild>&& aEndpoint)
43
0
{
44
0
  RefPtr<ContentBridgeChild> bridge = new ContentBridgeChild();
45
0
  bridge->mSelfRef = bridge;
46
0
47
0
  DebugOnly<bool> ok = aEndpoint.Bind(bridge);
48
0
  MOZ_ASSERT(ok);
49
0
}
50
51
void
52
ContentBridgeChild::DeferredDestroy()
53
0
{
54
0
  mSelfRef = nullptr;
55
0
  // |this| was just destroyed, hands off
56
0
}
57
58
mozilla::ipc::IPCResult
59
ContentBridgeChild::RecvAsyncMessage(const nsString& aMsg,
60
                                     InfallibleTArray<jsipc::CpowEntry>&& aCpows,
61
                                     const IPC::Principal& aPrincipal,
62
                                     const ClonedMessageData& aData)
63
0
{
64
0
  return nsIContentChild::RecvAsyncMessage(aMsg, std::move(aCpows), aPrincipal, aData);
65
0
}
66
67
bool
68
ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
69
                                            const TabId& aTabId,
70
                                            const TabId& aSameTabGroupAs,
71
                                            const IPCTabContext& aContext,
72
                                            const uint32_t& aChromeFlags,
73
                                            const ContentParentId& aCpID,
74
                                            const bool& aIsForBrowser)
75
0
{
76
0
  return PContentBridgeChild::SendPBrowserConstructor(aActor,
77
0
                                                      aTabId,
78
0
                                                      aSameTabGroupAs,
79
0
                                                      aContext,
80
0
                                                      aChromeFlags,
81
0
                                                      aCpID,
82
0
                                                      aIsForBrowser);
83
0
}
84
85
PFileDescriptorSetChild*
86
ContentBridgeChild::SendPFileDescriptorSetConstructor(const FileDescriptor& aFD)
87
0
{
88
0
  return PContentBridgeChild::SendPFileDescriptorSetConstructor(aFD);
89
0
}
90
91
PChildToParentStreamChild*
92
ContentBridgeChild::SendPChildToParentStreamConstructor(PChildToParentStreamChild* aActor)
93
0
{
94
0
  return PContentBridgeChild::SendPChildToParentStreamConstructor(aActor);
95
0
}
96
97
// This implementation is identical to ContentChild::GetCPOWManager but we can't
98
// move it to nsIContentChild because it calls ManagedPJavaScriptChild() which
99
// only exists in PContentChild and PContentBridgeChild.
100
jsipc::CPOWManager*
101
ContentBridgeChild::GetCPOWManager()
102
0
{
103
0
  if (PJavaScriptChild* c = LoneManagedOrNullAsserts(ManagedPJavaScriptChild())) {
104
0
    return CPOWManagerFor(c);
105
0
  }
106
0
  return CPOWManagerFor(SendPJavaScriptConstructor());
107
0
}
108
109
mozilla::jsipc::PJavaScriptChild *
110
ContentBridgeChild::AllocPJavaScriptChild()
111
0
{
112
0
  return nsIContentChild::AllocPJavaScriptChild();
113
0
}
114
115
bool
116
ContentBridgeChild::DeallocPJavaScriptChild(PJavaScriptChild *child)
117
0
{
118
0
  return nsIContentChild::DeallocPJavaScriptChild(child);
119
0
}
120
121
PBrowserChild*
122
ContentBridgeChild::AllocPBrowserChild(const TabId& aTabId,
123
                                       const TabId& aSameTabGroupAs,
124
                                       const IPCTabContext &aContext,
125
                                       const uint32_t& aChromeFlags,
126
                                       const ContentParentId& aCpID,
127
                                       const bool& aIsForBrowser)
128
0
{
129
0
  return nsIContentChild::AllocPBrowserChild(aTabId,
130
0
                                             aSameTabGroupAs,
131
0
                                             aContext,
132
0
                                             aChromeFlags,
133
0
                                             aCpID,
134
0
                                             aIsForBrowser);
135
0
}
136
137
bool
138
ContentBridgeChild::DeallocPBrowserChild(PBrowserChild* aChild)
139
0
{
140
0
  return nsIContentChild::DeallocPBrowserChild(aChild);
141
0
}
142
143
mozilla::ipc::IPCResult
144
ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
145
                                            const TabId& aTabId,
146
                                            const TabId& aSameTabGroupAs,
147
                                            const IPCTabContext& aContext,
148
                                            const uint32_t& aChromeFlags,
149
                                            const ContentParentId& aCpID,
150
                                            const bool& aIsForBrowser)
151
0
{
152
0
  return nsIContentChild::RecvPBrowserConstructor(aActor,
153
0
                                                  aTabId,
154
0
                                                  aSameTabGroupAs,
155
0
                                                  aContext,
156
0
                                                  aChromeFlags,
157
0
                                                  aCpID,
158
0
                                                  aIsForBrowser);
159
0
}
160
161
PIPCBlobInputStreamChild*
162
ContentBridgeChild::AllocPIPCBlobInputStreamChild(const nsID& aID,
163
                                                  const uint64_t& aSize)
164
0
{
165
0
  return nsIContentChild::AllocPIPCBlobInputStreamChild(aID, aSize);
166
0
}
167
168
bool
169
ContentBridgeChild::DeallocPIPCBlobInputStreamChild(PIPCBlobInputStreamChild* aActor)
170
0
{
171
0
  return nsIContentChild::DeallocPIPCBlobInputStreamChild(aActor);
172
0
}
173
174
PChildToParentStreamChild*
175
ContentBridgeChild::AllocPChildToParentStreamChild()
176
0
{
177
0
  return nsIContentChild::AllocPChildToParentStreamChild();
178
0
}
179
180
bool
181
ContentBridgeChild::DeallocPChildToParentStreamChild(PChildToParentStreamChild* aActor)
182
0
{
183
0
  return nsIContentChild::DeallocPChildToParentStreamChild(aActor);
184
0
}
185
186
PParentToChildStreamChild*
187
ContentBridgeChild::AllocPParentToChildStreamChild()
188
0
{
189
0
  return nsIContentChild::AllocPParentToChildStreamChild();
190
0
}
191
192
bool
193
ContentBridgeChild::DeallocPParentToChildStreamChild(PParentToChildStreamChild* aActor)
194
0
{
195
0
  return nsIContentChild::DeallocPParentToChildStreamChild(aActor);
196
0
}
197
198
PFileDescriptorSetChild*
199
ContentBridgeChild::AllocPFileDescriptorSetChild(const FileDescriptor& aFD)
200
0
{
201
0
  return nsIContentChild::AllocPFileDescriptorSetChild(aFD);
202
0
}
203
204
bool
205
ContentBridgeChild::DeallocPFileDescriptorSetChild(PFileDescriptorSetChild* aActor)
206
0
{
207
0
  return nsIContentChild::DeallocPFileDescriptorSetChild(aActor);
208
0
}
209
210
mozilla::ipc::IPCResult
211
ContentBridgeChild::RecvActivate(PBrowserChild* aTab)
212
0
{
213
0
  TabChild* tab = static_cast<TabChild*>(aTab);
214
0
  return tab->RecvActivate();
215
0
}
216
217
mozilla::ipc::IPCResult
218
ContentBridgeChild::RecvDeactivate(PBrowserChild* aTab)
219
0
{
220
0
  TabChild* tab = static_cast<TabChild*>(aTab);
221
0
  return tab->RecvDeactivate();
222
0
}
223
224
already_AddRefed<nsIEventTarget>
225
ContentBridgeChild::GetConstructedEventTarget(const Message& aMsg)
226
0
{
227
0
  // Currently we only set targets for PBrowser.
228
0
  if (aMsg.type() != PContentBridge::Msg_PBrowserConstructor__ID) {
229
0
    return nullptr;
230
0
  }
231
0
232
0
  return nsIContentChild::GetConstructedEventTarget(aMsg);
233
0
}
234
235
already_AddRefed<nsIEventTarget>
236
ContentBridgeChild::GetEventTargetFor(TabChild* aTabChild)
237
0
{
238
0
  return IToplevelProtocol::GetActorEventTarget(aTabChild);
239
0
}
240
241
} // namespace dom
242
} // namespace mozilla