Bug 1700051: part 31.4) Move `mSoftTextValid` to `SoftText`. r=smaug
[gecko.git] / ipc / glue / BackgroundChildImpl.h
blob22e740e55c99f55c9f8a62b27d018f9a9afc035d
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/Attributes.h"
11 #include "mozilla/ipc/InputStreamUtils.h"
12 #include "mozilla/ipc/PBackgroundChild.h"
13 #include "mozilla/UniquePtr.h"
14 #include "nsRefPtrHashtable.h"
16 namespace mozilla {
17 namespace dom {
19 class IDBFileHandle;
21 namespace indexedDB {
23 class ThreadLocal;
25 } // namespace indexedDB
26 } // namespace dom
28 namespace ipc {
30 // Instances of this class should never be created directly. This class is meant
31 // to be inherited in BackgroundImpl.
32 class BackgroundChildImpl : public PBackgroundChild,
33 public ChildToParentStreamActorManager {
34 public:
35 class ThreadLocal;
37 // Get the ThreadLocal for the current thread if
38 // BackgroundChild::GetOrCreateForCurrentThread() has been called and true was
39 // returned (e.g. a valid PBackgroundChild actor has been created or is in the
40 // process of being created). Otherwise this function returns null.
41 // This functions is implemented in BackgroundImpl.cpp.
42 static ThreadLocal* GetThreadLocalForCurrentThread();
44 PChildToParentStreamChild* SendPChildToParentStreamConstructor(
45 PChildToParentStreamChild* aActor) override;
46 PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
47 const FileDescriptor& aFD) override;
49 protected:
50 BackgroundChildImpl();
51 virtual ~BackgroundChildImpl();
53 virtual void ProcessingError(Result aCode, const char* aReason) override;
55 virtual void ActorDestroy(ActorDestroyReason aWhy) override;
57 virtual PBackgroundTestChild* AllocPBackgroundTestChild(
58 const nsCString& aTestArg) override;
60 virtual bool DeallocPBackgroundTestChild(
61 PBackgroundTestChild* aActor) override;
63 virtual PBackgroundIndexedDBUtilsChild* AllocPBackgroundIndexedDBUtilsChild()
64 override;
66 virtual bool DeallocPBackgroundIndexedDBUtilsChild(
67 PBackgroundIndexedDBUtilsChild* aActor) override;
69 virtual PBackgroundSDBConnectionChild* AllocPBackgroundSDBConnectionChild(
70 const PersistenceType& aPersistenceType,
71 const PrincipalInfo& aPrincipalInfo) override;
73 virtual bool DeallocPBackgroundSDBConnectionChild(
74 PBackgroundSDBConnectionChild* aActor) override;
76 virtual PBackgroundLSDatabaseChild* AllocPBackgroundLSDatabaseChild(
77 const PrincipalInfo& aPrincipalInfo, const uint32_t& aPrivateBrowsingId,
78 const uint64_t& aDatastoreId) override;
80 virtual bool DeallocPBackgroundLSDatabaseChild(
81 PBackgroundLSDatabaseChild* aActor) override;
83 virtual PBackgroundLSObserverChild* AllocPBackgroundLSObserverChild(
84 const uint64_t& aObserverId) override;
86 virtual bool DeallocPBackgroundLSObserverChild(
87 PBackgroundLSObserverChild* aActor) override;
89 virtual PBackgroundLSRequestChild* AllocPBackgroundLSRequestChild(
90 const LSRequestParams& aParams) override;
92 virtual bool DeallocPBackgroundLSRequestChild(
93 PBackgroundLSRequestChild* aActor) override;
95 virtual PBackgroundLSSimpleRequestChild* AllocPBackgroundLSSimpleRequestChild(
96 const LSSimpleRequestParams& aParams) override;
98 virtual bool DeallocPBackgroundLSSimpleRequestChild(
99 PBackgroundLSSimpleRequestChild* aActor) override;
101 virtual PBackgroundLocalStorageCacheChild*
102 AllocPBackgroundLocalStorageCacheChild(
103 const PrincipalInfo& aPrincipalInfo, const nsCString& aOriginKey,
104 const uint32_t& aPrivateBrowsingId) override;
106 virtual bool DeallocPBackgroundLocalStorageCacheChild(
107 PBackgroundLocalStorageCacheChild* aActor) override;
109 virtual PBackgroundStorageChild* AllocPBackgroundStorageChild(
110 const nsString& aProfilePath,
111 const uint32_t& aPrivateBrowsingId) override;
113 virtual bool DeallocPBackgroundStorageChild(
114 PBackgroundStorageChild* aActor) override;
116 virtual already_AddRefed<PRemoteLazyInputStreamChild>
117 AllocPRemoteLazyInputStreamChild(const nsID& aID,
118 const uint64_t& aSize) override;
120 virtual PTemporaryIPCBlobChild* AllocPTemporaryIPCBlobChild() override;
122 virtual bool DeallocPTemporaryIPCBlobChild(
123 PTemporaryIPCBlobChild* aActor) override;
125 virtual PFileCreatorChild* AllocPFileCreatorChild(
126 const nsString& aFullPath, const nsString& aType, const nsString& aName,
127 const Maybe<int64_t>& aLastModified, const bool& aExistenceCheck,
128 const bool& aIsFromNsIFile) override;
130 virtual bool DeallocPFileCreatorChild(PFileCreatorChild* aActor) override;
132 virtual mozilla::dom::PRemoteWorkerChild* AllocPRemoteWorkerChild(
133 const RemoteWorkerData& aData) override;
135 virtual mozilla::ipc::IPCResult RecvPRemoteWorkerConstructor(
136 PRemoteWorkerChild* aActor, const RemoteWorkerData& aData) override;
138 virtual bool DeallocPRemoteWorkerChild(
139 mozilla::dom::PRemoteWorkerChild* aActor) override;
141 virtual mozilla::dom::PRemoteWorkerControllerChild*
142 AllocPRemoteWorkerControllerChild(
143 const mozilla::dom::RemoteWorkerData& aRemoteWorkerData) override;
145 virtual bool DeallocPRemoteWorkerControllerChild(
146 mozilla::dom::PRemoteWorkerControllerChild* aActor) override;
148 virtual mozilla::dom::PRemoteWorkerServiceChild*
149 AllocPRemoteWorkerServiceChild() override;
151 virtual bool DeallocPRemoteWorkerServiceChild(
152 mozilla::dom::PRemoteWorkerServiceChild* aActor) override;
154 virtual mozilla::dom::PSharedWorkerChild* AllocPSharedWorkerChild(
155 const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
156 const mozilla::dom::MessagePortIdentifier& aPortIdentifier) override;
158 virtual bool DeallocPSharedWorkerChild(
159 mozilla::dom::PSharedWorkerChild* aActor) override;
161 virtual PFileDescriptorSetChild* AllocPFileDescriptorSetChild(
162 const FileDescriptor& aFileDescriptor) override;
164 virtual bool DeallocPFileDescriptorSetChild(
165 PFileDescriptorSetChild* aActor) override;
167 virtual PCamerasChild* AllocPCamerasChild() override;
169 virtual bool DeallocPCamerasChild(PCamerasChild* aActor) override;
171 virtual PVsyncChild* AllocPVsyncChild() override;
173 virtual bool DeallocPVsyncChild(PVsyncChild* aActor) override;
175 virtual PUDPSocketChild* AllocPUDPSocketChild(
176 const Maybe<PrincipalInfo>& aPrincipalInfo,
177 const nsCString& aFilter) override;
178 virtual bool DeallocPUDPSocketChild(PUDPSocketChild* aActor) override;
180 virtual PBroadcastChannelChild* AllocPBroadcastChannelChild(
181 const PrincipalInfo& aPrincipalInfo, const nsCString& aOrigin,
182 const nsString& aChannel) override;
184 virtual bool DeallocPBroadcastChannelChild(
185 PBroadcastChannelChild* aActor) override;
187 virtual PServiceWorkerManagerChild* AllocPServiceWorkerManagerChild()
188 override;
190 virtual bool DeallocPServiceWorkerManagerChild(
191 PServiceWorkerManagerChild* aActor) override;
193 virtual dom::cache::PCacheStorageChild* AllocPCacheStorageChild(
194 const dom::cache::Namespace& aNamespace,
195 const PrincipalInfo& aPrincipalInfo) override;
197 virtual bool DeallocPCacheStorageChild(
198 dom::cache::PCacheStorageChild* aActor) override;
200 virtual dom::cache::PCacheChild* AllocPCacheChild() override;
202 virtual bool DeallocPCacheChild(dom::cache::PCacheChild* aActor) override;
204 virtual already_AddRefed<dom::cache::PCacheStreamControlChild>
205 AllocPCacheStreamControlChild() override;
207 virtual PMessagePortChild* AllocPMessagePortChild(
208 const nsID& aUUID, const nsID& aDestinationUUID,
209 const uint32_t& aSequenceID) override;
211 virtual bool DeallocPMessagePortChild(PMessagePortChild* aActor) override;
213 virtual PChildToParentStreamChild* AllocPChildToParentStreamChild() override;
215 virtual bool DeallocPChildToParentStreamChild(
216 PChildToParentStreamChild* aActor) override;
218 virtual PParentToChildStreamChild* AllocPParentToChildStreamChild() override;
220 virtual bool DeallocPParentToChildStreamChild(
221 PParentToChildStreamChild* aActor) override;
223 virtual PQuotaChild* AllocPQuotaChild() override;
225 virtual bool DeallocPQuotaChild(PQuotaChild* aActor) override;
227 virtual PClientManagerChild* AllocPClientManagerChild() override;
229 virtual bool DeallocPClientManagerChild(PClientManagerChild* aActor) override;
231 #ifdef EARLY_BETA_OR_EARLIER
232 virtual void OnChannelReceivedMessage(const Message& aMsg) override;
233 #endif
235 virtual PWebAuthnTransactionChild* AllocPWebAuthnTransactionChild() override;
237 virtual bool DeallocPWebAuthnTransactionChild(
238 PWebAuthnTransactionChild* aActor) override;
240 virtual PMIDIPortChild* AllocPMIDIPortChild(
241 const MIDIPortInfo& aPortInfo, const bool& aSysexEnabled) override;
242 virtual bool DeallocPMIDIPortChild(PMIDIPortChild*) override;
244 virtual PMIDIManagerChild* AllocPMIDIManagerChild() override;
245 virtual bool DeallocPMIDIManagerChild(PMIDIManagerChild*) override;
247 already_AddRefed<PServiceWorkerChild> AllocPServiceWorkerChild(
248 const IPCServiceWorkerDescriptor&);
250 already_AddRefed<PServiceWorkerContainerChild>
251 AllocPServiceWorkerContainerChild();
253 already_AddRefed<PServiceWorkerRegistrationChild>
254 AllocPServiceWorkerRegistrationChild(
255 const IPCServiceWorkerRegistrationDescriptor&);
257 virtual PEndpointForReportChild* AllocPEndpointForReportChild(
258 const nsString& aGroupName, const PrincipalInfo& aPrincipalInfo) override;
260 virtual bool DeallocPEndpointForReportChild(
261 PEndpointForReportChild* aActor) override;
263 virtual dom::PMediaTransportChild* AllocPMediaTransportChild() override;
265 virtual bool DeallocPMediaTransportChild(
266 dom::PMediaTransportChild* aActor) override;
269 class BackgroundChildImpl::ThreadLocal final {
270 friend class mozilla::DefaultDelete<ThreadLocal>;
272 public:
273 mozilla::UniquePtr<mozilla::dom::indexedDB::ThreadLocal>
274 mIndexedDBThreadLocal;
275 mozilla::dom::IDBFileHandle* mCurrentFileHandle;
277 public:
278 ThreadLocal();
280 private:
281 // Only destroyed by UniquePtr<ThreadLocal>.
282 ~ThreadLocal();
285 } // namespace ipc
286 } // namespace mozilla
288 #endif // mozilla_ipc_backgroundchildimpl_h__