summaryrefslogtreecommitdiffstats
path: root/dom/storage/StorageIPC.h
blob: 41d9d88319fea66c57b008fc0813755a902435ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_dom_StorageIPC_h
#define mozilla_dom_StorageIPC_h

#include "LocalStorageCache.h"
#include "StorageDBThread.h"
#include "StorageObserver.h"

#include "mozilla/Mutex.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/FlippedOnce.h"
#include "mozilla/dom/PBackgroundLocalStorageCacheChild.h"
#include "mozilla/dom/PBackgroundLocalStorageCacheParent.h"
#include "mozilla/dom/PBackgroundSessionStorageCacheChild.h"
#include "mozilla/dom/PBackgroundSessionStorageCacheParent.h"
#include "mozilla/dom/PBackgroundSessionStorageManagerChild.h"
#include "mozilla/dom/PBackgroundSessionStorageManagerParent.h"
#include "mozilla/dom/PBackgroundStorageChild.h"
#include "mozilla/dom/PBackgroundStorageParent.h"
#include "mozilla/dom/PSessionStorageObserverChild.h"
#include "mozilla/dom/PSessionStorageObserverParent.h"
#include "nsTHashSet.h"

namespace mozilla {

class OriginAttributesPattern;

namespace ipc {

class BackgroundChildImpl;
class PrincipalInfo;

}  // namespace ipc

namespace dom {

class LocalStorageManager;
class PBackgroundStorageParent;
class PSessionStorageObserverParent;
class SessionStorageCache;
class SessionStorageCacheParent;
class SessionStorageManager;
class SessionStorageManagerParent;
class BackgroundSessionStorageManager;
class SessionStorageObserver;

class LocalStorageCacheChild final : public PBackgroundLocalStorageCacheChild {
  friend class mozilla::ipc::BackgroundChildImpl;
  friend class LocalStorageCache;
  friend class LocalStorageManager;

  // LocalStorageCache effectively owns this instance, although IPC handles its
  // allocation/deallocation.  When the LocalStorageCache destructor runs, it
  // will invoke SendDeleteMeInternal() which will trigger both instances to
  // drop their mutual references and cause IPC to destroy the actor after the
  // DeleteMe round-trip.
  LocalStorageCache* MOZ_NON_OWNING_REF mCache;

  NS_DECL_OWNINGTHREAD

 public:
  void AssertIsOnOwningThread() const {
    NS_ASSERT_OWNINGTHREAD(LocalStorageCacheChild);
  }

 private:
  // Only created by LocalStorageManager.
  explicit LocalStorageCacheChild(LocalStorageCache* aCache);

  // Only destroyed by mozilla::ipc::BackgroundChildImpl.
  ~LocalStorageCacheChild();

  // Only called by LocalStorageCache.
  void SendDeleteMeInternal();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;

  mozilla::ipc::IPCResult RecvObserve(const PrincipalInfo& aPrincipalInfo,
                                      const PrincipalInfo& aCachePrincipalInfo,
                                      const uint32_t& aPrivateBrowsingId,
                                      const nsAString& aDocumentURI,
                                      const nsAString& aKey,
                                      const nsAString& aOldValue,
                                      const nsAString& aNewValue) override;
};

// Child side of the IPC protocol, exposes as DB interface but
// is responsible to send all requests to the parent process
// and expects asynchronous answers. Those are then transparently
// forwarded back to consumers on the child process.
class StorageDBChild final : public PBackgroundStorageChild {
  class ShutdownObserver;

  virtual ~StorageDBChild();

 public:
  StorageDBChild(LocalStorageManager* aManager, uint32_t aPrivateBrowsingId);

  static StorageDBChild* Get(uint32_t aPrivateBrowsingId);

  static StorageDBChild* GetOrCreate(uint32_t aPrivateBrowsingId);

  NS_INLINE_DECL_REFCOUNTING(StorageDBChild);

  void AddIPDLReference();
  void ReleaseIPDLReference();

  virtual nsresult Init();
  virtual nsresult Shutdown();

  virtual void AsyncPreload(LocalStorageCacheBridge* aCache,
                            bool aPriority = false);
  virtual void AsyncGetUsage(StorageUsageBridge* aUsage);

  virtual void SyncPreload(LocalStorageCacheBridge* aCache,
                           bool aForceSync = false);

