Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/ipc/glue/BackgroundChildImpl.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 "BackgroundChildImpl.h"
8
9
#include "ActorsChild.h" // IndexedDB
10
#include "BroadcastChannelChild.h"
11
#include "FileDescriptorSetChild.h"
12
#ifdef MOZ_WEBRTC
13
#include "CamerasChild.h"
14
#endif
15
#include "mozilla/media/MediaChild.h"
16
#include "mozilla/Assertions.h"
17
#include "mozilla/SchedulerGroup.h"
18
#include "mozilla/dom/ClientManagerActors.h"
19
#include "mozilla/dom/PBackgroundSDBConnectionChild.h"
20
#include "mozilla/dom/PFileSystemRequestChild.h"
21
#include "mozilla/dom/FileSystemTaskBase.h"
22
#include "mozilla/dom/asmjscache/AsmJSCache.h"
23
#include "mozilla/dom/cache/ActorUtils.h"
24
#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryChild.h"
25
#include "mozilla/dom/indexedDB/PBackgroundIndexedDBUtilsChild.h"
26
#include "mozilla/dom/ipc/IPCBlobInputStreamChild.h"
27
#include "mozilla/dom/ipc/PendingIPCBlobChild.h"
28
#include "mozilla/dom/ipc/TemporaryIPCBlobChild.h"
29
#include "mozilla/dom/quota/PQuotaChild.h"
30
#include "mozilla/dom/StorageIPC.h"
31
#include "mozilla/dom/GamepadEventChannelChild.h"
32
#include "mozilla/dom/GamepadTestChannelChild.h"
33
#include "mozilla/dom/LocalStorage.h"
34
#include "mozilla/dom/MessagePortChild.h"
35
#include "mozilla/dom/ServiceWorkerActors.h"
36
#include "mozilla/dom/ServiceWorkerManagerChild.h"
37
#include "mozilla/dom/TabChild.h"
38
#include "mozilla/dom/TabGroup.h"
39
#include "mozilla/ipc/IPCStreamAlloc.h"
40
#include "mozilla/ipc/PBackgroundTestChild.h"
41
#include "mozilla/ipc/PChildToParentStreamChild.h"
42
#include "mozilla/ipc/PParentToChildStreamChild.h"
43
#include "mozilla/layout/VsyncChild.h"
44
#include "mozilla/net/HttpBackgroundChannelChild.h"
45
#include "mozilla/net/PUDPSocketChild.h"
46
#include "mozilla/dom/network/UDPSocketChild.h"
47
#include "mozilla/dom/WebAuthnTransactionChild.h"
48
#include "mozilla/dom/MIDIPortChild.h"
49
#include "mozilla/dom/MIDIManagerChild.h"
50
#include "nsID.h"
51
#include "nsTraceRefcnt.h"
52
53
namespace {
54
55
class TestChild final : public mozilla::ipc::PBackgroundTestChild
56
{
57
  friend class mozilla::ipc::BackgroundChildImpl;
58
59
  nsCString mTestArg;
60
61
  explicit TestChild(const nsCString& aTestArg)
62
    : mTestArg(aTestArg)
63
0
  {
64
0
    MOZ_COUNT_CTOR(TestChild);
65
0
  }
66
67
protected:
68
  ~TestChild() override
69
0
  {
70
0
    MOZ_COUNT_DTOR(TestChild);
71
0
  }
72
73
public:
74
  mozilla::ipc::IPCResult
75
  Recv__delete__(const nsCString& aTestArg) override;
76
};
77
78
} // namespace
79
80
namespace mozilla {
81
namespace ipc {
82
83
using mozilla::dom::UDPSocketChild;
84
using mozilla::net::PUDPSocketChild;
85
86
using mozilla::dom::asmjscache::PAsmJSCacheEntryChild;
87
using mozilla::dom::cache::PCacheChild;
88
using mozilla::dom::cache::PCacheStorageChild;
89
using mozilla::dom::cache::PCacheStreamControlChild;
90
using mozilla::dom::LocalStorage;
91
using mozilla::dom::PServiceWorkerChild;
92
using mozilla::dom::PServiceWorkerContainerChild;
93
using mozilla::dom::PServiceWorkerRegistrationChild;
94
using mozilla::dom::StorageDBChild;
95
96
using mozilla::dom::WebAuthnTransactionChild;
97
98
using mozilla::dom::PMIDIPortChild;
99
using mozilla::dom::PMIDIManagerChild;
100
101
// -----------------------------------------------------------------------------
102
// BackgroundChildImpl::ThreadLocal
103
// -----------------------------------------------------------------------------
104
105
BackgroundChildImpl::
106
ThreadLocal::ThreadLocal()
107
  : mCurrentFileHandle(nullptr)
108
0
{
109
0
  // May happen on any thread!
110
0
  MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
111
0
}
112
113
BackgroundChildImpl::
114
ThreadLocal::~ThreadLocal()
115
0
{
116
0
  // May happen on any thread!
117
0
  MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl::ThreadLocal);
118
0
}
119
120
// -----------------------------------------------------------------------------
121
// BackgroundChildImpl
122
// -----------------------------------------------------------------------------
123
124
BackgroundChildImpl::BackgroundChildImpl()
125
0
{
126
0
  // May happen on any thread!
127
0
  MOZ_COUNT_CTOR(mozilla::ipc::BackgroundChildImpl);
128
0
}
129
130
BackgroundChildImpl::~BackgroundChildImpl()
131
0
{
132
0
  // May happen on any thread!
133
0
  MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl);
134
0
}
135
136
void
137
BackgroundChildImpl::ProcessingError(Result aCode, const char* aReason)
138
0
{
139
0
  // May happen on any thread!
140
0
141
0
  nsAutoCString abortMessage;
142
0
143
0
  switch (aCode) {
144
0
145
0
#define HANDLE_CASE(_result)                                                   \
146
0
    case _result:                                                              \
147
0
      abortMessage.AssignLiteral(#_result);                                    \
148
0
      break
149
0
150
0
    HANDLE_CASE(MsgDropped);
151
0
    HANDLE_CASE(MsgNotKnown);
152
0
    HANDLE_CASE(MsgNotAllowed);
153
0
    HANDLE_CASE(MsgPayloadError);
154
0
    HANDLE_CASE(MsgProcessingError);
155
0
    HANDLE_CASE(MsgRouteError);
156
0
    HANDLE_CASE(MsgValueError);
157
0
158
0
#undef HANDLE_CASE
159
0
160
0
    default:
161
0
      MOZ_CRASH("Unknown error code!");
162
0
  }
163
0
164
0
  MOZ_CRASH_UNSAFE_PRINTF("%s: %s", abortMessage.get(), aReason);
165
0
}
166
167
void
168
BackgroundChildImpl::ActorDestroy(ActorDestroyReason aWhy)
169
0
{
170
0
  // May happen on any thread!
171
0
}
172
173
PBackgroundTestChild*
174
BackgroundChildImpl::AllocPBackgroundTestChild(const nsCString& aTestArg)
175
0
{
176
0
  return new TestChild(aTestArg);
177
0
}
178
179
bool
180
BackgroundChildImpl::DeallocPBackgroundTestChild(PBackgroundTestChild* aActor)
181
0
{
182
0
  MOZ_ASSERT(aActor);
183
0
184
0
  delete static_cast<TestChild*>(aActor);
185
0
  return true;
186
0
}
187
188
BackgroundChildImpl::PBackgroundIDBFactoryChild*
189
BackgroundChildImpl::AllocPBackgroundIDBFactoryChild(
190
                                                const LoggingInfo& aLoggingInfo)
191
0
{
192
0
  MOZ_CRASH("PBackgroundIDBFactoryChild actors should be manually "
193
0
            "constructed!");
194
0
}
195
196
bool
197
BackgroundChildImpl::DeallocPBackgroundIDBFactoryChild(
198
                                             PBackgroundIDBFactoryChild* aActor)
199
0
{
200
0
  MOZ_ASSERT(aActor);
201
0
202
0
  delete aActor;
203
0
  return true;
204
0
}
205
206
BackgroundChildImpl::PBackgroundIndexedDBUtilsChild*
207
BackgroundChildImpl::AllocPBackgroundIndexedDBUtilsChild()
208
0
{
209
0
  MOZ_CRASH("PBackgroundIndexedDBUtilsChild actors should be manually "
210
0
            "constructed!");
211
0
}
212
213
bool
214
BackgroundChildImpl::DeallocPBackgroundIndexedDBUtilsChild(
215
                                         PBackgroundIndexedDBUtilsChild* aActor)
216
0
{
217
0
  MOZ_ASSERT(aActor);
218
0
219
0
  delete aActor;
220
0
  return true;
221
0
}
222
223
BackgroundChildImpl::PBackgroundLocalStorageCacheChild*
224
BackgroundChildImpl::AllocPBackgroundLocalStorageCacheChild(
225
                                            const PrincipalInfo& aPrincipalInfo,
226
                                            const nsCString& aOriginKey,
227
                                            const uint32_t& aPrivateBrowsingId)
228
0
{
229
0
  MOZ_CRASH("PBackgroundLocalStorageChild actors should be manually "
230
0
            "constructed!");
231
0
}
232
233
bool
234
BackgroundChildImpl::DeallocPBackgroundLocalStorageCacheChild(
235
                                      PBackgroundLocalStorageCacheChild* aActor)
236
0
{
237
0
  MOZ_ASSERT(aActor);
238
0
239
0
  delete aActor;
240
0
  return true;
241
0
}
242
243
BackgroundChildImpl::PBackgroundSDBConnectionChild*
244
BackgroundChildImpl::AllocPBackgroundSDBConnectionChild(
245
                                            const PrincipalInfo& aPrincipalInfo)
246
0
{
247
0
  MOZ_CRASH("PBackgroundSDBConnectionChild actor should be manually "
248
0
            "constructed!");
249
0
}
250
251
bool
252
BackgroundChildImpl::DeallocPBackgroundSDBConnectionChild(
253
                                          PBackgroundSDBConnectionChild* aActor)
254
0
{
255
0
  MOZ_ASSERT(aActor);
256
0
257
0
  delete aActor;
258
0
  return true;
259
0
}
260
261
BackgroundChildImpl::PBackgroundStorageChild*
262
BackgroundChildImpl::AllocPBackgroundStorageChild(const nsString& aProfilePath)
263
0
{
264
0
  MOZ_CRASH("PBackgroundStorageChild actors should be manually constructed!");
265
0
}
266
267
bool
268
BackgroundChildImpl::DeallocPBackgroundStorageChild(
269
                                                PBackgroundStorageChild* aActor)
270
0
{
271
0
  MOZ_ASSERT(aActor);
272
0
273
0
  StorageDBChild* child = static_cast<StorageDBChild*>(aActor);
274
0
  child->ReleaseIPDLReference();
275
0
  return true;
276
0
}
277
278
PPendingIPCBlobChild*
279
BackgroundChildImpl::AllocPPendingIPCBlobChild(const IPCBlob& aBlob)
280
0
{
281
0
  return new mozilla::dom::PendingIPCBlobChild(aBlob);
282
0
}
283
284
bool
285
BackgroundChildImpl::DeallocPPendingIPCBlobChild(PPendingIPCBlobChild* aActor)
286
0
{
287
0
  delete aActor;
288
0
  return true;
289
0
}
290
291
PTemporaryIPCBlobChild*
292
BackgroundChildImpl::AllocPTemporaryIPCBlobChild()
293
0
{
294
0
  MOZ_CRASH("This is not supposed to be called.");
295
0
  return nullptr;
296
0
}
297
298
bool
299
BackgroundChildImpl::DeallocPTemporaryIPCBlobChild(PTemporaryIPCBlobChild* aActor)
300
0
{
301
0
  RefPtr<mozilla::dom::TemporaryIPCBlobChild> actor =
302
0
    dont_AddRef(static_cast<mozilla::dom::TemporaryIPCBlobChild*>(aActor));
303
0
  return true;
304
0
}
305
306
PIPCBlobInputStreamChild*
307
BackgroundChildImpl::AllocPIPCBlobInputStreamChild(const nsID& aID,
308
                                                   const uint64_t& aSize)
309
0
{
310
0
  // IPCBlobInputStreamChild is refcounted. Here it's created and in
311
0
  // DeallocPIPCBlobInputStreamChild is released.
312
0
313
0
  RefPtr<mozilla::dom::IPCBlobInputStreamChild> actor =
314
0
    new mozilla::dom::IPCBlobInputStreamChild(aID, aSize);
315
0
  return actor.forget().take();
316
0
}
317
318
bool
319
BackgroundChildImpl::DeallocPIPCBlobInputStreamChild(PIPCBlobInputStreamChild* aActor)
320
0
{
321
0
  RefPtr<mozilla::dom::IPCBlobInputStreamChild> actor =
322
0
    dont_AddRef(static_cast<mozilla::dom::IPCBlobInputStreamChild*>(aActor));
323
0
  return true;
324
0
}
325
326
PFileDescriptorSetChild*
327
BackgroundChildImpl::AllocPFileDescriptorSetChild(
328
                                          const FileDescriptor& aFileDescriptor)
329
0
{
330
0
  return new FileDescriptorSetChild(aFileDescriptor);
331
0
}
332
333
bool
334
BackgroundChildImpl::DeallocPFileDescriptorSetChild(
335
                                                PFileDescriptorSetChild* aActor)
336
0
{
337
0
  MOZ_ASSERT(aActor);
338
0
339
0
  delete static_cast<FileDescriptorSetChild*>(aActor);
340
0
  return true;
341
0
}
342
343
BackgroundChildImpl::PVsyncChild*
344
BackgroundChildImpl::AllocPVsyncChild()
345
0
{
346
0
  RefPtr<mozilla::layout::VsyncChild> actor = new mozilla::layout::VsyncChild();
347
0
  // There still has one ref-count after return, and it will be released in
348
0
  // DeallocPVsyncChild().
349
0
  return actor.forget().take();
350
0
}
351
352
bool
353
BackgroundChildImpl::DeallocPVsyncChild(PVsyncChild* aActor)
354
0
{
355
0
  MOZ_ASSERT(aActor);
356
0
357
0
  // This actor already has one ref-count. Please check AllocPVsyncChild().
358
0
  RefPtr<mozilla::layout::VsyncChild> actor =
359
0
      dont_AddRef(static_cast<mozilla::layout::VsyncChild*>(aActor));
360
0
  return true;
361
0
}
362
363
PUDPSocketChild*
364
BackgroundChildImpl::AllocPUDPSocketChild(const OptionalPrincipalInfo& aPrincipalInfo,
365
                                          const nsCString& aFilter)
366
0
{
367
0
  MOZ_CRASH("AllocPUDPSocket should not be called");
368
0
  return nullptr;
369
0
}
370
371
bool
372
BackgroundChildImpl::DeallocPUDPSocketChild(PUDPSocketChild* child)
373
0
{
374
0
375
0
  UDPSocketChild* p = static_cast<UDPSocketChild*>(child);
376
0
  p->ReleaseIPDLReference();
377
0
  return true;
378
0
}
379
380
// -----------------------------------------------------------------------------
381
// BroadcastChannel API
382
// -----------------------------------------------------------------------------
383
384
dom::PBroadcastChannelChild*
385
BackgroundChildImpl::AllocPBroadcastChannelChild(const PrincipalInfo& aPrincipalInfo,
386
                                                 const nsCString& aOrigin,
387
                                                 const nsString& aChannel)
388
0
{
389
0
  RefPtr<dom::BroadcastChannelChild> agent =
390
0
    new dom::BroadcastChannelChild(aOrigin);
391
0
  return agent.forget().take();
392
0
}
393
394
bool
395
BackgroundChildImpl::DeallocPBroadcastChannelChild(
396
                                                 PBroadcastChannelChild* aActor)
397
0
{
398
0
  RefPtr<dom::BroadcastChannelChild> child =
399
0
    dont_AddRef(static_cast<dom::BroadcastChannelChild*>(aActor));
400
0
  MOZ_ASSERT(child);
401
0
  return true;
402
0
}
403
404
camera::PCamerasChild*
405
BackgroundChildImpl::AllocPCamerasChild()
406
0
{
407
0
#ifdef MOZ_WEBRTC
408
0
  RefPtr<camera::CamerasChild> agent =
409
0
    new camera::CamerasChild();
410
0
  return agent.forget().take();
411
#else
412
  return nullptr;
413
#endif
414
}
415
416
bool
417
BackgroundChildImpl::DeallocPCamerasChild(camera::PCamerasChild *aActor)
418
0
{
419
0
#ifdef MOZ_WEBRTC
420
0
  RefPtr<camera::CamerasChild> child =
421
0
      dont_AddRef(static_cast<camera::CamerasChild*>(aActor));
422
0
  MOZ_ASSERT(aActor);
423
0
  camera::Shutdown();
424
0
#endif
425
0
  return true;
426
0
}
427
428
// -----------------------------------------------------------------------------
429
// ServiceWorkerManager
430
// -----------------------------------------------------------------------------
431
432
dom::PServiceWorkerManagerChild*
433
BackgroundChildImpl::AllocPServiceWorkerManagerChild()
434
0
{
435
0
  RefPtr<dom::ServiceWorkerManagerChild> agent =
436
0
    new dom::ServiceWorkerManagerChild();
437
0
  return agent.forget().take();
438
0
}
439
440
bool
441
BackgroundChildImpl::DeallocPServiceWorkerManagerChild(
442
                                             PServiceWorkerManagerChild* aActor)
443
0
{
444
0
  RefPtr<dom::ServiceWorkerManagerChild> child =
445
0
    dont_AddRef(static_cast<dom::ServiceWorkerManagerChild*>(aActor));
446
0
  MOZ_ASSERT(child);
447
0
  return true;
448
0
}
449
450
// -----------------------------------------------------------------------------
451
// Cache API
452
// -----------------------------------------------------------------------------
453
454
PCacheStorageChild*
455
BackgroundChildImpl::AllocPCacheStorageChild(const Namespace& aNamespace,
456
                                             const PrincipalInfo& aPrincipalInfo)
457
0
{
458
0
  MOZ_CRASH("CacheStorageChild actor must be provided to PBackground manager");
459
0
  return nullptr;
460
0
}
461
462
bool
463
BackgroundChildImpl::DeallocPCacheStorageChild(PCacheStorageChild* aActor)
464
0
{
465
0
  dom::cache::DeallocPCacheStorageChild(aActor);
466
0
  return true;
467
0
}
468
469
PCacheChild*
470
BackgroundChildImpl::AllocPCacheChild()
471
0
{
472
0
  return dom::cache::AllocPCacheChild();
473
0
}
474
475
bool
476
BackgroundChildImpl::DeallocPCacheChild(PCacheChild* aActor)
477
0
{
478
0
  dom::cache::DeallocPCacheChild(aActor);
479
0
  return true;
480
0
}
481
482
PCacheStreamControlChild*
483
BackgroundChildImpl::AllocPCacheStreamControlChild()
484
0
{
485
0
  return dom::cache::AllocPCacheStreamControlChild();
486
0
}
487
488
bool
489
BackgroundChildImpl::DeallocPCacheStreamControlChild(PCacheStreamControlChild* aActor)
490
0
{
491
0
  dom::cache::DeallocPCacheStreamControlChild(aActor);
492
0
  return true;
493
0
}
494
495
// -----------------------------------------------------------------------------
496
// MessageChannel/MessagePort API
497
// -----------------------------------------------------------------------------
498
499
dom::PMessagePortChild*
500
BackgroundChildImpl::AllocPMessagePortChild(const nsID& aUUID,
501
                                            const nsID& aDestinationUUID,
502
                                            const uint32_t& aSequenceID)
503
0
{
504
0
  RefPtr<dom::MessagePortChild> agent = new dom::MessagePortChild();
505
0
  return agent.forget().take();
506
0
}
507
508
bool
509
BackgroundChildImpl::DeallocPMessagePortChild(PMessagePortChild* aActor)
510
0
{
511
0
  RefPtr<dom::MessagePortChild> child =
512
0
    dont_AddRef(static_cast<dom::MessagePortChild*>(aActor));
513
0
  MOZ_ASSERT(child);
514
0
  return true;
515
0
}
516
517
PChildToParentStreamChild*
518
BackgroundChildImpl::AllocPChildToParentStreamChild()
519
0
{
520
0
  MOZ_CRASH("PChildToParentStreamChild actors should be manually constructed!");
521
0
}
522
523
bool
524
BackgroundChildImpl::DeallocPChildToParentStreamChild(PChildToParentStreamChild* aActor)
525
0
{
526
0
  delete aActor;
527
0
  return true;
528
0
}
529
530
PParentToChildStreamChild*
531
BackgroundChildImpl::AllocPParentToChildStreamChild()
532
0
{
533
0
  return mozilla::ipc::AllocPParentToChildStreamChild();
534
0
}
535
536
bool
537
BackgroundChildImpl::DeallocPParentToChildStreamChild(PParentToChildStreamChild* aActor)
538
0
{
539
0
  delete aActor;
540
0
  return true;
541
0
}
542
543
PAsmJSCacheEntryChild*
544
BackgroundChildImpl::AllocPAsmJSCacheEntryChild(
545
                               const dom::asmjscache::OpenMode& aOpenMode,
546
                               const dom::asmjscache::WriteParams& aWriteParams,
547
                               const PrincipalInfo& aPrincipalInfo)
548
0
{
549
0
  MOZ_CRASH("PAsmJSCacheEntryChild actors should be manually constructed!");
550
0
}
551
552
bool
553
BackgroundChildImpl::DeallocPAsmJSCacheEntryChild(PAsmJSCacheEntryChild* aActor)
554
0
{
555
0
  MOZ_ASSERT(aActor);
556
0
557
0
  dom::asmjscache::DeallocEntryChild(aActor);
558
0
  return true;
559
0
}
560
561
BackgroundChildImpl::PQuotaChild*
562
BackgroundChildImpl::AllocPQuotaChild()
563
0
{
564
0
  MOZ_CRASH("PQuotaChild actor should be manually constructed!");
565
0
}
566
567
bool
568
BackgroundChildImpl::DeallocPQuotaChild(PQuotaChild* aActor)
569
0
{
570
0
  MOZ_ASSERT(aActor);
571
0
  delete aActor;
572
0
  return true;
573
0
}
574
575
// -----------------------------------------------------------------------------
576
// WebMIDI API
577
// -----------------------------------------------------------------------------
578
579
PMIDIPortChild*
580
BackgroundChildImpl::AllocPMIDIPortChild(const MIDIPortInfo& aPortInfo, const bool& aSysexEnabled)
581
0
{
582
0
    MOZ_CRASH("Should be created manually");
583
0
    return nullptr;
584
0
}
585
586
bool
587
BackgroundChildImpl::DeallocPMIDIPortChild(PMIDIPortChild* aActor)
588
0
{
589
0
  MOZ_ASSERT(aActor);
590
0
  // The reference is increased in dom/midi/MIDIPort.cpp. We should
591
0
  // decrease it after IPC.
592
0
  RefPtr<dom::MIDIPortChild> child =
593
0
    dont_AddRef(static_cast<dom::MIDIPortChild*>(aActor));
594
0
  child->Teardown();
595
0
  return true;
596
0
}
597
598
PMIDIManagerChild*
599
BackgroundChildImpl::AllocPMIDIManagerChild()
600
0
{
601
0
  MOZ_CRASH("Should be created manually");
602
0
  return nullptr;
603
0
}
604
605
bool
606
BackgroundChildImpl::DeallocPMIDIManagerChild(PMIDIManagerChild* aActor)
607
0
{
608
0
  MOZ_ASSERT(aActor);
609
0
  // The reference is increased in dom/midi/MIDIAccessManager.cpp. We should
610
0
  // decrease it after IPC.
611
0
  RefPtr<dom::MIDIManagerChild> child =
612
0
    dont_AddRef(static_cast<dom::MIDIManagerChild*>(aActor));
613
0
  return true;
614
0
}
615
616
dom::PFileSystemRequestChild*
617
BackgroundChildImpl::AllocPFileSystemRequestChild(const FileSystemParams& aParams)
618
0
{
619
0
  MOZ_CRASH("Should never get here!");
620
0
  return nullptr;
621
0
}
622
623
bool
624
BackgroundChildImpl::DeallocPFileSystemRequestChild(PFileSystemRequestChild* aActor)
625
0
{
626
0
  // The reference is increased in FileSystemTaskBase::Start of
627
0
  // FileSystemTaskBase.cpp. We should decrease it after IPC.
628
0
  RefPtr<dom::FileSystemTaskChildBase> child =
629
0
    dont_AddRef(static_cast<dom::FileSystemTaskChildBase*>(aActor));
630
0
  return true;
631
0
}
632
633
// Gamepad API Background IPC
634
dom::PGamepadEventChannelChild*
635
BackgroundChildImpl::AllocPGamepadEventChannelChild()
636
0
{
637
0
  MOZ_CRASH("PGamepadEventChannelChild actor should be manually constructed!");
638
0
  return nullptr;
639
0
}
640
641
bool
642
BackgroundChildImpl::DeallocPGamepadEventChannelChild(PGamepadEventChannelChild* aActor)
643
0
{
644
0
  MOZ_ASSERT(aActor);
645
0
  delete static_cast<dom::GamepadEventChannelChild*>(aActor);
646
0
  return true;
647
0
}
648
649
dom::PGamepadTestChannelChild*
650
BackgroundChildImpl::AllocPGamepadTestChannelChild()
651
0
{
652
0
  MOZ_CRASH("PGamepadTestChannelChild actor should be manually constructed!");
653
0
  return nullptr;
654
0
}
655
656
bool
657
BackgroundChildImpl::DeallocPGamepadTestChannelChild(PGamepadTestChannelChild* aActor)
658
0
{
659
0
  MOZ_ASSERT(aActor);
660
0
  delete static_cast<dom::GamepadTestChannelChild*>(aActor);
661
0
  return true;
662
0
}
663
664
mozilla::dom::PClientManagerChild*
665
BackgroundChildImpl::AllocPClientManagerChild()
666
0
{
667
0
  return mozilla::dom::AllocClientManagerChild();
668
0
}
669
670
bool
671
BackgroundChildImpl::DeallocPClientManagerChild(mozilla::dom::PClientManagerChild* aActor)
672
0
{
673
0
  return mozilla::dom::DeallocClientManagerChild(aActor);
674
0
}
675
676
#ifdef EARLY_BETA_OR_EARLIER
677
void
678
BackgroundChildImpl::OnChannelReceivedMessage(const Message& aMsg)
679
0
{
680
0
  if (aMsg.type() == layout::PVsync::MessageType::Msg_Notify__ID) {
681
0
    // Not really necessary to look at the message payload, it will be
682
0
    // <0.5ms away from TimeStamp::Now()
683
0
    SchedulerGroup::MarkVsyncReceived();
684
0
  }
685
0
}
686
#endif
687
688
dom::PWebAuthnTransactionChild*
689
BackgroundChildImpl::AllocPWebAuthnTransactionChild()
690
0
{
691
0
  MOZ_CRASH("PWebAuthnTransaction actor should be manually constructed!");
692
0
  return nullptr;
693
0
}
694
695
bool
696
BackgroundChildImpl::DeallocPWebAuthnTransactionChild(PWebAuthnTransactionChild* aActor)
697
0
{
698
0
  MOZ_ASSERT(aActor);
699
0
  RefPtr<dom::WebAuthnTransactionChild> child =
700
0
    dont_AddRef(static_cast<dom::WebAuthnTransactionChild*>(aActor));
701
0
  return true;
702
0
}
703
704
net::PHttpBackgroundChannelChild*
705
BackgroundChildImpl::AllocPHttpBackgroundChannelChild(const uint64_t& aChannelId)
706
0
{
707
0
  MOZ_CRASH("PHttpBackgroundChannelChild actor should be manually constructed!");
708
0
  return nullptr;
709
0
}
710
711
bool
712
BackgroundChildImpl::DeallocPHttpBackgroundChannelChild(PHttpBackgroundChannelChild* aActor)
713
0
{
714
0
  // The reference is increased in BackgroundChannelCreateCallback::ActorCreated
715
0
  // of HttpBackgroundChannelChild.cpp. We should decrease it after IPC
716
0
  // destroyed.
717
0
  RefPtr<net::HttpBackgroundChannelChild> child =
718
0
    dont_AddRef(static_cast<net::HttpBackgroundChannelChild*>(aActor));
719
0
  return true;
720
0
}
721
722
PServiceWorkerChild*
723
BackgroundChildImpl::AllocPServiceWorkerChild(const IPCServiceWorkerDescriptor&)
724
0
{
725
0
  return dom::AllocServiceWorkerChild();
726
0
}
727
728
bool
729
BackgroundChildImpl::DeallocPServiceWorkerChild(PServiceWorkerChild* aActor)
730
0
{
731
0
  return dom::DeallocServiceWorkerChild(aActor);
732
0
}
733
734
PServiceWorkerContainerChild*
735
BackgroundChildImpl::AllocPServiceWorkerContainerChild()
736
0
{
737
0
  return dom::AllocServiceWorkerContainerChild();
738
0
}
739
740
bool
741
BackgroundChildImpl::DeallocPServiceWorkerContainerChild(PServiceWorkerContainerChild* aActor)
742
0
{
743
0
  return dom::DeallocServiceWorkerContainerChild(aActor);
744
0
}
745
746
PServiceWorkerRegistrationChild*
747
BackgroundChildImpl::AllocPServiceWorkerRegistrationChild(const IPCServiceWorkerRegistrationDescriptor&)
748
0
{
749
0
  return dom::AllocServiceWorkerRegistrationChild();
750
0
}
751
752
bool
753
BackgroundChildImpl::DeallocPServiceWorkerRegistrationChild(PServiceWorkerRegistrationChild* aActor)
754
0
{
755
0
  return dom::DeallocServiceWorkerRegistrationChild(aActor);
756
0
}
757
758
bool
759
BackgroundChildImpl::GetMessageSchedulerGroups(const Message& aMsg, SchedulerGroupSet& aGroups)
760
0
{
761
0
  if (aMsg.type() == layout::PVsync::MessageType::Msg_Notify__ID) {
762
0
    MOZ_ASSERT(NS_IsMainThread());
763
0
    aGroups.Clear();
764
0
    if (dom::TabChild::HasVisibleTabs()) {
765
0
      for (auto iter = dom::TabChild::GetVisibleTabs().ConstIter();
766
0
           !iter.Done(); iter.Next()) {
767
0
        aGroups.Put(iter.Get()->GetKey()->TabGroup());
768
0
      }
769
0
    }
770
0
    return true;
771
0
  }
772
0
773
0
  return false;
774
0
}
775
776
} // namespace ipc
777
} // namespace mozilla
778
779
mozilla::ipc::IPCResult
780
TestChild::Recv__delete__(const nsCString& aTestArg)
781
0
{
782
0
  MOZ_RELEASE_ASSERT(aTestArg == mTestArg,
783
0
                     "BackgroundTest message was corrupted!");
784
0
785
0
  return IPC_OK();
786
0
}