Bug 1858509 add thread-safety annotations around MediaSourceDemuxer::mMonitor r=alwu
[gecko.git] / ipc / glue / BackgroundChildImpl.h
blob1c17e141c3bd93bd5f5a9c92830217735b43eefb
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/. */
7 #ifndef mozilla_ipc_backgroundchildimpl_h__
8 #define mozilla_ipc_backgroundchildimpl_h__
10 #include "mozilla/ipc/PBackgroundChild.h"
11 #include "mozilla/UniquePtr.h"
13 namespace mozilla {
14 namespace dom {
16 class IDBFileHandle;
18 namespace indexedDB {
20 class ThreadLocal;
22 } // namespace indexedDB
23 } // namespace dom
25 namespace ipc {
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;
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();
40 protected:
41 BackgroundChildImpl();
42 virtual ~BackgroundChildImpl();
44 virtual void ProcessingError(Result aCode, const char* aReason) override;
46 virtual void ActorDestroy(ActorDestroyReason aWhy) override;
48 virtual PBackgroundTestChild* AllocPBackgroundTestChild(
49 const nsACString& aTestArg) override;
51 virtual bool DeallocPBackgroundTestChild(
52 PBackgroundTestChild* aActor) override;
54 virtual PBackgroundIndexedDBUtilsChild* AllocPBackgroundIndexedDBUtilsChild()
55 override;
57 virtual bool DeallocPBackgroundIndexedDBUtilsChild(
58 PBackgroundIndexedDBUtilsChild* aActor) override;
60 virtual PBackgroundSDBConnectionChild* AllocPBackgroundSDBConnectionChild(
61 const PersistenceType& aPersistenceType,
62 const PrincipalInfo& aPrincipalInfo) override;
64 virtual bool DeallocPBackgroundSDBConnectionChild(
65 PBackgroundSDBConnectionChild* aActor) override;
67 virtual PBackgroundLSDatabaseChild* AllocPBackgroundLSDatabaseChild(
68 const PrincipalInfo& aPrincipalInfo, const uint32_t& aPrivateBrowsingId,
69 const uint64_t& aDatastoreId) override;
71 virtual bool DeallocPBackgroundLSDatabaseChild(
72 PBackgroundLSDatabaseChild* aActor) override;
74 virtual PBackgroundLSObserverChild* AllocPBackgroundLSObserverChild(
75 const uint64_t& aObserverId) override;
77 virtual bool DeallocPBackgroundLSObserverChild(
78 PBackgroundLSObserverChild* aActor) override;
80 virtual PBackgroundLSRequestChild* AllocPBackgroundLSRequestChild(
81 const LSRequestParams& aParams) override;
83 virtual bool DeallocPBackgroundLSRequestChild(
84 PBackgroundLSRequestChild* aActor) override;
86 virtual PBackgroundLSSimpleRequestChild* AllocPBackgroundLSSimpleRequestChild(
87 const LSSimpleRequestParams& aParams) override;
89 virtual bool DeallocPBackgroundLSSimpleRequestChild(
90 PBackgroundLSSimpleRequestChild* aActor) override;
92 virtual PBackgroundLocalStorageCacheChild*
93 AllocPBackgroundLocalStorageCacheChild(
94 const PrincipalInfo& aPrincipalInfo, const nsACString& aOriginKey,
95 const uint32_t& aPrivateBrowsingId) override;
97 virtual bool DeallocPBackgroundLocalStorageCacheChild(
98 PBackgroundLocalStorageCacheChild* aActor) override;
100 virtual PBackgroundStorageChild* AllocPBackgroundStorageChild(
101 const nsAString& aProfilePath,
102 const uint32_t& aPrivateBrowsingId) override;
104 virtual bool DeallocPBackgroundStorageChild(
105 PBackgroundStorageChild* aActor) override;
107 virtual PTemporaryIPCBlobChild* AllocPTemporaryIPCBlobChild() override;
109 virtual bool DeallocPTemporaryIPCBlobChild(
110 PTemporaryIPCBlobChild* aActor) override;
112 virtual PFileCreatorChild* AllocPFileCreatorChild(
113 const nsAString& aFullPath, const nsAString& aType,
114 const nsAString& aName, const Maybe<int64_t>& aLastModified,
115 const bool& aExistenceCheck, const bool& aIsFromNsIFile) override;
117 virtual bool DeallocPFileCreatorChild(PFileCreatorChild* aActor) override;
119 already_AddRefed<mozilla::dom::PRemoteWorkerChild> AllocPRemoteWorkerChild(
120 const RemoteWorkerData& aData) override;
122 virtual mozilla::ipc::IPCResult RecvPRemoteWorkerConstructor(
123 PRemoteWorkerChild* aActor, const RemoteWorkerData& aData) override;
125 virtual mozilla::dom::PRemoteWorkerControllerChild*
126 AllocPRemoteWorkerControllerChild(
127 const mozilla::dom::RemoteWorkerData& aRemoteWorkerData) override;
129 virtual bool DeallocPRemoteWorkerControllerChild(
130 mozilla::dom::PRemoteWorkerControllerChild* aActor) override;
132 virtual mozilla::dom::PSharedWorkerChild* AllocPSharedWorkerChild(
133 const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
134 const mozilla::dom::MessagePortIdentifier& aPortIdentifier) override;
136 virtual bool DeallocPSharedWorkerChild(
137 mozilla::dom::PSharedWorkerChild* aActor) override;
139 virtual PCamerasChild* AllocPCamerasChild() override;
141 virtual bool DeallocPCamerasChild(PCamerasChild* aActor) override;
143 virtual PUDPSocketChild* AllocPUDPSocketChild(
144 const Maybe<PrincipalInfo>& aPrincipalInfo,
145 const nsACString& aFilter) override;
146 virtual bool DeallocPUDPSocketChild(PUDPSocketChild* aActor) override;
148 virtual PBroadcastChannelChild* AllocPBroadcastChannelChild(
149 const PrincipalInfo& aPrincipalInfo, const nsACString& aOrigin,
150 const nsAString& aChannel) override;
152 virtual bool DeallocPBroadcastChannelChild(
153 PBroadcastChannelChild* aActor) override;
155 virtual PServiceWorkerManagerChild* AllocPServiceWorkerManagerChild()
156 override;
158 virtual bool DeallocPServiceWorkerManagerChild(
159 PServiceWorkerManagerChild* aActor) override;
161 virtual already_AddRefed<dom::cache::PCacheChild> AllocPCacheChild() override;
163 virtual already_AddRefed<dom::cache::PCacheStreamControlChild>
164 AllocPCacheStreamControlChild() override;
166 virtual PMessagePortChild* AllocPMessagePortChild(
167 const nsID& aUUID, const nsID& aDestinationUUID,
168 const uint32_t& aSequenceID) override;
170 virtual bool DeallocPMessagePortChild(PMessagePortChild* aActor) override;
172 virtual PQuotaChild* AllocPQuotaChild() override;
174 virtual bool DeallocPQuotaChild(PQuotaChild* aActor) override;
176 virtual PClientManagerChild* AllocPClientManagerChild() override;
178 virtual bool DeallocPClientManagerChild(PClientManagerChild* aActor) override;
180 virtual PWebAuthnTransactionChild* AllocPWebAuthnTransactionChild() override;
182 virtual bool DeallocPWebAuthnTransactionChild(
183 PWebAuthnTransactionChild* aActor) override;
185 already_AddRefed<PServiceWorkerChild> AllocPServiceWorkerChild(
186 const IPCServiceWorkerDescriptor&);
188 already_AddRefed<PServiceWorkerContainerChild>
189 AllocPServiceWorkerContainerChild();
191 already_AddRefed<PServiceWorkerRegistrationChild>
192 AllocPServiceWorkerRegistrationChild(
193 const IPCServiceWorkerRegistrationDescriptor&);
195 virtual PEndpointForReportChild* AllocPEndpointForReportChild(
196 const nsAString& aGroupName,
197 const PrincipalInfo& aPrincipalInfo) override;
199 virtual bool DeallocPEndpointForReportChild(
200 PEndpointForReportChild* aActor) override;
203 class BackgroundChildImpl::ThreadLocal final {
204 friend class mozilla::DefaultDelete<ThreadLocal>;
206 public:
207 mozilla::UniquePtr<mozilla::dom::indexedDB::ThreadLocal>
208 mIndexedDBThreadLocal;
209 mozilla::dom::IDBFileHandle* mCurrentFileHandle;
211 public:
212 ThreadLocal();
214 private:
215 // Only destroyed by UniquePtr<ThreadLocal>.
216 ~ThreadLocal();
219 } // namespace ipc
220 } // namespace mozilla
222 #endif // mozilla_ipc_backgroundchildimpl_h__