  virtual nsresult AsyncAddItem(LocalStorageCacheBridge* aCache,
                                const nsAString& aKey, const nsAString& aValue);
  virtual nsresult AsyncUpdateItem(LocalStorageCacheBridge* aCache,
                                   const nsAString& aKey,
                                   const nsAString& aValue);
  virtual nsresult AsyncRemoveItem(LocalStorageCacheBridge* aCache,
                                   const nsAString& aKey);
  virtual nsresult AsyncClear(LocalStorageCacheBridge* aCache);

  virtual void AsyncClearAll() {
    if (mOriginsHavingData) {
      mOriginsHavingData->Clear(); /* NO-OP on the child process otherwise */
    }
  }

  virtual void AsyncClearMatchingOrigin(const nsACString& aOriginNoSuffix) {
    MOZ_CRASH("Shouldn't be called!");
  }

  virtual void AsyncClearMatchingOriginAttributes(
      const OriginAttributesPattern& aPattern) {
    MOZ_CRASH("Shouldn't be called!");
  }

  virtual void AsyncFlush() { MOZ_CRASH("Shouldn't be called!"); }

  virtual bool ShouldPreloadOrigin(const nsACString& aOriginNoSuffix);

 private:
  mozilla::ipc::IPCResult RecvObserve(const nsACString& aTopic,
                                      const nsAString& aOriginAttributesPattern,
                                      const nsACString& aOriginScope) override;
  mozilla::ipc::IPCResult RecvLoadItem(const nsACString& aOriginSuffix,
                                       const nsACString& aOriginNoSuffix,
                                       const nsAString& aKey,
                                       const nsAString& aValue) override;
  mozilla::ipc::IPCResult RecvLoadDone(const nsACString& aOriginSuffix,
                                       const nsACString& aOriginNoSuffix,
                                       const nsresult& aRv) override;
  mozilla::ipc::IPCResult RecvOriginsHavingData(
      nsTArray<nsCString>&& aOrigins) override;
  mozilla::ipc::IPCResult RecvLoadUsage(const nsACString& aOriginNoSuffix,
                                        const int64_t& aUsage) override;
  mozilla::ipc::IPCResult RecvError(const nsresult& aRv) override;

  nsTHashSet<nsCString>& OriginsHavingData();

  // Held to get caches to forward answers to.
  RefPtr<LocalStorageManager> mManager;

  // Origins having data hash, for optimization purposes only
  UniquePtr<nsTHashSet<nsCString>> mOriginsHavingData;

  // List of caches waiting for preload.  This ensures the contract that
  // AsyncPreload call references the cache for time of the preload.
  nsTHashSet<RefPtr<LocalStorageCacheBridge>> mLoadingCaches;

  // Expected to be only 0 or 1.
  const uint32_t mPrivateBrowsingId;

  // Status of the remote database
  nsresult mStatus;

  bool mIPCOpen;
};

class SessionStorageObserverChild final : public PSessionStorageObserverChild {
  friend class SessionStorageManager;
  friend class SessionStorageObserver;

  // SessionStorageObserver effectively owns this instance, although IPC handles
  // its allocation/deallocation.  When the SessionStorageObserver destructor
  // runs, it will invoke SendDeleteMeInternal() which will trigger both
  // instances to drop their mutual references and cause IPC to destroy the
  // actor after the DeleteMe round-trip.
  SessionStorageObserver* MOZ_NON_OWNING_REF mObserver;

  NS_DECL_OWNINGTHREAD

 public:
  void AssertIsOnOwningThread() const {
    NS_ASSERT_OWNINGTHREAD(LocalStorageCacheChild);
  }

 private:
  // Only created by SessionStorageManager.
  explicit SessionStorageObserverChild(SessionStorageObserver* aObserver);

  ~SessionStorageObserverChild();

  // Only called by SessionStorageObserver.
  void SendDeleteMeInternal();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;

  mozilla::ipc::IPCResult RecvObserve(const nsACString& aTopic,
                                      const nsAString& aOriginAttributesPattern,
                                      const nsACString& aOriginScope) override;
};

class SessionStorageCacheChild final
    : public PBackgroundSessionStorageCacheChild {
  friend class PBackgroundSessionStorageCacheChild;
  friend class SessionStorageCache;
  friend class SessionStorageManager;
  friend class mozilla::ipc::BackgroundChildImpl;

  // SessionStorageManagerChild effectively owns this instance, although IPC
  // handles its allocation/deallocation.  When the SessionStorageManager
  // destructor runs, it will invoke SendDeleteMeInternal() which will trigger
  // both instances to drop their mutual references and cause IPC to destroy the
  // actor after the DeleteMe round-trip.
  SessionStorageCache* MOZ_NON_OWNING_REF mCache;

  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageCacheChild, override)

