tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

StorageIPC.h (22635B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_StorageIPC_h
      8 #define mozilla_dom_StorageIPC_h
      9 
     10 #include "LocalStorageCache.h"
     11 #include "StorageDBThread.h"
     12 #include "StorageObserver.h"
     13 #include "mozilla/Mutex.h"
     14 #include "mozilla/UniquePtr.h"
     15 #include "mozilla/dom/FlippedOnce.h"
     16 #include "mozilla/dom/PBackgroundLocalStorageCacheChild.h"
     17 #include "mozilla/dom/PBackgroundLocalStorageCacheParent.h"
     18 #include "mozilla/dom/PBackgroundSessionStorageCacheChild.h"
     19 #include "mozilla/dom/PBackgroundSessionStorageCacheParent.h"
     20 #include "mozilla/dom/PBackgroundSessionStorageManagerChild.h"
     21 #include "mozilla/dom/PBackgroundSessionStorageManagerParent.h"
     22 #include "mozilla/dom/PBackgroundStorageChild.h"
     23 #include "mozilla/dom/PBackgroundStorageParent.h"
     24 #include "mozilla/dom/PSessionStorageObserverChild.h"
     25 #include "mozilla/dom/PSessionStorageObserverParent.h"
     26 #include "nsTHashSet.h"
     27 
     28 namespace mozilla {
     29 
     30 class OriginAttributesPattern;
     31 
     32 namespace ipc {
     33 
     34 class BackgroundChildImpl;
     35 class PrincipalInfo;
     36 
     37 }  // namespace ipc
     38 
     39 namespace dom {
     40 
     41 class LocalStorageManager;
     42 class PBackgroundStorageParent;
     43 class PSessionStorageObserverParent;
     44 class SessionStorageCache;
     45 class SessionStorageCacheParent;
     46 class SessionStorageManager;
     47 class SessionStorageManagerParent;
     48 class BackgroundSessionStorageManager;
     49 class SessionStorageObserver;
     50 
     51 class LocalStorageCacheChild final : public PBackgroundLocalStorageCacheChild {
     52  friend class mozilla::ipc::BackgroundChildImpl;
     53  friend class LocalStorageCache;
     54  friend class LocalStorageManager;
     55 
     56  // LocalStorageCache effectively owns this instance, although IPC handles its
     57  // allocation/deallocation.  When the LocalStorageCache destructor runs, it
     58  // will invoke SendDeleteMeInternal() which will trigger both instances to
     59  // drop their mutual references and cause IPC to destroy the actor after the
     60  // DeleteMe round-trip.
     61  LocalStorageCache* MOZ_NON_OWNING_REF mCache;
     62 
     63  NS_DECL_OWNINGTHREAD
     64 
     65 public:
     66  void AssertIsOnOwningThread() const {
     67    NS_ASSERT_OWNINGTHREAD(LocalStorageCacheChild);
     68  }
     69 
     70 private:
     71  // Only created by LocalStorageManager.
     72  explicit LocalStorageCacheChild(LocalStorageCache* aCache);
     73 
     74  // Only destroyed by mozilla::ipc::BackgroundChildImpl.
     75  ~LocalStorageCacheChild();
     76 
     77  // Only called by LocalStorageCache.
     78  void SendDeleteMeInternal();
     79 
     80  // IPDL methods are only called by IPDL.
     81  void ActorDestroy(ActorDestroyReason aWhy) override;
     82 
     83  mozilla::ipc::IPCResult RecvObserve(const PrincipalInfo& aPrincipalInfo,
     84                                      const PrincipalInfo& aCachePrincipalInfo,
     85                                      const uint32_t& aPrivateBrowsingId,
     86                                      const nsAString& aDocumentURI,
     87                                      const nsAString& aKey,
     88                                      const nsAString& aOldValue,
     89                                      const nsAString& aNewValue) override;
     90 };
     91 
     92 // Child side of the IPC protocol, exposes as DB interface but
     93 // is responsible to send all requests to the parent process
     94 // and expects asynchronous answers. Those are then transparently
     95 // forwarded back to consumers on the child process.
     96 class StorageDBChild final : public PBackgroundStorageChild {
     97  class ShutdownObserver;
     98 
     99  virtual ~StorageDBChild();
    100 
    101 public:
    102  StorageDBChild(LocalStorageManager* aManager, uint32_t aPrivateBrowsingId);
    103 
    104  static StorageDBChild* Get(uint32_t aPrivateBrowsingId);
    105 
    106  static StorageDBChild* GetOrCreate(uint32_t aPrivateBrowsingId);
    107 
    108  NS_INLINE_DECL_REFCOUNTING(StorageDBChild);
    109 
    110  void AddIPDLReference();
    111  void ReleaseIPDLReference();
    112 
    113  virtual nsresult Init();
    114  virtual nsresult Shutdown();
    115 
    116  virtual void AsyncPreload(LocalStorageCacheBridge* aCache,
    117                            bool aPriority = false);
    118  virtual void AsyncGetUsage(StorageUsageBridge* aUsage);
    119 
    120  virtual void SyncPreload(LocalStorageCacheBridge* aCache,
    121                           bool aForceSync = false);
    122 
    123  virtual nsresult AsyncAddItem(LocalStorageCacheBridge* aCache,
    124                                const nsAString& aKey, const nsAString& aValue);
    125  virtual nsresult AsyncUpdateItem(LocalStorageCacheBridge* aCache,
    126                                   const nsAString& aKey,
    127                                   const nsAString& aValue);
    128  virtual nsresult AsyncRemoveItem(LocalStorageCacheBridge* aCache,
    129                                   const nsAString& aKey);
    130  virtual nsresult AsyncClear(LocalStorageCacheBridge* aCache);
    131 
    132  virtual void AsyncClearAll() {
    133    if (mOriginsHavingData) {
    134      mOriginsHavingData->Clear(); /* NO-OP on the child process otherwise */
    135    }
    136  }
    137 
    138  virtual void AsyncClearMatchingOrigin(const nsACString& aOriginNoSuffix) {
    139    MOZ_CRASH("Shouldn't be called!");
    140  }
    141 
    142  virtual void AsyncClearMatchingOriginAttributes(
    143      const OriginAttributesPattern& aPattern) {
    144    MOZ_CRASH("Shouldn't be called!");
    145  }
    146 
    147  virtual void AsyncFlush() { MOZ_CRASH("Shouldn't be called!"); }
    148 
    149  virtual bool ShouldPreloadOrigin(const nsACString& aOriginNoSuffix);
    150 
    151 private:
    152  mozilla::ipc::IPCResult RecvObserve(const nsACString& aTopic,
    153                                      const nsAString& aOriginAttributesPattern,
    154                                      const nsACString& aOriginScope) override;
    155  mozilla::ipc::IPCResult RecvLoadItem(const nsACString& aOriginSuffix,
    156                                       const nsACString& aOriginNoSuffix,
    157                                       const nsAString& aKey,
    158                                       const nsAString& aValue) override;
    159  mozilla::ipc::IPCResult RecvLoadDone(const nsACString& aOriginSuffix,
    160                                       const nsACString& aOriginNoSuffix,
    161                                       const nsresult& aRv) override;
    162  mozilla::ipc::IPCResult RecvOriginsHavingData(
    163      nsTArray<nsCString>&& aOrigins) override;
    164  mozilla::ipc::IPCResult RecvLoadUsage(const nsACString& aOriginNoSuffix,
    165                                        const int64_t& aUsage) override;
    166  mozilla::ipc::IPCResult RecvError(const nsresult& aRv) override;
    167 
    168  nsTHashSet<nsCString>& OriginsHavingData();
    169 
    170  // Held to get caches to forward answers to.
    171  RefPtr<LocalStorageManager> mManager;
    172 
    173  // Origins having data hash, for optimization purposes only
    174  UniquePtr<nsTHashSet<nsCString>> mOriginsHavingData;
    175 
    176  // List of caches waiting for preload.  This ensures the contract that
    177  // AsyncPreload call references the cache for time of the preload.
    178  nsTHashSet<RefPtr<LocalStorageCacheBridge>> mLoadingCaches;
    179 
    180  // Expected to be only 0 or 1.
    181  const uint32_t mPrivateBrowsingId;
    182 
    183  // Status of the remote database
    184  nsresult mStatus;
    185 
    186  bool mIPCOpen;
    187 };
    188 
    189 class SessionStorageObserverChild final : public PSessionStorageObserverChild {
    190  friend class SessionStorageManager;
    191  friend class SessionStorageObserver;
    192 
    193  // SessionStorageObserver effectively owns this instance, although IPC handles
    194  // its allocation/deallocation.  When the SessionStorageObserver destructor
    195  // runs, it will invoke SendDeleteMeInternal() which will trigger both
    196  // instances to drop their mutual references and cause IPC to destroy the
    197  // actor after the DeleteMe round-trip.
    198  SessionStorageObserver* MOZ_NON_OWNING_REF mObserver;
    199 
    200  NS_DECL_OWNINGTHREAD
    201 
    202 public:
    203  void AssertIsOnOwningThread() const {
    204    NS_ASSERT_OWNINGTHREAD(LocalStorageCacheChild);
    205  }
    206 
    207 private:
    208  // Only created by SessionStorageManager.
    209  explicit SessionStorageObserverChild(SessionStorageObserver* aObserver);
    210 
    211  ~SessionStorageObserverChild();
    212 
    213  // Only called by SessionStorageObserver.
    214  void SendDeleteMeInternal();
    215 
    216  // IPDL methods are only called by IPDL.
    217  void ActorDestroy(ActorDestroyReason aWhy) override;
    218 
    219  mozilla::ipc::IPCResult RecvObserve(const nsACString& aTopic,
    220                                      const nsAString& aOriginAttributesPattern,
    221                                      const nsACString& aOriginScope) override;
    222 };
    223 
    224 class SessionStorageCacheChild final
    225    : public PBackgroundSessionStorageCacheChild {
    226  friend class PBackgroundSessionStorageCacheChild;
    227  friend class SessionStorageCache;
    228  friend class SessionStorageManager;
    229  friend class mozilla::ipc::BackgroundChildImpl;
    230 
    231  // SessionStorageManagerChild effectively owns this instance, although IPC
    232  // handles its allocation/deallocation.  When the SessionStorageManager
    233  // destructor runs, it will invoke SendDeleteMeInternal() which will trigger
    234  // both instances to drop their mutual references and cause IPC to destroy the
    235  // actor after the DeleteMe round-trip.
    236  SessionStorageCache* MOZ_NON_OWNING_REF mCache;
    237 
    238  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageCacheChild, override)
    239 
    240 public:
    241  void AssertIsOnOwningThread() const {
    242    NS_ASSERT_OWNINGTHREAD(SesionStoragManagerChild);
    243  }
    244 
    245 private:
    246  // Only created by SessionStorageManager.
    247  explicit SessionStorageCacheChild(SessionStorageCache* aCache);
    248 
    249  // Only destroyed by mozilla::ipc::BackgroundChildImpl.
    250  ~SessionStorageCacheChild();
    251 
    252  // Only called by SessionStorageCache.
    253  void SendDeleteMeInternal();
    254 
    255  // IPDL methods are only called by IPDL.
    256  void ActorDestroy(ActorDestroyReason aWhy) override;
    257 };
    258 
    259 class SessionStorageManagerChild final
    260    : public PBackgroundSessionStorageManagerChild {
    261  friend class PBackgroundSessionStorageManagerChild;
    262  friend class SessionStorage;
    263  friend class SessionStorageManager;
    264  friend class mozilla::ipc::BackgroundChildImpl;
    265 
    266  // SessionStorageManager effectively owns this instance, although IPC handles
    267  // its allocation/deallocation.  When the SessionStorageManager destructor
    268  // runs, it will invoke SendDeleteMeInternal() which will trigger both
    269  // instances to drop their mutual references and cause IPC to destroy the
    270  // actor after the DeleteMe round-trip.
    271  SessionStorageManager* MOZ_NON_OWNING_REF mSSManager;
    272 
    273  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageManagerChild, override)
    274 
    275 public:
    276  void AssertIsOnOwningThread() const {
    277    NS_ASSERT_OWNINGTHREAD(SesionStoragManagerChild);
    278  }
    279 
    280 private:
    281  // Only created by SessionStorage.
    282  explicit SessionStorageManagerChild(SessionStorageManager* aSSManager);
    283 
    284  // Only destroyed by mozilla::ipc::BackgroundChildImpl.
    285  ~SessionStorageManagerChild();
    286 
    287  // Only called by SessionStorageManager.
    288  void SendDeleteMeInternal();
    289 
    290  // IPDL methods are only called by IPDL.
    291  void ActorDestroy(ActorDestroyReason aWhy) override;
    292 
    293  mozilla::ipc::IPCResult RecvClearStoragesForOrigin(
    294      const nsACString& aOriginAttrs, const nsACString& aOriginKey) override;
    295 };
    296 
    297 class LocalStorageCacheParent final
    298    : public PBackgroundLocalStorageCacheParent {
    299  const PrincipalInfo mPrincipalInfo;
    300  const nsCString mOriginKey;
    301  uint32_t mPrivateBrowsingId;
    302  bool mActorDestroyed;
    303 
    304 public:
    305  // Created in AllocPBackgroundLocalStorageCacheParent.
    306  LocalStorageCacheParent(const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
    307                          const nsACString& aOriginKey,
    308                          uint32_t aPrivateBrowsingId);
    309 
    310  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::LocalStorageCacheParent)
    311 
    312  const PrincipalInfo& PrincipalInfo() const { return mPrincipalInfo; }
    313 
    314 private:
    315  // Reference counted.
    316  ~LocalStorageCacheParent();
    317 
    318  // IPDL methods are only called by IPDL.
    319  void ActorDestroy(ActorDestroyReason aWhy) override;
    320 
    321  mozilla::ipc::IPCResult RecvDeleteMe() override;
    322 
    323  mozilla::ipc::IPCResult RecvNotify(const nsAString& aDocumentURI,
    324                                     const nsAString& aKey,
    325                                     const nsAString& aOldValue,
    326                                     const nsAString& aNewValue) override;
    327 };
    328 
    329 // Receives async requests from child processes and is responsible
    330 // to send back responses from the DB thread.  Exposes as a fake
    331 // LocalStorageCache consumer.
    332 // Also responsible for forwardning all chrome operation notifications
    333 // such as cookie cleaning etc to the child process.
    334 class StorageDBParent final : public PBackgroundStorageParent {
    335  class ObserverSink;
    336 
    337  virtual ~StorageDBParent();
    338 
    339 public:
    340  StorageDBParent(const nsAString& aProfilePath, uint32_t aPrivateBrowsingId);
    341 
    342  void Init();
    343 
    344  NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
    345  NS_IMETHOD_(MozExternalRefCountType) Release(void);
    346 
    347  void AddIPDLReference();
    348  void ReleaseIPDLReference();
    349 
    350  bool IPCOpen() { return mIPCOpen; }
    351 
    352 public:
    353  // Fake cache class receiving async callbacks from DB thread, sending
    354  // them back to appropriate cache object on the child process.
    355  class CacheParentBridge : public LocalStorageCacheBridge {
    356   public:
    357    CacheParentBridge(StorageDBParent* aParentDB,
    358                      const nsACString& aOriginSuffix,
    359                      const nsACString& aOriginNoSuffix)
    360        : mOwningEventTarget(GetCurrentSerialEventTarget()),
    361          mParent(aParentDB),
    362          mOriginSuffix(aOriginSuffix),
    363          mOriginNoSuffix(aOriginNoSuffix),
    364          mLoaded(false),
    365          mLoadedCount(0) {}
    366    virtual ~CacheParentBridge() = default;
    367 
    368    // LocalStorageCacheBridge
    369    virtual const nsCString Origin() const override;
    370    virtual const nsCString& OriginNoSuffix() const override {
    371      return mOriginNoSuffix;
    372    }
    373    virtual const nsCString& OriginSuffix() const override {
    374      return mOriginSuffix;
    375    }
    376    virtual bool Loaded() override { return mLoaded; }
    377    virtual uint32_t LoadedCount() override { return mLoadedCount; }
    378 
    379    virtual bool LoadItem(const nsAString& aKey,
    380                          const nsAString& aValue) override;
    381    virtual void LoadDone(nsresult aRv) override;
    382    virtual void LoadWait() override;
    383 
    384    NS_IMETHOD_(void)
    385    Release(void) override;
    386 
    387   private:
    388    void Destroy();
    389 
    390    nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;
    391    RefPtr<StorageDBParent> mParent;
    392    nsCString mOriginSuffix, mOriginNoSuffix;
    393    bool mLoaded;
    394    uint32_t mLoadedCount;
    395  };
    396 
    397  // Fake usage class receiving async callbacks from DB thread
    398  class UsageParentBridge : public StorageUsageBridge {
    399   public:
    400    UsageParentBridge(StorageDBParent* aParentDB,
    401                      const nsACString& aOriginScope)
    402        : mOwningEventTarget(GetCurrentSerialEventTarget()),
    403          mParent(aParentDB),
    404          mOriginScope(aOriginScope) {}
    405    virtual ~UsageParentBridge() = default;
    406 
    407    // StorageUsageBridge
    408    virtual const nsCString& OriginScope() override { return mOriginScope; }
    409    virtual void LoadUsage(const int64_t usage) override;
    410 
    411    NS_IMETHOD_(MozExternalRefCountType)
    412    Release(void) override;
    413 
    414   private:
    415    void Destroy();
    416 
    417    nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;
    418    RefPtr<StorageDBParent> mParent;
    419    nsCString mOriginScope;
    420  };
    421 
    422 private:
    423  // IPC
    424  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
    425  mozilla::ipc::IPCResult RecvDeleteMe() override;
    426 
    427  mozilla::ipc::IPCResult RecvAsyncPreload(const nsACString& aOriginSuffix,
    428                                           const nsACString& aOriginNoSuffix,
    429                                           const bool& aPriority) override;
    430  mozilla::ipc::IPCResult RecvPreload(const nsACString& aOriginSuffix,
    431                                      const nsACString& aOriginNoSuffix,
    432                                      const uint32_t& aAlreadyLoadedCount,
    433                                      nsTArray<nsString>* aKeys,
    434                                      nsTArray<nsString>* aValues,
    435                                      nsresult* aRv) override;
    436  mozilla::ipc::IPCResult RecvAsyncGetUsage(
    437      const nsACString& aOriginNoSuffix) override;
    438  mozilla::ipc::IPCResult RecvAsyncAddItem(const nsACString& aOriginSuffix,
    439                                           const nsACString& aOriginNoSuffix,
    440                                           const nsAString& aKey,
    441                                           const nsAString& aValue) override;
    442  mozilla::ipc::IPCResult RecvAsyncUpdateItem(const nsACString& aOriginSuffix,
    443                                              const nsACString& aOriginNoSuffix,
    444                                              const nsAString& aKey,
    445                                              const nsAString& aValue) override;
    446  mozilla::ipc::IPCResult RecvAsyncRemoveItem(const nsACString& aOriginSuffix,
    447                                              const nsACString& aOriginNoSuffix,
    448                                              const nsAString& aKey) override;
    449  mozilla::ipc::IPCResult RecvAsyncClear(
    450      const nsACString& aOriginSuffix,
    451      const nsACString& aOriginNoSuffix) override;
    452  mozilla::ipc::IPCResult RecvAsyncFlush() override;
    453 
    454  mozilla::ipc::IPCResult RecvStartup() override;
    455  mozilla::ipc::IPCResult RecvClearAll() override;
    456  mozilla::ipc::IPCResult RecvClearMatchingOrigin(
    457      const nsACString& aOriginNoSuffix) override;
    458  mozilla::ipc::IPCResult RecvClearMatchingOriginAttributes(
    459      const OriginAttributesPattern& aPattern) override;
    460 
    461  void Observe(const nsACString& aTopic, const nsAString& aOriginAttrPattern,
    462               const nsACString& aOriginScope);
    463 
    464 private:
    465  CacheParentBridge* NewCache(const nsACString& aOriginSuffix,
    466                              const nsACString& aOriginNoSuffix);
    467 
    468  RefPtr<ObserverSink> mObserverSink;
    469 
    470  // A hack to deal with deadlock between the parent process main thread and
    471  // background thread when invoking StorageDBThread::GetOrCreate because it
    472  // cannot safely perform a synchronous dispatch back to the main thread
    473  // (because we are already synchronously doing things on the stack).
    474  // Populated for the same process actors, empty for other process actors.
    475  nsString mProfilePath;
    476 
    477  // Expected to be only 0 or 1.
    478  const uint32_t mPrivateBrowsingId;
    479 
    480  ThreadSafeAutoRefCnt mRefCnt;
    481  NS_DECL_OWNINGTHREAD
    482 
    483  // True when IPC channel is open and Send*() methods are OK to use.
    484  bool mIPCOpen;
    485 };
    486 
    487 class SessionStorageObserverParent final : public PSessionStorageObserverParent,
    488                                           public StorageObserverSink {
    489  bool mActorDestroyed;
    490 
    491 public:
    492  // Created in AllocPSessionStorageObserverParent.
    493  SessionStorageObserverParent();
    494 
    495  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageObserverParent)
    496 
    497 private:
    498  // Reference counted.
    499  ~SessionStorageObserverParent();
    500 
    501  // IPDL methods are only called by IPDL.
    502  void ActorDestroy(ActorDestroyReason aWhy) override;
    503 
    504  mozilla::ipc::IPCResult RecvDeleteMe() override;
    505 
    506  // StorageObserverSink
    507  nsresult Observe(const char* aTopic, const nsAString& aOriginAttrPattern,
    508                   const nsACString& aOriginScope) override;
    509 };
    510 
    511 class SessionStorageCacheParent final
    512    : public PBackgroundSessionStorageCacheParent {
    513  friend class PBackgroundSessionStorageCacheParent;
    514  const PrincipalInfo mPrincipalInfo;
    515  const nsCString mOriginKey;
    516 
    517  RefPtr<SessionStorageManagerParent> mManagerActor;
    518  FlippedOnce<false> mLoadReceived;
    519 
    520 public:
    521  SessionStorageCacheParent(const PrincipalInfo& aPrincipalInfo,
    522                            const nsACString& aOriginKey,
    523                            SessionStorageManagerParent* aActor);
    524 
    525  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageCacheParent, override)
    526 
    527  const PrincipalInfo& PrincipalInfo() const { return mPrincipalInfo; }
    528  const nsACString& OriginKey() const { return mOriginKey; }
    529 
    530 private:
    531  ~SessionStorageCacheParent();
    532 
    533  // IPDL methods are only called by IPDL.
    534  void ActorDestroy(ActorDestroyReason aWhy) override;
    535 
    536  mozilla::ipc::IPCResult RecvLoad(nsTArray<SSSetItemInfo>* aData) override;
    537 
    538  mozilla::ipc::IPCResult RecvCheckpoint(
    539      nsTArray<SSWriteInfo>&& aWriteInfos) override;
    540 
    541  mozilla::ipc::IPCResult RecvDeleteMe() override;
    542 };
    543 
    544 class SessionStorageManagerParent final
    545    : public PBackgroundSessionStorageManagerParent {
    546  friend class PBackgroundSessionStorageManagerParent;
    547 
    548  RefPtr<BackgroundSessionStorageManager> mBackgroundManager;
    549 
    550 public:
    551  explicit SessionStorageManagerParent(uint64_t aTopContextId);
    552 
    553  NS_INLINE_DECL_REFCOUNTING(mozilla::dom::SessionStorageManagerParent,
    554                             override)
    555 
    556  already_AddRefed<PBackgroundSessionStorageCacheParent>
    557  AllocPBackgroundSessionStorageCacheParent(
    558      const PrincipalInfo& aPrincipalInfo,
    559      const nsACString& aOriginKey) override;
    560 
    561  BackgroundSessionStorageManager* GetManager() const;
    562 
    563  mozilla::ipc::IPCResult RecvClearStorages(
    564      const OriginAttributesPattern& aPattern, const nsACString& aOriginScope,
    565      const uint32_t& aMode) override;
    566 
    567 private:
    568  ~SessionStorageManagerParent();
    569 
    570  // IPDL methods are only called by IPDL.
    571  void ActorDestroy(ActorDestroyReason aWhy) override;
    572 
    573  mozilla::ipc::IPCResult RecvDeleteMe() override;
    574 };
    575 
    576 PBackgroundLocalStorageCacheParent* AllocPBackgroundLocalStorageCacheParent(
    577    const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
    578    const nsACString& aOriginKey, const uint32_t& aPrivateBrowsingId);
    579 
    580 mozilla::ipc::IPCResult RecvPBackgroundLocalStorageCacheConstructor(
    581    mozilla::ipc::PBackgroundParent* aBackgroundActor,
    582    PBackgroundLocalStorageCacheParent* aActor,
    583    const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
    584    const nsACString& aOriginKey, const uint32_t& aPrivateBrowsingId);
    585 
    586 bool DeallocPBackgroundLocalStorageCacheParent(
    587    PBackgroundLocalStorageCacheParent* aActor);
    588 
    589 PBackgroundStorageParent* AllocPBackgroundStorageParent(
    590    const nsAString& aProfilePath, const uint32_t& aPrivateBrowsingId);
    591 
    592 mozilla::ipc::IPCResult RecvPBackgroundStorageConstructor(
    593    PBackgroundStorageParent* aActor, const nsAString& aProfilePath,
    594    const uint32_t& aPrivateBrowsingId);
    595 
    596 bool DeallocPBackgroundStorageParent(PBackgroundStorageParent* aActor);
    597 
    598 PSessionStorageObserverParent* AllocPSessionStorageObserverParent();
    599 
    600 bool RecvPSessionStorageObserverConstructor(
    601    PSessionStorageObserverParent* aActor);
    602 
    603 bool DeallocPSessionStorageObserverParent(
    604    PSessionStorageObserverParent* aActor);
    605 
    606 already_AddRefed<PBackgroundSessionStorageCacheParent>
    607 AllocPBackgroundSessionStorageCacheParent(
    608    const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
    609    const nsACString& aOriginKey);
    610 
    611 already_AddRefed<PBackgroundSessionStorageManagerParent>
    612 AllocPBackgroundSessionStorageManagerParent(const uint64_t& aTopContextId);
    613 }  // namespace dom
    614 }  // namespace mozilla
    615 
    616 #endif  // mozilla_dom_StorageIPC_h