/src/mozilla-central/ipc/glue/BackgroundParentImpl.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 "BackgroundParentImpl.h" |
8 | | |
9 | | #include "BroadcastChannelParent.h" |
10 | | #include "FileDescriptorSetParent.h" |
11 | | #ifdef MOZ_WEBRTC |
12 | | #include "CamerasParent.h" |
13 | | #endif |
14 | | #include "mozilla/media/MediaParent.h" |
15 | | #include "mozilla/Assertions.h" |
16 | | #include "mozilla/dom/ClientManagerActors.h" |
17 | | #include "mozilla/dom/ContentParent.h" |
18 | | #include "mozilla/dom/DOMTypes.h" |
19 | | #include "mozilla/dom/FileSystemBase.h" |
20 | | #include "mozilla/dom/FileSystemRequestParent.h" |
21 | | #include "mozilla/dom/GamepadEventChannelParent.h" |
22 | | #include "mozilla/dom/GamepadTestChannelParent.h" |
23 | | #include "mozilla/dom/PGamepadEventChannelParent.h" |
24 | | #include "mozilla/dom/PGamepadTestChannelParent.h" |
25 | | #include "mozilla/dom/MessagePortParent.h" |
26 | | #include "mozilla/dom/ServiceWorkerActors.h" |
27 | | #include "mozilla/dom/ServiceWorkerManagerParent.h" |
28 | | #include "mozilla/dom/ServiceWorkerRegistrar.h" |
29 | | #include "mozilla/dom/StorageActivityService.h" |
30 | | #include "mozilla/dom/asmjscache/AsmJSCache.h" |
31 | | #include "mozilla/dom/cache/ActorUtils.h" |
32 | | #include "mozilla/dom/indexedDB/ActorsParent.h" |
33 | | #include "mozilla/dom/ipc/IPCBlobInputStreamParent.h" |
34 | | #include "mozilla/dom/ipc/PendingIPCBlobParent.h" |
35 | | #include "mozilla/dom/ipc/TemporaryIPCBlobParent.h" |
36 | | #include "mozilla/dom/quota/ActorsParent.h" |
37 | | #include "mozilla/dom/simpledb/ActorsParent.h" |
38 | | #include "mozilla/dom/StorageIPC.h" |
39 | | #include "mozilla/dom/MIDIManagerParent.h" |
40 | | #include "mozilla/dom/MIDIPortParent.h" |
41 | | #include "mozilla/dom/MIDIPlatformService.h" |
42 | | #include "mozilla/ipc/BackgroundParent.h" |
43 | | #include "mozilla/ipc/BackgroundUtils.h" |
44 | | #include "mozilla/ipc/IPCStreamAlloc.h" |
45 | | #include "mozilla/ipc/PBackgroundSharedTypes.h" |
46 | | #include "mozilla/ipc/PBackgroundTestParent.h" |
47 | | #include "mozilla/ipc/PChildToParentStreamParent.h" |
48 | | #include "mozilla/ipc/PParentToChildStreamParent.h" |
49 | | #include "mozilla/layout/VsyncParent.h" |
50 | | #include "mozilla/net/HttpBackgroundChannelParent.h" |
51 | | #include "mozilla/dom/network/UDPSocketParent.h" |
52 | | #include "mozilla/dom/WebAuthnTransactionParent.h" |
53 | | #include "mozilla/Preferences.h" |
54 | | #include "nsNetUtil.h" |
55 | | #include "nsIScriptSecurityManager.h" |
56 | | #include "nsProxyRelease.h" |
57 | | #include "mozilla/RefPtr.h" |
58 | | #include "nsThreadUtils.h" |
59 | | #include "nsTraceRefcnt.h" |
60 | | #include "nsXULAppAPI.h" |
61 | | |
62 | | #ifdef DISABLE_ASSERTS_FOR_FUZZING |
63 | | #define ASSERT_UNLESS_FUZZING(...) do { } while (0) |
64 | | #else |
65 | | #define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false) |
66 | | #endif |
67 | | |
68 | | using mozilla::ipc::AssertIsOnBackgroundThread; |
69 | | using mozilla::dom::asmjscache::PAsmJSCacheEntryParent; |
70 | | using mozilla::dom::cache::PCacheParent; |
71 | | using mozilla::dom::cache::PCacheStorageParent; |
72 | | using mozilla::dom::cache::PCacheStreamControlParent; |
73 | | using mozilla::dom::FileSystemBase; |
74 | | using mozilla::dom::FileSystemRequestParent; |
75 | | using mozilla::dom::MessagePortParent; |
76 | | using mozilla::dom::PMessagePortParent; |
77 | | using mozilla::dom::PServiceWorkerParent; |
78 | | using mozilla::dom::PServiceWorkerContainerParent; |
79 | | using mozilla::dom::PServiceWorkerRegistrationParent; |
80 | | using mozilla::dom::UDPSocketParent; |
81 | | using mozilla::dom::WebAuthnTransactionParent; |
82 | | using mozilla::AssertIsOnMainThread; |
83 | | using mozilla::dom::PMIDIPortParent; |
84 | | using mozilla::dom::PMIDIManagerParent; |
85 | | using mozilla::dom::MIDIPortParent; |
86 | | using mozilla::dom::MIDIManagerParent; |
87 | | using mozilla::dom::MIDIPlatformService; |
88 | | |
89 | | namespace { |
90 | | |
91 | | class TestParent final : public mozilla::ipc::PBackgroundTestParent |
92 | | { |
93 | | friend class mozilla::ipc::BackgroundParentImpl; |
94 | | |
95 | | TestParent() |
96 | 0 | { |
97 | 0 | MOZ_COUNT_CTOR(TestParent); |
98 | 0 | } |
99 | | |
100 | | protected: |
101 | | ~TestParent() override |
102 | 0 | { |
103 | 0 | MOZ_COUNT_DTOR(TestParent); |
104 | 0 | } |
105 | | |
106 | | public: |
107 | | void |
108 | | ActorDestroy(ActorDestroyReason aWhy) override; |
109 | | }; |
110 | | |
111 | | } // namespace |
112 | | |
113 | | namespace mozilla { |
114 | | namespace ipc { |
115 | | |
116 | | using mozilla::dom::ContentParent; |
117 | | using mozilla::dom::BroadcastChannelParent; |
118 | | using mozilla::dom::ServiceWorkerRegistrationData; |
119 | | |
120 | | BackgroundParentImpl::BackgroundParentImpl() |
121 | 0 | { |
122 | 0 | AssertIsInMainProcess(); |
123 | 0 | AssertIsOnMainThread(); |
124 | 0 |
|
125 | 0 | MOZ_COUNT_CTOR(mozilla::ipc::BackgroundParentImpl); |
126 | 0 | } |
127 | | |
128 | | BackgroundParentImpl::~BackgroundParentImpl() |
129 | 0 | { |
130 | 0 | AssertIsInMainProcess(); |
131 | 0 | AssertIsOnMainThread(); |
132 | 0 |
|
133 | 0 | MOZ_COUNT_DTOR(mozilla::ipc::BackgroundParentImpl); |
134 | 0 | } |
135 | | |
136 | | void |
137 | | BackgroundParentImpl::ActorDestroy(ActorDestroyReason aWhy) |
138 | 0 | { |
139 | 0 | AssertIsInMainProcess(); |
140 | 0 | AssertIsOnBackgroundThread(); |
141 | 0 | } |
142 | | |
143 | | BackgroundParentImpl::PBackgroundTestParent* |
144 | | BackgroundParentImpl::AllocPBackgroundTestParent(const nsCString& aTestArg) |
145 | 0 | { |
146 | 0 | AssertIsInMainProcess(); |
147 | 0 | AssertIsOnBackgroundThread(); |
148 | 0 |
|
149 | 0 | return new TestParent(); |
150 | 0 | } |
151 | | |
152 | | mozilla::ipc::IPCResult |
153 | | BackgroundParentImpl::RecvPBackgroundTestConstructor( |
154 | | PBackgroundTestParent* aActor, |
155 | | const nsCString& aTestArg) |
156 | 0 | { |
157 | 0 | AssertIsInMainProcess(); |
158 | 0 | AssertIsOnBackgroundThread(); |
159 | 0 | MOZ_ASSERT(aActor); |
160 | 0 |
|
161 | 0 | if (!PBackgroundTestParent::Send__delete__(aActor, aTestArg)) { |
162 | 0 | return IPC_FAIL_NO_REASON(this); |
163 | 0 | } |
164 | 0 | return IPC_OK(); |
165 | 0 | } |
166 | | |
167 | | bool |
168 | | BackgroundParentImpl::DeallocPBackgroundTestParent( |
169 | | PBackgroundTestParent* aActor) |
170 | 0 | { |
171 | 0 | AssertIsInMainProcess(); |
172 | 0 | AssertIsOnBackgroundThread(); |
173 | 0 | MOZ_ASSERT(aActor); |
174 | 0 |
|
175 | 0 | delete static_cast<TestParent*>(aActor); |
176 | 0 | return true; |
177 | 0 | } |
178 | | |
179 | | auto |
180 | | BackgroundParentImpl::AllocPBackgroundIDBFactoryParent( |
181 | | const LoggingInfo& aLoggingInfo) |
182 | | -> PBackgroundIDBFactoryParent* |
183 | 0 | { |
184 | 0 | using mozilla::dom::indexedDB::AllocPBackgroundIDBFactoryParent; |
185 | 0 |
|
186 | 0 | AssertIsInMainProcess(); |
187 | 0 | AssertIsOnBackgroundThread(); |
188 | 0 |
|
189 | 0 | return AllocPBackgroundIDBFactoryParent(aLoggingInfo); |
190 | 0 | } |
191 | | |
192 | | mozilla::ipc::IPCResult |
193 | | BackgroundParentImpl::RecvPBackgroundIDBFactoryConstructor( |
194 | | PBackgroundIDBFactoryParent* aActor, |
195 | | const LoggingInfo& aLoggingInfo) |
196 | 0 | { |
197 | 0 | using mozilla::dom::indexedDB::RecvPBackgroundIDBFactoryConstructor; |
198 | 0 |
|
199 | 0 | AssertIsInMainProcess(); |
200 | 0 | AssertIsOnBackgroundThread(); |
201 | 0 | MOZ_ASSERT(aActor); |
202 | 0 |
|
203 | 0 | if (!RecvPBackgroundIDBFactoryConstructor(aActor, aLoggingInfo)) { |
204 | 0 | return IPC_FAIL_NO_REASON(this); |
205 | 0 | } |
206 | 0 | return IPC_OK(); |
207 | 0 | } |
208 | | |
209 | | bool |
210 | | BackgroundParentImpl::DeallocPBackgroundIDBFactoryParent( |
211 | | PBackgroundIDBFactoryParent* aActor) |
212 | 0 | { |
213 | 0 | using mozilla::dom::indexedDB::DeallocPBackgroundIDBFactoryParent; |
214 | 0 |
|
215 | 0 | AssertIsInMainProcess(); |
216 | 0 | AssertIsOnBackgroundThread(); |
217 | 0 | MOZ_ASSERT(aActor); |
218 | 0 |
|
219 | 0 | return DeallocPBackgroundIDBFactoryParent(aActor); |
220 | 0 | } |
221 | | |
222 | | auto |
223 | | BackgroundParentImpl::AllocPBackgroundIndexedDBUtilsParent() |
224 | | -> PBackgroundIndexedDBUtilsParent* |
225 | 0 | { |
226 | 0 | AssertIsInMainProcess(); |
227 | 0 | AssertIsOnBackgroundThread(); |
228 | 0 |
|
229 | 0 | return mozilla::dom::indexedDB::AllocPBackgroundIndexedDBUtilsParent(); |
230 | 0 | } |
231 | | |
232 | | bool |
233 | | BackgroundParentImpl::DeallocPBackgroundIndexedDBUtilsParent( |
234 | | PBackgroundIndexedDBUtilsParent* aActor) |
235 | 0 | { |
236 | 0 | AssertIsInMainProcess(); |
237 | 0 | AssertIsOnBackgroundThread(); |
238 | 0 | MOZ_ASSERT(aActor); |
239 | 0 |
|
240 | 0 | return |
241 | 0 | mozilla::dom::indexedDB::DeallocPBackgroundIndexedDBUtilsParent(aActor); |
242 | 0 | } |
243 | | |
244 | | mozilla::ipc::IPCResult |
245 | | BackgroundParentImpl::RecvFlushPendingFileDeletions() |
246 | 0 | { |
247 | 0 | AssertIsInMainProcess(); |
248 | 0 | AssertIsOnBackgroundThread(); |
249 | 0 |
|
250 | 0 | if (!mozilla::dom::indexedDB::RecvFlushPendingFileDeletions()) { |
251 | 0 | return IPC_FAIL_NO_REASON(this); |
252 | 0 | } |
253 | 0 | return IPC_OK(); |
254 | 0 | } |
255 | | |
256 | | BackgroundParentImpl::PBackgroundSDBConnectionParent* |
257 | | BackgroundParentImpl::AllocPBackgroundSDBConnectionParent( |
258 | | const PrincipalInfo& aPrincipalInfo) |
259 | 0 | { |
260 | 0 | AssertIsInMainProcess(); |
261 | 0 | AssertIsOnBackgroundThread(); |
262 | 0 |
|
263 | 0 | return mozilla::dom::AllocPBackgroundSDBConnectionParent(aPrincipalInfo); |
264 | 0 | } |
265 | | |
266 | | mozilla::ipc::IPCResult |
267 | | BackgroundParentImpl::RecvPBackgroundSDBConnectionConstructor( |
268 | | PBackgroundSDBConnectionParent* aActor, |
269 | | const PrincipalInfo& aPrincipalInfo) |
270 | 0 | { |
271 | 0 | AssertIsInMainProcess(); |
272 | 0 | AssertIsOnBackgroundThread(); |
273 | 0 | MOZ_ASSERT(aActor); |
274 | 0 |
|
275 | 0 | if (!mozilla::dom::RecvPBackgroundSDBConnectionConstructor(aActor, |
276 | 0 | aPrincipalInfo)) { |
277 | 0 | return IPC_FAIL_NO_REASON(this); |
278 | 0 | } |
279 | 0 | return IPC_OK(); |
280 | 0 | } |
281 | | |
282 | | bool |
283 | | BackgroundParentImpl::DeallocPBackgroundSDBConnectionParent( |
284 | | PBackgroundSDBConnectionParent* aActor) |
285 | 0 | { |
286 | 0 | AssertIsInMainProcess(); |
287 | 0 | AssertIsOnBackgroundThread(); |
288 | 0 | MOZ_ASSERT(aActor); |
289 | 0 |
|
290 | 0 | return mozilla::dom::DeallocPBackgroundSDBConnectionParent(aActor); |
291 | 0 | } |
292 | | |
293 | | BackgroundParentImpl::PBackgroundLocalStorageCacheParent* |
294 | | BackgroundParentImpl::AllocPBackgroundLocalStorageCacheParent( |
295 | | const PrincipalInfo& aPrincipalInfo, |
296 | | const nsCString& aOriginKey, |
297 | | const uint32_t& aPrivateBrowsingId) |
298 | 0 | { |
299 | 0 | AssertIsInMainProcess(); |
300 | 0 | AssertIsOnBackgroundThread(); |
301 | 0 |
|
302 | 0 | return |
303 | 0 | mozilla::dom::AllocPBackgroundLocalStorageCacheParent(aPrincipalInfo, |
304 | 0 | aOriginKey, |
305 | 0 | aPrivateBrowsingId); |
306 | 0 | } |
307 | | |
308 | | mozilla::ipc::IPCResult |
309 | | BackgroundParentImpl::RecvPBackgroundLocalStorageCacheConstructor( |
310 | | PBackgroundLocalStorageCacheParent* aActor, |
311 | | const PrincipalInfo& aPrincipalInfo, |
312 | | const nsCString& aOriginKey, |
313 | | const uint32_t& aPrivateBrowsingId) |
314 | 0 | { |
315 | 0 | AssertIsInMainProcess(); |
316 | 0 | AssertIsOnBackgroundThread(); |
317 | 0 | MOZ_ASSERT(aActor); |
318 | 0 |
|
319 | 0 | return |
320 | 0 | mozilla::dom::RecvPBackgroundLocalStorageCacheConstructor( |
321 | 0 | this, |
322 | 0 | aActor, |
323 | 0 | aPrincipalInfo, |
324 | 0 | aOriginKey, |
325 | 0 | aPrivateBrowsingId); |
326 | 0 | } |
327 | | |
328 | | bool |
329 | | BackgroundParentImpl::DeallocPBackgroundLocalStorageCacheParent( |
330 | | PBackgroundLocalStorageCacheParent* aActor) |
331 | 0 | { |
332 | 0 | AssertIsInMainProcess(); |
333 | 0 | AssertIsOnBackgroundThread(); |
334 | 0 | MOZ_ASSERT(aActor); |
335 | 0 |
|
336 | 0 | return mozilla::dom::DeallocPBackgroundLocalStorageCacheParent(aActor); |
337 | 0 | } |
338 | | |
339 | | auto |
340 | | BackgroundParentImpl::AllocPBackgroundStorageParent(const nsString& aProfilePath) |
341 | | -> PBackgroundStorageParent* |
342 | 0 | { |
343 | 0 | AssertIsInMainProcess(); |
344 | 0 | AssertIsOnBackgroundThread(); |
345 | 0 |
|
346 | 0 | return mozilla::dom::AllocPBackgroundStorageParent(aProfilePath); |
347 | 0 | } |
348 | | |
349 | | mozilla::ipc::IPCResult |
350 | | BackgroundParentImpl::RecvPBackgroundStorageConstructor( |
351 | | PBackgroundStorageParent* aActor, |
352 | | const nsString& aProfilePath) |
353 | 0 | { |
354 | 0 | AssertIsInMainProcess(); |
355 | 0 | AssertIsOnBackgroundThread(); |
356 | 0 | MOZ_ASSERT(aActor); |
357 | 0 |
|
358 | 0 | return mozilla::dom::RecvPBackgroundStorageConstructor(aActor, aProfilePath); |
359 | 0 | } |
360 | | |
361 | | bool |
362 | | BackgroundParentImpl::DeallocPBackgroundStorageParent( |
363 | | PBackgroundStorageParent* aActor) |
364 | 0 | { |
365 | 0 | AssertIsInMainProcess(); |
366 | 0 | AssertIsOnBackgroundThread(); |
367 | 0 | MOZ_ASSERT(aActor); |
368 | 0 |
|
369 | 0 | return mozilla::dom::DeallocPBackgroundStorageParent(aActor); |
370 | 0 | } |
371 | | |
372 | | PPendingIPCBlobParent* |
373 | | BackgroundParentImpl::AllocPPendingIPCBlobParent(const IPCBlob& aBlob) |
374 | 0 | { |
375 | 0 | MOZ_CRASH("PPendingIPCBlobParent actors should be manually constructed!"); |
376 | 0 | } |
377 | | |
378 | | bool |
379 | | BackgroundParentImpl::DeallocPPendingIPCBlobParent(PPendingIPCBlobParent* aActor) |
380 | 0 | { |
381 | 0 | AssertIsInMainProcess(); |
382 | 0 | AssertIsOnBackgroundThread(); |
383 | 0 | MOZ_ASSERT(aActor); |
384 | 0 |
|
385 | 0 | delete aActor; |
386 | 0 | return true; |
387 | 0 | } |
388 | | |
389 | | PTemporaryIPCBlobParent* |
390 | | BackgroundParentImpl::AllocPTemporaryIPCBlobParent() |
391 | 0 | { |
392 | 0 | return new mozilla::dom::TemporaryIPCBlobParent(); |
393 | 0 | } |
394 | | |
395 | | mozilla::ipc::IPCResult |
396 | | BackgroundParentImpl::RecvPTemporaryIPCBlobConstructor(PTemporaryIPCBlobParent* aActor) |
397 | 0 | { |
398 | 0 | mozilla::dom::TemporaryIPCBlobParent* actor = |
399 | 0 | static_cast<mozilla::dom::TemporaryIPCBlobParent*>(aActor); |
400 | 0 | return actor->CreateAndShareFile(); |
401 | 0 | } |
402 | | |
403 | | bool |
404 | | BackgroundParentImpl::DeallocPTemporaryIPCBlobParent(PTemporaryIPCBlobParent* aActor) |
405 | 0 | { |
406 | 0 | delete aActor; |
407 | 0 | return true; |
408 | 0 | } |
409 | | |
410 | | PIPCBlobInputStreamParent* |
411 | | BackgroundParentImpl::AllocPIPCBlobInputStreamParent(const nsID& aID, |
412 | | const uint64_t& aSize) |
413 | 0 | { |
414 | 0 | AssertIsInMainProcess(); |
415 | 0 | AssertIsOnBackgroundThread(); |
416 | 0 |
|
417 | 0 | RefPtr<mozilla::dom::IPCBlobInputStreamParent> actor = |
418 | 0 | mozilla::dom::IPCBlobInputStreamParent::Create(aID, aSize, this); |
419 | 0 | return actor.forget().take(); |
420 | 0 | } |
421 | | |
422 | | mozilla::ipc::IPCResult |
423 | | BackgroundParentImpl::RecvPIPCBlobInputStreamConstructor(PIPCBlobInputStreamParent* aActor, |
424 | | const nsID& aID, |
425 | | const uint64_t& aSize) |
426 | 0 | { |
427 | 0 | if (!static_cast<mozilla::dom::IPCBlobInputStreamParent*>(aActor)->HasValidStream()) { |
428 | 0 | return IPC_FAIL_NO_REASON(this); |
429 | 0 | } |
430 | 0 |
|
431 | 0 | return IPC_OK(); |
432 | 0 | } |
433 | | |
434 | | bool |
435 | | BackgroundParentImpl::DeallocPIPCBlobInputStreamParent(PIPCBlobInputStreamParent* aActor) |
436 | 0 | { |
437 | 0 | AssertIsInMainProcess(); |
438 | 0 | AssertIsOnBackgroundThread(); |
439 | 0 | MOZ_ASSERT(aActor); |
440 | 0 |
|
441 | 0 | RefPtr<mozilla::dom::IPCBlobInputStreamParent> actor = |
442 | 0 | dont_AddRef(static_cast<mozilla::dom::IPCBlobInputStreamParent*>(aActor)); |
443 | 0 | return true; |
444 | 0 | } |
445 | | |
446 | | PFileDescriptorSetParent* |
447 | | BackgroundParentImpl::AllocPFileDescriptorSetParent( |
448 | | const FileDescriptor& aFileDescriptor) |
449 | 0 | { |
450 | 0 | AssertIsInMainProcess(); |
451 | 0 | AssertIsOnBackgroundThread(); |
452 | 0 |
|
453 | 0 | return new FileDescriptorSetParent(aFileDescriptor); |
454 | 0 | } |
455 | | |
456 | | bool |
457 | | BackgroundParentImpl::DeallocPFileDescriptorSetParent( |
458 | | PFileDescriptorSetParent* aActor) |
459 | 0 | { |
460 | 0 | AssertIsInMainProcess(); |
461 | 0 | AssertIsOnBackgroundThread(); |
462 | 0 | MOZ_ASSERT(aActor); |
463 | 0 |
|
464 | 0 | delete static_cast<FileDescriptorSetParent*>(aActor); |
465 | 0 | return true; |
466 | 0 | } |
467 | | |
468 | | PChildToParentStreamParent* |
469 | | BackgroundParentImpl::AllocPChildToParentStreamParent() |
470 | 0 | { |
471 | 0 | return mozilla::ipc::AllocPChildToParentStreamParent(); |
472 | 0 | } |
473 | | |
474 | | bool |
475 | | BackgroundParentImpl::DeallocPChildToParentStreamParent( |
476 | | PChildToParentStreamParent* aActor) |
477 | 0 | { |
478 | 0 | delete aActor; |
479 | 0 | return true; |
480 | 0 | } |
481 | | |
482 | | PParentToChildStreamParent* |
483 | | BackgroundParentImpl::AllocPParentToChildStreamParent() |
484 | 0 | { |
485 | 0 | MOZ_CRASH("PParentToChildStreamParent actors should be manually constructed!"); |
486 | 0 | } |
487 | | |
488 | | bool |
489 | | BackgroundParentImpl::DeallocPParentToChildStreamParent( |
490 | | PParentToChildStreamParent* aActor) |
491 | 0 | { |
492 | 0 | delete aActor; |
493 | 0 | return true; |
494 | 0 | } |
495 | | |
496 | | BackgroundParentImpl::PVsyncParent* |
497 | | BackgroundParentImpl::AllocPVsyncParent() |
498 | 0 | { |
499 | 0 | AssertIsInMainProcess(); |
500 | 0 | AssertIsOnBackgroundThread(); |
501 | 0 |
|
502 | 0 | RefPtr<mozilla::layout::VsyncParent> actor = |
503 | 0 | mozilla::layout::VsyncParent::Create(); |
504 | 0 | // There still has one ref-count after return, and it will be released in |
505 | 0 | // DeallocPVsyncParent(). |
506 | 0 | return actor.forget().take(); |
507 | 0 | } |
508 | | |
509 | | bool |
510 | | BackgroundParentImpl::DeallocPVsyncParent(PVsyncParent* aActor) |
511 | 0 | { |
512 | 0 | AssertIsInMainProcess(); |
513 | 0 | AssertIsOnBackgroundThread(); |
514 | 0 | MOZ_ASSERT(aActor); |
515 | 0 |
|
516 | 0 | // This actor already has one ref-count. Please check AllocPVsyncParent(). |
517 | 0 | RefPtr<mozilla::layout::VsyncParent> actor = |
518 | 0 | dont_AddRef(static_cast<mozilla::layout::VsyncParent*>(aActor)); |
519 | 0 | return true; |
520 | 0 | } |
521 | | |
522 | | camera::PCamerasParent* |
523 | | BackgroundParentImpl::AllocPCamerasParent() |
524 | 0 | { |
525 | 0 | AssertIsInMainProcess(); |
526 | 0 | AssertIsOnBackgroundThread(); |
527 | 0 |
|
528 | 0 | #ifdef MOZ_WEBRTC |
529 | 0 | RefPtr<mozilla::camera::CamerasParent> actor = |
530 | 0 | mozilla::camera::CamerasParent::Create(); |
531 | 0 | return actor.forget().take(); |
532 | | #else |
533 | | return nullptr; |
534 | | #endif |
535 | | } |
536 | | |
537 | | bool |
538 | | BackgroundParentImpl::DeallocPCamerasParent(camera::PCamerasParent *aActor) |
539 | 0 | { |
540 | 0 | AssertIsInMainProcess(); |
541 | 0 | AssertIsOnBackgroundThread(); |
542 | 0 | MOZ_ASSERT(aActor); |
543 | 0 |
|
544 | 0 | #ifdef MOZ_WEBRTC |
545 | 0 | RefPtr<mozilla::camera::CamerasParent> actor = |
546 | 0 | dont_AddRef(static_cast<mozilla::camera::CamerasParent*>(aActor)); |
547 | 0 | #endif |
548 | 0 | return true; |
549 | 0 | } |
550 | | |
551 | | auto |
552 | | BackgroundParentImpl::AllocPUDPSocketParent(const OptionalPrincipalInfo& /* unused */, |
553 | | const nsCString& /* unused */) |
554 | | -> PUDPSocketParent* |
555 | 0 | { |
556 | 0 | RefPtr<UDPSocketParent> p = new UDPSocketParent(this); |
557 | 0 |
|
558 | 0 | return p.forget().take(); |
559 | 0 | } |
560 | | |
561 | | mozilla::ipc::IPCResult |
562 | | BackgroundParentImpl::RecvPUDPSocketConstructor(PUDPSocketParent* aActor, |
563 | | const OptionalPrincipalInfo& aOptionalPrincipal, |
564 | | const nsCString& aFilter) |
565 | 0 | { |
566 | 0 | AssertIsInMainProcess(); |
567 | 0 | AssertIsOnBackgroundThread(); |
568 | 0 |
|
569 | 0 | if (aOptionalPrincipal.type() == OptionalPrincipalInfo::TPrincipalInfo) { |
570 | 0 | // Support for checking principals (for non-mtransport use) will be handled in |
571 | 0 | // bug 1167039 |
572 | 0 | return IPC_FAIL_NO_REASON(this); |
573 | 0 | } |
574 | 0 | // No principal - This must be from mtransport (WebRTC/ICE) - We'd want |
575 | 0 | // to DispatchToMainThread() here, but if we do we must block RecvBind() |
576 | 0 | // until Init() gets run. Since we don't have a principal, and we verify |
577 | 0 | // we have a filter, we can safely skip the Dispatch and just invoke Init() |
578 | 0 | // to install the filter. |
579 | 0 |
|
580 | 0 | // For mtransport, this will always be "stun", which doesn't allow outbound |
581 | 0 | // packets if they aren't STUN packets until a STUN response is seen. |
582 | 0 | if (!aFilter.EqualsASCII(NS_NETWORK_SOCKET_FILTER_HANDLER_STUN_SUFFIX)) { |
583 | 0 | return IPC_FAIL_NO_REASON(this); |
584 | 0 | } |
585 | 0 |
|
586 | 0 | IPC::Principal principal; |
587 | 0 | if (!static_cast<UDPSocketParent*>(aActor)->Init(principal, aFilter)) { |
588 | 0 | MOZ_CRASH("UDPSocketCallback - failed init"); |
589 | 0 | } |
590 | 0 |
|
591 | 0 | return IPC_OK(); |
592 | 0 | } |
593 | | |
594 | | bool |
595 | | BackgroundParentImpl::DeallocPUDPSocketParent(PUDPSocketParent* actor) |
596 | 0 | { |
597 | 0 | UDPSocketParent* p = static_cast<UDPSocketParent*>(actor); |
598 | 0 | p->Release(); |
599 | 0 | return true; |
600 | 0 | } |
601 | | |
602 | | mozilla::dom::PBroadcastChannelParent* |
603 | | BackgroundParentImpl::AllocPBroadcastChannelParent( |
604 | | const PrincipalInfo& aPrincipalInfo, |
605 | | const nsCString& aOrigin, |
606 | | const nsString& aChannel) |
607 | 0 | { |
608 | 0 | AssertIsInMainProcess(); |
609 | 0 | AssertIsOnBackgroundThread(); |
610 | 0 |
|
611 | 0 | nsString originChannelKey; |
612 | 0 |
|
613 | 0 | // The format of originChannelKey is: |
614 | 0 | // <channelName>|<origin+OriginAttributes> |
615 | 0 |
|
616 | 0 | originChannelKey.Assign(aChannel); |
617 | 0 |
|
618 | 0 | originChannelKey.AppendLiteral("|"); |
619 | 0 |
|
620 | 0 | originChannelKey.Append(NS_ConvertUTF8toUTF16(aOrigin)); |
621 | 0 |
|
622 | 0 | return new BroadcastChannelParent(originChannelKey); |
623 | 0 | } |
624 | | |
625 | | namespace { |
626 | | |
627 | | struct MOZ_STACK_CLASS NullifyContentParentRAII |
628 | | { |
629 | | explicit NullifyContentParentRAII(RefPtr<ContentParent>& aContentParent) |
630 | | : mContentParent(aContentParent) |
631 | 0 | {} |
632 | | |
633 | | ~NullifyContentParentRAII() |
634 | 0 | { |
635 | 0 | mContentParent = nullptr; |
636 | 0 | } |
637 | | |
638 | | RefPtr<ContentParent>& mContentParent; |
639 | | }; |
640 | | |
641 | | class CheckPrincipalRunnable final : public Runnable |
642 | | { |
643 | | public: |
644 | | CheckPrincipalRunnable(already_AddRefed<ContentParent> aParent, |
645 | | const PrincipalInfo& aPrincipalInfo, |
646 | | const nsCString& aOrigin) |
647 | | : Runnable("ipc::CheckPrincipalRunnable") |
648 | | , mContentParent(aParent) |
649 | | , mPrincipalInfo(aPrincipalInfo) |
650 | | , mOrigin(aOrigin) |
651 | 0 | { |
652 | 0 | AssertIsInMainProcess(); |
653 | 0 | AssertIsOnBackgroundThread(); |
654 | 0 |
|
655 | 0 | MOZ_ASSERT(mContentParent); |
656 | 0 | } |
657 | | |
658 | | NS_IMETHOD Run() override |
659 | 0 | { |
660 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
661 | 0 |
|
662 | 0 | NullifyContentParentRAII raii(mContentParent); |
663 | 0 |
|
664 | 0 | nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(mPrincipalInfo); |
665 | 0 |
|
666 | 0 | nsAutoCString origin; |
667 | 0 | nsresult rv = principal->GetOrigin(origin); |
668 | 0 | if (NS_FAILED(rv)) { |
669 | 0 | mContentParent->KillHard("BroadcastChannel killed: principal::GetOrigin failed."); |
670 | 0 | return NS_OK; |
671 | 0 | } |
672 | 0 | |
673 | 0 | if (NS_WARN_IF(!mOrigin.Equals(origin))) { |
674 | 0 | mContentParent->KillHard("BroadcastChannel killed: origins do not match."); |
675 | 0 | return NS_OK; |
676 | 0 | } |
677 | 0 | |
678 | 0 | return NS_OK; |
679 | 0 | } |
680 | | |
681 | | private: |
682 | | RefPtr<ContentParent> mContentParent; |
683 | | PrincipalInfo mPrincipalInfo; |
684 | | nsCString mOrigin; |
685 | | }; |
686 | | |
687 | | } // namespace |
688 | | |
689 | | mozilla::ipc::IPCResult |
690 | | BackgroundParentImpl::RecvPBroadcastChannelConstructor( |
691 | | PBroadcastChannelParent* actor, |
692 | | const PrincipalInfo& aPrincipalInfo, |
693 | | const nsCString& aOrigin, |
694 | | const nsString& aChannel) |
695 | 0 | { |
696 | 0 | AssertIsInMainProcess(); |
697 | 0 | AssertIsOnBackgroundThread(); |
698 | 0 |
|
699 | 0 | RefPtr<ContentParent> parent = BackgroundParent::GetContentParent(this); |
700 | 0 |
|
701 | 0 | // If the ContentParent is null we are dealing with a same-process actor. |
702 | 0 | if (!parent) { |
703 | 0 | return IPC_OK(); |
704 | 0 | } |
705 | 0 |
|
706 | 0 | RefPtr<CheckPrincipalRunnable> runnable = |
707 | 0 | new CheckPrincipalRunnable(parent.forget(), aPrincipalInfo, aOrigin); |
708 | 0 | MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); |
709 | 0 |
|
710 | 0 | return IPC_OK(); |
711 | 0 | } |
712 | | |
713 | | bool |
714 | | BackgroundParentImpl::DeallocPBroadcastChannelParent( |
715 | | PBroadcastChannelParent* aActor) |
716 | 0 | { |
717 | 0 | AssertIsInMainProcess(); |
718 | 0 | AssertIsOnBackgroundThread(); |
719 | 0 | MOZ_ASSERT(aActor); |
720 | 0 |
|
721 | 0 | delete static_cast<BroadcastChannelParent*>(aActor); |
722 | 0 | return true; |
723 | 0 | } |
724 | | |
725 | | mozilla::dom::PServiceWorkerManagerParent* |
726 | | BackgroundParentImpl::AllocPServiceWorkerManagerParent() |
727 | 0 | { |
728 | 0 | AssertIsInMainProcess(); |
729 | 0 | AssertIsOnBackgroundThread(); |
730 | 0 |
|
731 | 0 | RefPtr<dom::ServiceWorkerManagerParent> agent = |
732 | 0 | new dom::ServiceWorkerManagerParent(); |
733 | 0 | return agent.forget().take(); |
734 | 0 | } |
735 | | |
736 | | bool |
737 | | BackgroundParentImpl::DeallocPServiceWorkerManagerParent( |
738 | | PServiceWorkerManagerParent* aActor) |
739 | 0 | { |
740 | 0 | AssertIsInMainProcess(); |
741 | 0 | AssertIsOnBackgroundThread(); |
742 | 0 | MOZ_ASSERT(aActor); |
743 | 0 |
|
744 | 0 | RefPtr<dom::ServiceWorkerManagerParent> parent = |
745 | 0 | dont_AddRef(static_cast<dom::ServiceWorkerManagerParent*>(aActor)); |
746 | 0 | MOZ_ASSERT(parent); |
747 | 0 | return true; |
748 | 0 | } |
749 | | |
750 | | mozilla::ipc::IPCResult |
751 | | BackgroundParentImpl::RecvShutdownServiceWorkerRegistrar() |
752 | 0 | { |
753 | 0 | AssertIsInMainProcess(); |
754 | 0 | AssertIsOnBackgroundThread(); |
755 | 0 |
|
756 | 0 | if (BackgroundParent::IsOtherProcessActor(this)) { |
757 | 0 | return IPC_FAIL_NO_REASON(this); |
758 | 0 | } |
759 | 0 |
|
760 | 0 | RefPtr<dom::ServiceWorkerRegistrar> service = |
761 | 0 | dom::ServiceWorkerRegistrar::Get(); |
762 | 0 | MOZ_ASSERT(service); |
763 | 0 |
|
764 | 0 | service->Shutdown(); |
765 | 0 | return IPC_OK(); |
766 | 0 | } |
767 | | |
768 | | PCacheStorageParent* |
769 | | BackgroundParentImpl::AllocPCacheStorageParent(const Namespace& aNamespace, |
770 | | const PrincipalInfo& aPrincipalInfo) |
771 | 0 | { |
772 | 0 | return dom::cache::AllocPCacheStorageParent(this, aNamespace, aPrincipalInfo); |
773 | 0 | } |
774 | | |
775 | | bool |
776 | | BackgroundParentImpl::DeallocPCacheStorageParent(PCacheStorageParent* aActor) |
777 | 0 | { |
778 | 0 | dom::cache::DeallocPCacheStorageParent(aActor); |
779 | 0 | return true; |
780 | 0 | } |
781 | | |
782 | | PCacheParent* |
783 | | BackgroundParentImpl::AllocPCacheParent() |
784 | 0 | { |
785 | 0 | MOZ_CRASH("CacheParent actor must be provided to PBackground manager"); |
786 | 0 | return nullptr; |
787 | 0 | } |
788 | | |
789 | | bool |
790 | | BackgroundParentImpl::DeallocPCacheParent(PCacheParent* aActor) |
791 | 0 | { |
792 | 0 | dom::cache::DeallocPCacheParent(aActor); |
793 | 0 | return true; |
794 | 0 | } |
795 | | |
796 | | PCacheStreamControlParent* |
797 | | BackgroundParentImpl::AllocPCacheStreamControlParent() |
798 | 0 | { |
799 | 0 | MOZ_CRASH("CacheStreamControlParent actor must be provided to PBackground manager"); |
800 | 0 | return nullptr; |
801 | 0 | } |
802 | | |
803 | | bool |
804 | | BackgroundParentImpl::DeallocPCacheStreamControlParent(PCacheStreamControlParent* aActor) |
805 | 0 | { |
806 | 0 | dom::cache::DeallocPCacheStreamControlParent(aActor); |
807 | 0 | return true; |
808 | 0 | } |
809 | | |
810 | | PMessagePortParent* |
811 | | BackgroundParentImpl::AllocPMessagePortParent(const nsID& aUUID, |
812 | | const nsID& aDestinationUUID, |
813 | | const uint32_t& aSequenceID) |
814 | 0 | { |
815 | 0 | AssertIsInMainProcess(); |
816 | 0 | AssertIsOnBackgroundThread(); |
817 | 0 |
|
818 | 0 | return new MessagePortParent(aUUID); |
819 | 0 | } |
820 | | |
821 | | mozilla::ipc::IPCResult |
822 | | BackgroundParentImpl::RecvPMessagePortConstructor(PMessagePortParent* aActor, |
823 | | const nsID& aUUID, |
824 | | const nsID& aDestinationUUID, |
825 | | const uint32_t& aSequenceID) |
826 | 0 | { |
827 | 0 | AssertIsInMainProcess(); |
828 | 0 | AssertIsOnBackgroundThread(); |
829 | 0 |
|
830 | 0 | MessagePortParent* mp = static_cast<MessagePortParent*>(aActor); |
831 | 0 | if (!mp->Entangle(aDestinationUUID, aSequenceID)) { |
832 | 0 | return IPC_FAIL_NO_REASON(this); |
833 | 0 | } |
834 | 0 | return IPC_OK(); |
835 | 0 | } |
836 | | |
837 | | bool |
838 | | BackgroundParentImpl::DeallocPMessagePortParent(PMessagePortParent* aActor) |
839 | 0 | { |
840 | 0 | AssertIsInMainProcess(); |
841 | 0 | AssertIsOnBackgroundThread(); |
842 | 0 | MOZ_ASSERT(aActor); |
843 | 0 |
|
844 | 0 | delete static_cast<MessagePortParent*>(aActor); |
845 | 0 | return true; |
846 | 0 | } |
847 | | |
848 | | mozilla::ipc::IPCResult |
849 | | BackgroundParentImpl::RecvMessagePortForceClose(const nsID& aUUID, |
850 | | const nsID& aDestinationUUID, |
851 | | const uint32_t& aSequenceID) |
852 | 0 | { |
853 | 0 | AssertIsInMainProcess(); |
854 | 0 | AssertIsOnBackgroundThread(); |
855 | 0 |
|
856 | 0 | if (!MessagePortParent::ForceClose(aUUID, aDestinationUUID, aSequenceID)) { |
857 | 0 | return IPC_FAIL_NO_REASON(this); |
858 | 0 | } |
859 | 0 | return IPC_OK(); |
860 | 0 | } |
861 | | |
862 | | PAsmJSCacheEntryParent* |
863 | | BackgroundParentImpl::AllocPAsmJSCacheEntryParent( |
864 | | const dom::asmjscache::OpenMode& aOpenMode, |
865 | | const dom::asmjscache::WriteParams& aWriteParams, |
866 | | const PrincipalInfo& aPrincipalInfo) |
867 | 0 | { |
868 | 0 | AssertIsInMainProcess(); |
869 | 0 | AssertIsOnBackgroundThread(); |
870 | 0 |
|
871 | 0 | return |
872 | 0 | dom::asmjscache::AllocEntryParent(aOpenMode, aWriteParams, aPrincipalInfo); |
873 | 0 | } |
874 | | |
875 | | bool |
876 | | BackgroundParentImpl::DeallocPAsmJSCacheEntryParent( |
877 | | PAsmJSCacheEntryParent* aActor) |
878 | 0 | { |
879 | 0 | AssertIsInMainProcess(); |
880 | 0 | AssertIsOnBackgroundThread(); |
881 | 0 |
|
882 | 0 | dom::asmjscache::DeallocEntryParent(aActor); |
883 | 0 | return true; |
884 | 0 | } |
885 | | |
886 | | BackgroundParentImpl::PQuotaParent* |
887 | | BackgroundParentImpl::AllocPQuotaParent() |
888 | 0 | { |
889 | 0 | AssertIsInMainProcess(); |
890 | 0 | AssertIsOnBackgroundThread(); |
891 | 0 |
|
892 | 0 | return mozilla::dom::quota::AllocPQuotaParent(); |
893 | 0 | } |
894 | | |
895 | | bool |
896 | | BackgroundParentImpl::DeallocPQuotaParent(PQuotaParent* aActor) |
897 | 0 | { |
898 | 0 | AssertIsInMainProcess(); |
899 | 0 | AssertIsOnBackgroundThread(); |
900 | 0 | MOZ_ASSERT(aActor); |
901 | 0 |
|
902 | 0 | return mozilla::dom::quota::DeallocPQuotaParent(aActor); |
903 | 0 | } |
904 | | |
905 | | dom::PFileSystemRequestParent* |
906 | | BackgroundParentImpl::AllocPFileSystemRequestParent( |
907 | | const FileSystemParams& aParams) |
908 | 0 | { |
909 | 0 | AssertIsInMainProcess(); |
910 | 0 | AssertIsOnBackgroundThread(); |
911 | 0 |
|
912 | 0 | RefPtr<FileSystemRequestParent> result = new FileSystemRequestParent(); |
913 | 0 |
|
914 | 0 | if (NS_WARN_IF(!result->Initialize(aParams))) { |
915 | 0 | return nullptr; |
916 | 0 | } |
917 | 0 | |
918 | 0 | return result.forget().take(); |
919 | 0 | } |
920 | | |
921 | | mozilla::ipc::IPCResult |
922 | | BackgroundParentImpl::RecvPFileSystemRequestConstructor( |
923 | | PFileSystemRequestParent* aActor, |
924 | | const FileSystemParams& params) |
925 | 0 | { |
926 | 0 | static_cast<FileSystemRequestParent*>(aActor)->Start(); |
927 | 0 | return IPC_OK(); |
928 | 0 | } |
929 | | |
930 | | bool |
931 | | BackgroundParentImpl::DeallocPFileSystemRequestParent( |
932 | | PFileSystemRequestParent* aDoomed) |
933 | 0 | { |
934 | 0 | AssertIsInMainProcess(); |
935 | 0 | AssertIsOnBackgroundThread(); |
936 | 0 |
|
937 | 0 | RefPtr<FileSystemRequestParent> parent = |
938 | 0 | dont_AddRef(static_cast<FileSystemRequestParent*>(aDoomed)); |
939 | 0 | return true; |
940 | 0 | } |
941 | | |
942 | | // Gamepad API Background IPC |
943 | | dom::PGamepadEventChannelParent* |
944 | | BackgroundParentImpl::AllocPGamepadEventChannelParent() |
945 | 0 | { |
946 | 0 | RefPtr<dom::GamepadEventChannelParent> parent = |
947 | 0 | new dom::GamepadEventChannelParent(); |
948 | 0 |
|
949 | 0 | return parent.forget().take(); |
950 | 0 | } |
951 | | |
952 | | bool |
953 | | BackgroundParentImpl::DeallocPGamepadEventChannelParent(dom::PGamepadEventChannelParent *aActor) |
954 | 0 | { |
955 | 0 | MOZ_ASSERT(aActor); |
956 | 0 | RefPtr<dom::GamepadEventChannelParent> parent = |
957 | 0 | dont_AddRef(static_cast<dom::GamepadEventChannelParent*>(aActor)); |
958 | 0 | return true; |
959 | 0 | } |
960 | | |
961 | | dom::PGamepadTestChannelParent* |
962 | | BackgroundParentImpl::AllocPGamepadTestChannelParent() |
963 | 0 | { |
964 | 0 | RefPtr<dom::GamepadTestChannelParent> parent = |
965 | 0 | new dom::GamepadTestChannelParent(); |
966 | 0 |
|
967 | 0 | return parent.forget().take(); |
968 | 0 | } |
969 | | |
970 | | bool |
971 | | BackgroundParentImpl::DeallocPGamepadTestChannelParent(dom::PGamepadTestChannelParent *aActor) |
972 | 0 | { |
973 | 0 | MOZ_ASSERT(aActor); |
974 | 0 | RefPtr<dom::GamepadTestChannelParent> parent = |
975 | 0 | dont_AddRef(static_cast<dom::GamepadTestChannelParent*>(aActor)); |
976 | 0 | return true; |
977 | 0 | } |
978 | | |
979 | | dom::PWebAuthnTransactionParent* |
980 | | BackgroundParentImpl::AllocPWebAuthnTransactionParent() |
981 | 0 | { |
982 | 0 | return new dom::WebAuthnTransactionParent(); |
983 | 0 | } |
984 | | |
985 | | bool |
986 | | BackgroundParentImpl::DeallocPWebAuthnTransactionParent(dom::PWebAuthnTransactionParent *aActor) |
987 | 0 | { |
988 | 0 | MOZ_ASSERT(aActor); |
989 | 0 | delete aActor; |
990 | 0 | return true; |
991 | 0 | } |
992 | | |
993 | | net::PHttpBackgroundChannelParent* |
994 | | BackgroundParentImpl::AllocPHttpBackgroundChannelParent(const uint64_t& aChannelId) |
995 | 0 | { |
996 | 0 | AssertIsInMainProcess(); |
997 | 0 | AssertIsOnBackgroundThread(); |
998 | 0 |
|
999 | 0 | RefPtr<net::HttpBackgroundChannelParent> actor = |
1000 | 0 | new net::HttpBackgroundChannelParent(); |
1001 | 0 |
|
1002 | 0 | // hold extra refcount for IPDL |
1003 | 0 | return actor.forget().take(); |
1004 | 0 | } |
1005 | | |
1006 | | mozilla::ipc::IPCResult |
1007 | | BackgroundParentImpl::RecvPHttpBackgroundChannelConstructor( |
1008 | | net::PHttpBackgroundChannelParent *aActor, |
1009 | | const uint64_t& aChannelId) |
1010 | 0 | { |
1011 | 0 | MOZ_ASSERT(aActor); |
1012 | 0 | AssertIsInMainProcess(); |
1013 | 0 | AssertIsOnBackgroundThread(); |
1014 | 0 |
|
1015 | 0 | net::HttpBackgroundChannelParent* aParent = |
1016 | 0 | static_cast<net::HttpBackgroundChannelParent*>(aActor); |
1017 | 0 |
|
1018 | 0 | if (NS_WARN_IF(NS_FAILED(aParent->Init(aChannelId)))) { |
1019 | 0 | return IPC_FAIL_NO_REASON(this); |
1020 | 0 | } |
1021 | 0 |
|
1022 | 0 | return IPC_OK(); |
1023 | 0 | } |
1024 | | |
1025 | | bool |
1026 | | BackgroundParentImpl::DeallocPHttpBackgroundChannelParent( |
1027 | | net::PHttpBackgroundChannelParent *aActor) |
1028 | 0 | { |
1029 | 0 | MOZ_ASSERT(aActor); |
1030 | 0 | AssertIsInMainProcess(); |
1031 | 0 | AssertIsOnBackgroundThread(); |
1032 | 0 |
|
1033 | 0 | // release extra refcount hold by AllocPHttpBackgroundChannelParent |
1034 | 0 | RefPtr<net::HttpBackgroundChannelParent> actor = |
1035 | 0 | dont_AddRef(static_cast<net::HttpBackgroundChannelParent*>(aActor)); |
1036 | 0 |
|
1037 | 0 | return true; |
1038 | 0 | } |
1039 | | |
1040 | | PMIDIPortParent* |
1041 | | BackgroundParentImpl::AllocPMIDIPortParent(const MIDIPortInfo& aPortInfo, const bool& aSysexEnabled) |
1042 | 0 | { |
1043 | 0 | AssertIsInMainProcess(); |
1044 | 0 | AssertIsOnBackgroundThread(); |
1045 | 0 |
|
1046 | 0 | RefPtr<MIDIPortParent> result = new MIDIPortParent(aPortInfo, aSysexEnabled); |
1047 | 0 | return result.forget().take(); |
1048 | 0 | } |
1049 | | |
1050 | | bool |
1051 | | BackgroundParentImpl::DeallocPMIDIPortParent(PMIDIPortParent* aActor) |
1052 | 0 | { |
1053 | 0 | MOZ_ASSERT(aActor); |
1054 | 0 | AssertIsInMainProcess(); |
1055 | 0 | AssertIsOnBackgroundThread(); |
1056 | 0 |
|
1057 | 0 | RefPtr<MIDIPortParent> parent = |
1058 | 0 | dont_AddRef(static_cast<MIDIPortParent*>(aActor)); |
1059 | 0 | parent->Teardown(); |
1060 | 0 | return true; |
1061 | 0 | } |
1062 | | |
1063 | | PMIDIManagerParent* |
1064 | | BackgroundParentImpl::AllocPMIDIManagerParent() |
1065 | 0 | { |
1066 | 0 | AssertIsInMainProcess(); |
1067 | 0 | AssertIsOnBackgroundThread(); |
1068 | 0 |
|
1069 | 0 | RefPtr<MIDIManagerParent> result = new MIDIManagerParent(); |
1070 | 0 | MIDIPlatformService::Get()->AddManager(result); |
1071 | 0 | return result.forget().take(); |
1072 | 0 | } |
1073 | | |
1074 | | bool |
1075 | | BackgroundParentImpl::DeallocPMIDIManagerParent(PMIDIManagerParent* aActor) |
1076 | 0 | { |
1077 | 0 | MOZ_ASSERT(aActor); |
1078 | 0 | AssertIsInMainProcess(); |
1079 | 0 | AssertIsOnBackgroundThread(); |
1080 | 0 |
|
1081 | 0 | RefPtr<MIDIManagerParent> parent = |
1082 | 0 | dont_AddRef(static_cast<MIDIManagerParent*>(aActor)); |
1083 | 0 | parent->Teardown(); |
1084 | 0 | return true; |
1085 | 0 | } |
1086 | | |
1087 | | mozilla::dom::PClientManagerParent* |
1088 | | BackgroundParentImpl::AllocPClientManagerParent() |
1089 | 0 | { |
1090 | 0 | return mozilla::dom::AllocClientManagerParent(); |
1091 | 0 | } |
1092 | | |
1093 | | bool |
1094 | | BackgroundParentImpl::DeallocPClientManagerParent(mozilla::dom::PClientManagerParent* aActor) |
1095 | 0 | { |
1096 | 0 | return mozilla::dom::DeallocClientManagerParent(aActor); |
1097 | 0 | } |
1098 | | |
1099 | | mozilla::ipc::IPCResult |
1100 | | BackgroundParentImpl::RecvPClientManagerConstructor(mozilla::dom::PClientManagerParent* aActor) |
1101 | 0 | { |
1102 | 0 | mozilla::dom::InitClientManagerParent(aActor); |
1103 | 0 | return IPC_OK(); |
1104 | 0 | } |
1105 | | |
1106 | | IPCResult |
1107 | | BackgroundParentImpl::RecvStorageActivity(const PrincipalInfo& aPrincipalInfo) |
1108 | 0 | { |
1109 | 0 | dom::StorageActivityService::SendActivity(aPrincipalInfo); |
1110 | 0 | return IPC_OK(); |
1111 | 0 | } |
1112 | | |
1113 | | PServiceWorkerParent* |
1114 | | BackgroundParentImpl::AllocPServiceWorkerParent(const IPCServiceWorkerDescriptor&) |
1115 | 0 | { |
1116 | 0 | return dom::AllocServiceWorkerParent(); |
1117 | 0 | } |
1118 | | |
1119 | | bool |
1120 | | BackgroundParentImpl::DeallocPServiceWorkerParent(PServiceWorkerParent* aActor) |
1121 | 0 | { |
1122 | 0 | return dom::DeallocServiceWorkerParent(aActor); |
1123 | 0 | } |
1124 | | |
1125 | | IPCResult |
1126 | | BackgroundParentImpl::RecvPServiceWorkerConstructor(PServiceWorkerParent* aActor, |
1127 | | const IPCServiceWorkerDescriptor& aDescriptor) |
1128 | 0 | { |
1129 | 0 | dom::InitServiceWorkerParent(aActor, aDescriptor); |
1130 | 0 | return IPC_OK(); |
1131 | 0 | } |
1132 | | |
1133 | | PServiceWorkerContainerParent* |
1134 | | BackgroundParentImpl::AllocPServiceWorkerContainerParent() |
1135 | 0 | { |
1136 | 0 | return dom::AllocServiceWorkerContainerParent(); |
1137 | 0 | } |
1138 | | |
1139 | | bool |
1140 | | BackgroundParentImpl::DeallocPServiceWorkerContainerParent(PServiceWorkerContainerParent* aActor) |
1141 | 0 | { |
1142 | 0 | return dom::DeallocServiceWorkerContainerParent(aActor); |
1143 | 0 | } |
1144 | | |
1145 | | mozilla::ipc::IPCResult |
1146 | | BackgroundParentImpl::RecvPServiceWorkerContainerConstructor(PServiceWorkerContainerParent* aActor) |
1147 | 0 | { |
1148 | 0 | dom::InitServiceWorkerContainerParent(aActor); |
1149 | 0 | return IPC_OK(); |
1150 | 0 | } |
1151 | | |
1152 | | PServiceWorkerRegistrationParent* |
1153 | | BackgroundParentImpl::AllocPServiceWorkerRegistrationParent(const IPCServiceWorkerRegistrationDescriptor&) |
1154 | 0 | { |
1155 | 0 | return dom::AllocServiceWorkerRegistrationParent(); |
1156 | 0 | } |
1157 | | |
1158 | | bool |
1159 | | BackgroundParentImpl::DeallocPServiceWorkerRegistrationParent(PServiceWorkerRegistrationParent* aActor) |
1160 | 0 | { |
1161 | 0 | return dom::DeallocServiceWorkerRegistrationParent(aActor); |
1162 | 0 | } |
1163 | | |
1164 | | mozilla::ipc::IPCResult |
1165 | | BackgroundParentImpl::RecvPServiceWorkerRegistrationConstructor(PServiceWorkerRegistrationParent* aActor, |
1166 | | const IPCServiceWorkerRegistrationDescriptor& aDescriptor) |
1167 | 0 | { |
1168 | 0 | dom::InitServiceWorkerRegistrationParent(aActor, aDescriptor); |
1169 | 0 | return IPC_OK(); |
1170 | 0 | } |
1171 | | |
1172 | | } // namespace ipc |
1173 | | } // namespace mozilla |
1174 | | |
1175 | | void |
1176 | | TestParent::ActorDestroy(ActorDestroyReason aWhy) |
1177 | 0 | { |
1178 | 0 | mozilla::ipc::AssertIsInMainProcess(); |
1179 | 0 | AssertIsOnBackgroundThread(); |
1180 | 0 | } |