 public:
  void AssertIsOnOwningThread() const {
    NS_ASSERT_OWNINGTHREAD(SesionStoragManagerChild);
  }

 private:
  // Only created by SessionStorageManager.
  explicit SessionStorageCacheChild(SessionStorageCache* aCache);

  // Only destroyed by mozilla::ipc::BackgroundChildImpl.
  ~SessionStorageCacheChild();

  // Only called by SessionStorageCache.
  void SendDeleteMeInternal();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;
};

class SessionStorageManagerChild final
    : public PBackgroundSessionStorageManagerChild {
  friend class PBackgroundSessionStorageManagerChild;
  friend class SessionStorage;
  friend class SessionStorageManager;
  friend class mozilla::ipc::BackgroundChildImpl;

  // SessionStorageManager effectively owns this instance, although IPC handles
  // its allocation/deallocation.  When the SessionStorageManager destructor
  // runs, it will invoke SendDeleteMeInternal() which will trigger both
  // instances to drop their mutual references and cause IPC to destroy the
  // actor after the DeleteMe round-trip.
  SessionStorageManager* MOZ_NON_OWNING_REF mSSManager;

  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageManagerChild, override)

 public:
  void AssertIsOnOwningThread() const {
    NS_ASSERT_OWNINGTHREAD(SesionStoragManagerChild);
  }

 private:
  // Only created by SessionStorage.
  explicit SessionStorageManagerChild(SessionStorageManager* aSSManager);

  // Only destroyed by mozilla::ipc::BackgroundChildImpl.
  ~SessionStorageManagerChild();

  // Only called by SessionStorageManager.
  void SendDeleteMeInternal();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;

  mozilla::ipc::IPCResult RecvClearStoragesForOrigin(
      const nsACString& aOriginAttrs, const nsACString& aOriginKey) override;
};

class LocalStorageCacheParent final
    : public PBackgroundLocalStorageCacheParent {
  const PrincipalInfo mPrincipalInfo;
  const nsCString mOriginKey;
  uint32_t mPrivateBrowsingId;
  bool mActorDestroyed;

 public:
  // Created in AllocPBackgroundLocalStorageCacheParent.
  LocalStorageCacheParent(const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
                          const nsACString& aOriginKey,
                          uint32_t aPrivateBrowsingId);

  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::LocalStorageCacheParent)

  const PrincipalInfo& PrincipalInfo() const { return mPrincipalInfo; }

 private:
  // Reference counted.
  ~LocalStorageCacheParent();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;

  mozilla::ipc::IPCResult RecvDeleteMe() override;

  mozilla::ipc::IPCResult RecvNotify(const nsAString& aDocumentURI,
                                     const nsAString& aKey,
                                     const nsAString& aOldValue,
                                     const nsAString& aNewValue) override;
};

// Receives async requests from child processes and is responsible
// to send back responses from the DB thread.  Exposes as a fake
// LocalStorageCache consumer.
// Also responsible for forwardning all chrome operation notifications
// such as cookie cleaning etc to the child process.
class StorageDBParent final : public PBackgroundStorageParent {
  class ObserverSink;

  virtual ~StorageDBParent();

 public:
  StorageDBParent(const nsAString& aProfilePath, uint32_t aPrivateBrowsingId);

  void Init();

  NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
  NS_IMETHOD_(MozExternalRefCountType) Release(void);

  void AddIPDLReference();
  void ReleaseIPDLReference();

  bool IPCOpen() { return mIPCOpen; }

 public:
  // Fake cache class receiving async callbacks from DB thread, sending
  // them back to appropriate cache object on the child process.
  class CacheParentBridge : public LocalStorageCacheBridge {
   public:
    CacheParentBridge(StorageDBParent* aParentDB,
                      const nsACString& aOriginSuffix,
                      const nsACString& aOriginNoSuffix)
        : mOwningEventTarget(GetCurrentSerialEventTarget()),
          mParent(aParentDB),
          mOriginSuffix(aOriginSuffix),
          mOriginNoSuffix(aOriginNoSuffix),
          mLoaded(false),
          mLoadedCount(0) {}
    virtual ~CacheParentBridge() = default;

    // LocalStorageCacheBridge
    virtual const nsCString Origin() const override;
    virtual const nsCString& OriginNoSuffix() const override {
      return mOriginNoSuffix;
    }
    virtual const nsCString& OriginSuffix() const override {
      return mOriginSuffix;
    }
    virtual bool Loaded() override { return mLoaded; }
    virtual uint32_t LoadedCount() override { return mLoadedCount; }

