tor-browser

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

BackgroundChildImpl.h (6383B)


      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 #ifndef mozilla_ipc_backgroundchildimpl_h__
      8 #define mozilla_ipc_backgroundchildimpl_h__
      9 
     10 #include "mozilla/ipc/PBackgroundChild.h"
     11 #include "mozilla/UniquePtr.h"
     12 
     13 namespace mozilla {
     14 namespace dom {
     15 
     16 class IDBFileHandle;
     17 
     18 namespace indexedDB {
     19 
     20 class ThreadLocal;
     21 
     22 }  // namespace indexedDB
     23 }  // namespace dom
     24 
     25 namespace ipc {
     26 
     27 // Instances of this class should never be created directly. This class is meant
     28 // to be inherited in BackgroundImpl.
     29 class BackgroundChildImpl : public PBackgroundChild {
     30 public:
     31  class ThreadLocal;
     32 
     33  // Get the ThreadLocal for the current thread if
     34  // BackgroundChild::GetOrCreateForCurrentThread() has been called and true was
     35  // returned (e.g. a valid PBackgroundChild actor has been created or is in the
     36  // process of being created). Otherwise this function returns null.
     37  // This functions is implemented in BackgroundImpl.cpp.
     38  static ThreadLocal* GetThreadLocalForCurrentThread();
     39 
     40 protected:
     41  BackgroundChildImpl();
     42  virtual ~BackgroundChildImpl();
     43 
     44  virtual void ProcessingError(Result aCode, const char* aReason) override;
     45 
     46  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
     47 
     48  virtual PBackgroundTestChild* AllocPBackgroundTestChild(
     49      const nsACString& aTestArg) override;
     50 
     51  virtual bool DeallocPBackgroundTestChild(
     52      PBackgroundTestChild* aActor) override;
     53 
     54  virtual PBackgroundIndexedDBUtilsChild* AllocPBackgroundIndexedDBUtilsChild()
     55      override;
     56 
     57  virtual bool DeallocPBackgroundIndexedDBUtilsChild(
     58      PBackgroundIndexedDBUtilsChild* aActor) override;
     59 
     60  virtual PBackgroundLSObserverChild* AllocPBackgroundLSObserverChild(
     61      const uint64_t& aObserverId) override;
     62 
     63  virtual bool DeallocPBackgroundLSObserverChild(
     64      PBackgroundLSObserverChild* aActor) override;
     65 
     66  virtual PBackgroundLSRequestChild* AllocPBackgroundLSRequestChild(
     67      const LSRequestParams& aParams) override;
     68 
     69  virtual bool DeallocPBackgroundLSRequestChild(
     70      PBackgroundLSRequestChild* aActor) override;
     71 
     72  virtual PBackgroundLSSimpleRequestChild* AllocPBackgroundLSSimpleRequestChild(
     73      const LSSimpleRequestParams& aParams) override;
     74 
     75  virtual bool DeallocPBackgroundLSSimpleRequestChild(
     76      PBackgroundLSSimpleRequestChild* aActor) override;
     77 
     78  virtual PBackgroundLocalStorageCacheChild*
     79  AllocPBackgroundLocalStorageCacheChild(
     80      const PrincipalInfo& aPrincipalInfo, const nsACString& aOriginKey,
     81      const uint32_t& aPrivateBrowsingId) override;
     82 
     83  virtual bool DeallocPBackgroundLocalStorageCacheChild(
     84      PBackgroundLocalStorageCacheChild* aActor) override;
     85 
     86  virtual PBackgroundStorageChild* AllocPBackgroundStorageChild(
     87      const nsAString& aProfilePath,
     88      const uint32_t& aPrivateBrowsingId) override;
     89 
     90  virtual bool DeallocPBackgroundStorageChild(
     91      PBackgroundStorageChild* aActor) override;
     92 
     93  virtual PTemporaryIPCBlobChild* AllocPTemporaryIPCBlobChild() override;
     94 
     95  virtual bool DeallocPTemporaryIPCBlobChild(
     96      PTemporaryIPCBlobChild* aActor) override;
     97 
     98  virtual PFileCreatorChild* AllocPFileCreatorChild(
     99      const nsAString& aFullPath, const nsAString& aType,
    100      const nsAString& aName, const Maybe<int64_t>& aLastModified,
    101      const bool& aExistenceCheck, const bool& aIsFromNsIFile) override;
    102 
    103  virtual bool DeallocPFileCreatorChild(PFileCreatorChild* aActor) override;
    104 
    105  virtual mozilla::dom::PSharedWorkerChild* AllocPSharedWorkerChild(
    106      const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
    107      const mozilla::dom::MessagePortIdentifier& aPortIdentifier) override;
    108 
    109  virtual bool DeallocPSharedWorkerChild(
    110      mozilla::dom::PSharedWorkerChild* aActor) override;
    111 
    112  virtual PCamerasChild* AllocPCamerasChild() override;
    113 
    114  virtual bool DeallocPCamerasChild(PCamerasChild* aActor) override;
    115 
    116  virtual PUDPSocketChild* AllocPUDPSocketChild(
    117      const Maybe<PrincipalInfo>& aPrincipalInfo,
    118      const nsACString& aFilter) override;
    119  virtual bool DeallocPUDPSocketChild(PUDPSocketChild* aActor) override;
    120 
    121  virtual PBroadcastChannelChild* AllocPBroadcastChannelChild(
    122      const PrincipalInfo& aPrincipalInfo, const nsACString& aOrigin,
    123      const nsAString& aChannel) override;
    124 
    125  virtual bool DeallocPBroadcastChannelChild(
    126      PBroadcastChannelChild* aActor) override;
    127 
    128  virtual PCookieStoreChild* AllocPCookieStoreChild() override;
    129 
    130  virtual bool DeallocPCookieStoreChild(PCookieStoreChild* aActor) override;
    131 
    132  virtual PServiceWorkerManagerChild* AllocPServiceWorkerManagerChild()
    133      override;
    134 
    135  virtual bool DeallocPServiceWorkerManagerChild(
    136      PServiceWorkerManagerChild* aActor) override;
    137 
    138  virtual already_AddRefed<dom::cache::PCacheChild> AllocPCacheChild() override;
    139 
    140  virtual already_AddRefed<dom::cache::PCacheStreamControlChild>
    141  AllocPCacheStreamControlChild() override;
    142 
    143  virtual PMessagePortChild* AllocPMessagePortChild(
    144      const nsID& aUUID, const nsID& aDestinationUUID,
    145      const uint32_t& aSequenceID) override;
    146 
    147  virtual bool DeallocPMessagePortChild(PMessagePortChild* aActor) override;
    148 
    149  already_AddRefed<PServiceWorkerChild> AllocPServiceWorkerChild(
    150      const IPCServiceWorkerDescriptor&);
    151 
    152  already_AddRefed<PServiceWorkerContainerChild>
    153  AllocPServiceWorkerContainerChild();
    154 
    155  already_AddRefed<PServiceWorkerRegistrationChild>
    156  AllocPServiceWorkerRegistrationChild(
    157      const IPCServiceWorkerRegistrationDescriptor&);
    158 
    159  virtual PEndpointForReportChild* AllocPEndpointForReportChild(
    160      const nsAString& aGroupName,
    161      const PrincipalInfo& aPrincipalInfo) override;
    162 
    163  virtual bool DeallocPEndpointForReportChild(
    164      PEndpointForReportChild* aActor) override;
    165 };
    166 
    167 class BackgroundChildImpl::ThreadLocal final {
    168  friend mozilla::DefaultDelete<ThreadLocal>;
    169 
    170 public:
    171  mozilla::UniquePtr<mozilla::dom::indexedDB::ThreadLocal>
    172      mIndexedDBThreadLocal;
    173  mozilla::dom::IDBFileHandle* mCurrentFileHandle;
    174 
    175 public:
    176  ThreadLocal();
    177 
    178 private:
    179  // Only destroyed by UniquePtr<ThreadLocal>.
    180  ~ThreadLocal();
    181 };
    182 
    183 }  // namespace ipc
    184 }  // namespace mozilla
    185 
    186 #endif  // mozilla_ipc_backgroundchildimpl_h__