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"
22 } // namespace indexedDB
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
{
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();
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()
57 virtual bool DeallocPBackgroundIndexedDBUtilsChild(
58 PBackgroundIndexedDBUtilsChild
* aActor
) override
;
60 virtual PBackgroundLSObserverChild
* AllocPBackgroundLSObserverChild(
61 const uint64_t& aObserverId
) override
;
63 virtual bool DeallocPBackgroundLSObserverChild(
64 PBackgroundLSObserverChild
* aActor
) override
;
66 virtual PBackgroundLSRequestChild
* AllocPBackgroundLSRequestChild(
67 const LSRequestParams
& aParams
) override
;
69 virtual bool DeallocPBackgroundLSRequestChild(
70 PBackgroundLSRequestChild
* aActor
) override
;
72 virtual PBackgroundLSSimpleRequestChild
* AllocPBackgroundLSSimpleRequestChild(
73 const LSSimpleRequestParams
& aParams
) override
;
75 virtual bool DeallocPBackgroundLSSimpleRequestChild(
76 PBackgroundLSSimpleRequestChild
* aActor
) override
;
78 virtual PBackgroundLocalStorageCacheChild
*
79 AllocPBackgroundLocalStorageCacheChild(
80 const PrincipalInfo
& aPrincipalInfo
, const nsACString
& aOriginKey
,
81 const uint32_t& aPrivateBrowsingId
) override
;
83 virtual bool DeallocPBackgroundLocalStorageCacheChild(
84 PBackgroundLocalStorageCacheChild
* aActor
) override
;
86 virtual PBackgroundStorageChild
* AllocPBackgroundStorageChild(
87 const nsAString
& aProfilePath
,
88 const uint32_t& aPrivateBrowsingId
) override
;
90 virtual bool DeallocPBackgroundStorageChild(
91 PBackgroundStorageChild
* aActor
) override
;
93 virtual PTemporaryIPCBlobChild
* AllocPTemporaryIPCBlobChild() override
;
95 virtual bool DeallocPTemporaryIPCBlobChild(
96 PTemporaryIPCBlobChild
* aActor
) override
;
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
;
103 virtual bool DeallocPFileCreatorChild(PFileCreatorChild
* aActor
) override
;
105 already_AddRefed
<mozilla::dom::PRemoteWorkerChild
> AllocPRemoteWorkerChild(
106 const RemoteWorkerData
& aData
) override
;
108 virtual mozilla::ipc::IPCResult
RecvPRemoteWorkerConstructor(
109 PRemoteWorkerChild
* aActor
, const RemoteWorkerData
& aData
) override
;
111 virtual mozilla::dom::PSharedWorkerChild
* AllocPSharedWorkerChild(
112 const mozilla::dom::RemoteWorkerData
& aData
, const uint64_t& aWindowID
,
113 const mozilla::dom::MessagePortIdentifier
& aPortIdentifier
) override
;
115 virtual bool DeallocPSharedWorkerChild(
116 mozilla::dom::PSharedWorkerChild
* aActor
) override
;
118 virtual PCamerasChild
* AllocPCamerasChild() override
;
120 virtual bool DeallocPCamerasChild(PCamerasChild
* aActor
) override
;
122 virtual PUDPSocketChild
* AllocPUDPSocketChild(
123 const Maybe
<PrincipalInfo
>& aPrincipalInfo
,
124 const nsACString
& aFilter
) override
;
125 virtual bool DeallocPUDPSocketChild(PUDPSocketChild
* aActor
) override
;
127 virtual PBroadcastChannelChild
* AllocPBroadcastChannelChild(
128 const PrincipalInfo
& aPrincipalInfo
, const nsACString
& aOrigin
,
129 const nsAString
& aChannel
) override
;
131 virtual bool DeallocPBroadcastChannelChild(
132 PBroadcastChannelChild
* aActor
) override
;
134 virtual PServiceWorkerManagerChild
* AllocPServiceWorkerManagerChild()
137 virtual bool DeallocPServiceWorkerManagerChild(
138 PServiceWorkerManagerChild
* aActor
) override
;
140 virtual already_AddRefed
<dom::cache::PCacheChild
> AllocPCacheChild() override
;
142 virtual already_AddRefed
<dom::cache::PCacheStreamControlChild
>
143 AllocPCacheStreamControlChild() override
;
145 virtual PMessagePortChild
* AllocPMessagePortChild(
146 const nsID
& aUUID
, const nsID
& aDestinationUUID
,
147 const uint32_t& aSequenceID
) override
;
149 virtual bool DeallocPMessagePortChild(PMessagePortChild
* aActor
) override
;
151 virtual PWebAuthnTransactionChild
* AllocPWebAuthnTransactionChild() override
;
153 virtual bool DeallocPWebAuthnTransactionChild(
154 PWebAuthnTransactionChild
* aActor
) override
;
156 already_AddRefed
<PServiceWorkerChild
> AllocPServiceWorkerChild(
157 const IPCServiceWorkerDescriptor
&);
159 already_AddRefed
<PServiceWorkerContainerChild
>
160 AllocPServiceWorkerContainerChild();
162 already_AddRefed
<PServiceWorkerRegistrationChild
>
163 AllocPServiceWorkerRegistrationChild(
164 const IPCServiceWorkerRegistrationDescriptor
&);
166 virtual PEndpointForReportChild
* AllocPEndpointForReportChild(
167 const nsAString
& aGroupName
,
168 const PrincipalInfo
& aPrincipalInfo
) override
;
170 virtual bool DeallocPEndpointForReportChild(
171 PEndpointForReportChild
* aActor
) override
;
174 class BackgroundChildImpl::ThreadLocal final
{
175 friend class mozilla::DefaultDelete
<ThreadLocal
>;
178 mozilla::UniquePtr
<mozilla::dom::indexedDB::ThreadLocal
>
179 mIndexedDBThreadLocal
;
180 mozilla::dom::IDBFileHandle
* mCurrentFileHandle
;
186 // Only destroyed by UniquePtr<ThreadLocal>.
191 } // namespace mozilla
193 #endif // mozilla_ipc_backgroundchildimpl_h__