    virtual bool LoadItem(const nsAString& aKey,
                          const nsAString& aValue) override;
    virtual void LoadDone(nsresult aRv) override;
    virtual void LoadWait() override;

    NS_IMETHOD_(void)
    Release(void) override;

   private:
    void Destroy();

    nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;
    RefPtr<StorageDBParent> mParent;
    nsCString mOriginSuffix, mOriginNoSuffix;
    bool mLoaded;
    uint32_t mLoadedCount;
  };

  // Fake usage class receiving async callbacks from DB thread
  class UsageParentBridge : public StorageUsageBridge {
   public:
    UsageParentBridge(StorageDBParent* aParentDB,
                      const nsACString& aOriginScope)
        : mOwningEventTarget(GetCurrentSerialEventTarget()),
          mParent(aParentDB),
          mOriginScope(aOriginScope) {}
    virtual ~UsageParentBridge() = default;

    // StorageUsageBridge
    virtual const nsCString& OriginScope() override { return mOriginScope; }
    virtual void LoadUsage(const int64_t usage) override;

    NS_IMETHOD_(MozExternalRefCountType)
    Release(void) override;

   private:
    void Destroy();

    nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;
    RefPtr<StorageDBParent> mParent;
    nsCString mOriginScope;
  };

 private:
  // IPC
  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  mozilla::ipc::IPCResult RecvDeleteMe() override;

  mozilla::ipc::IPCResult RecvAsyncPreload(const nsACString& aOriginSuffix,
                                           const nsACString& aOriginNoSuffix,
                                           const bool& aPriority) override;
  mozilla::ipc::IPCResult RecvPreload(const nsACString& aOriginSuffix,
                                      const nsACString& aOriginNoSuffix,
                                      const uint32_t& aAlreadyLoadedCount,
                                      nsTArray<nsString>* aKeys,
                                      nsTArray<nsString>* aValues,
                                      nsresult* aRv) override;
  mozilla::ipc::IPCResult RecvAsyncGetUsage(
      const nsACString& aOriginNoSuffix) override;
  mozilla::ipc::IPCResult RecvAsyncAddItem(const nsACString& aOriginSuffix,
                                           const nsACString& aOriginNoSuffix,
                                           const nsAString& aKey,
                                           const nsAString& aValue) override;
  mozilla::ipc::IPCResult RecvAsyncUpdateItem(const nsACString& aOriginSuffix,
                                              const nsACString& aOriginNoSuffix,
                                              const nsAString& aKey,
                                              const nsAString& aValue) override;
  mozilla::ipc::IPCResult RecvAsyncRemoveItem(const nsACString& aOriginSuffix,
                                              const nsACString& aOriginNoSuffix,
                                              const nsAString& aKey) override;
  mozilla::ipc::IPCResult RecvAsyncClear(
      const nsACString& aOriginSuffix,
      const nsACString& aOriginNoSuffix) override;
  mozilla::ipc::IPCResult RecvAsyncFlush() override;

  mozilla::ipc::IPCResult RecvStartup() override;
  mozilla::ipc::IPCResult RecvClearAll() override;
  mozilla::ipc::IPCResult RecvClearMatchingOrigin(
      const nsACString& aOriginNoSuffix) override;
  mozilla::ipc::IPCResult RecvClearMatchingOriginAttributes(
      const OriginAttributesPattern& aPattern) override;

  void Observe(const nsACString& aTopic, const nsAString& aOriginAttrPattern,
               const nsACString& aOriginScope);

 private:
  CacheParentBridge* NewCache(const nsACString& aOriginSuffix,
                              const nsACString& aOriginNoSuffix);

  RefPtr<ObserverSink> mObserverSink;

  // A hack to deal with deadlock between the parent process main thread and
  // background thread when invoking StorageDBThread::GetOrCreate because it
  // cannot safely perform a synchronous dispatch back to the main thread
  // (because we are already synchronously doing things on the stack).
  // Populated for the same process actors, empty for other process actors.
  nsString mProfilePath;

  // Expected to be only 0 or 1.
  const uint32_t mPrivateBrowsingId;

  ThreadSafeAutoRefCnt mRefCnt;
  NS_DECL_OWNINGTHREAD

  // True when IPC channel is open and Send*() methods are OK to use.
  bool mIPCOpen;
};

class SessionStorageObserverParent final : public PSessionStorageObserverParent,
                                           public StorageObserverSink {
  bool mActorDestroyed;

 public:
  // Created in AllocPSessionStorageObserverParent.
  SessionStorageObserverParent();

  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageObserverParent)

 private:
  // Reference counted.
  ~SessionStorageObserverParent();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;

  mozilla::ipc::IPCResult RecvDeleteMe() override;

  // StorageObserverSink
  nsresult Observe(const char* aTopic, const nsAString& aOriginAttrPattern,
                   const nsACString& aOriginScope) override;
};

class SessionStorageCacheParent final
    : public PBackgroundSessionStorageCacheParent {
  friend class PBackgroundSessionStorageCacheParent;
  const PrincipalInfo mPrincipalInfo;
  const nsCString mOriginKey;

  RefPtr<SessionStorageManagerParent> mManagerActor;
  FlippedOnce<false> mLoadReceived;

 public:
  SessionStorageCacheParent(const PrincipalInfo& aPrincipalInfo,
                            const nsACString& aOriginKey,
                            SessionStorageManagerParent* aActor);

  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageCacheParent, override)

  const PrincipalInfo& PrincipalInfo() const { return mPrincipalInfo; }
  const nsACString& OriginKey() const { return mOriginKey; }

 private:
  ~SessionStorageCacheParent();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;

  mozilla::ipc::IPCResult RecvLoad(nsTArray<SSSetItemInfo>* aData) override;

  mozilla::ipc::IPCResult RecvCheckpoint(
      nsTArray<SSWriteInfo>&& aWriteInfos) override;

  mozilla::ipc::IPCResult RecvDeleteMe() override;
};

class SessionStorageManagerParent final
    : public PBackgroundSessionStorageManagerParent {
  friend class PBackgroundSessionStorageManagerParent;

  RefPtr<BackgroundSessionStorageManager> mBackgroundManager;

 public:
  explicit SessionStorageManagerParent(uint64_t aTopContextId);

  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageManagerParent,
                             override)

  already_AddRefed<PBackgroundSessionStorageCacheParent>
  AllocPBackgroundSessionStorageCacheParent(
      const PrincipalInfo& aPrincipalInfo,
      const nsACString& aOriginKey) override;

  BackgroundSessionStorageManager* GetManager() const;

  mozilla::ipc::IPCResult RecvClearStorages(
      const OriginAttributesPattern& aPattern,
      const nsACString& aOriginScope) override;

 private:
  ~SessionStorageManagerParent();

  // IPDL methods are only called by IPDL.
  void ActorDestroy(ActorDestroyReason aWhy) override;

  mozilla::ipc::IPCResult RecvDeleteMe() override;
};

PBackgroundLocalStorageCacheParent* AllocPBackgroundLocalStorageCacheParent(
    const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
    const nsACString& aOriginKey, const uint32_t& aPrivateBrowsingId);

mozilla::ipc::IPCResult RecvPBackgroundLocalStorageCacheConstructor(
    mozilla::ipc::PBackgroundParent* aBackgroundActor,
    PBackgroundLocalStorageCacheParent* aActor,
    const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
    const nsACString& aOriginKey, const uint32_t& aPrivateBrowsingId);

bool DeallocPBackgroundLocalStorageCacheParent(
    PBackgroundLocalStorageCacheParent* aActor);

PBackgroundStorageParent* AllocPBackgroundStorageParent(
    const nsAString& aProfilePath, const uint32_t& aPrivateBrowsingId);

mozilla::ipc::IPCResult RecvPBackgroundStorageConstructor(
    PBackgroundStorageParent* aActor, const nsAString& aProfilePath,
    const uint32_t& aPrivateBrowsingId);

bool DeallocPBackgroundStorageParent(PBackgroundStorageParent* aActor);

PSessionStorageObserverParent* AllocPSessionStorageObserverParent();

bool RecvPSessionStorageObserverConstructor(
    PSessionStorageObserverParent* aActor);

bool DeallocPSessionStorageObserverParent(
    PSessionStorageObserverParent* aActor);

already_AddRefed<PBackgroundSessionStorageCacheParent>
AllocPBackgroundSessionStorageCacheParent(
    const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
    const nsACString& aOriginKey);

already_AddRefed<PBackgroundSessionStorageManagerParent>
AllocPBackgroundSessionStorageManagerParent(const uint64_t& aTopContextId);
}  // namespace dom
}  // namespace mozilla

#endif  // mozilla_dom_StorageIPC_h