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 virtual mozilla::dom::PSharedWorkerChild
* AllocPSharedWorkerChild(
106 const mozilla::dom::RemoteWorkerData
& aData
, const uint64_t& aWindowID
,
107 const mozilla::dom::MessagePortIdentifier
& aPortIdentifier
) override
;
109 virtual bool DeallocPSharedWorkerChild(
110 mozilla::dom::PSharedWorkerChild
* aActor
) override
;
112 virtual PCamerasChild
* AllocPCamerasChild() override
;
114 virtual bool DeallocPCamerasChild(PCamerasChild
* aActor
) override
;
116 virtual PUDPSocketChild
* AllocPUDPSocketChild(
117 const Maybe
<PrincipalInfo
>& aPrincipalInfo
,
118 const nsACString
& aFilter
) override
;
119 virtual bool DeallocPUDPSocketChild(PUDPSocketChild
* aActor
) override
;
121 virtual PBroadcastChannelChild
* AllocPBroadcastChannelChild(
122 const PrincipalInfo
& aPrincipalInfo
, const nsACString
& aOrigin
,
123 const nsAString
& aChannel
) override
;
125 virtual bool DeallocPBroadcastChannelChild(
126 PBroadcastChannelChild
* aActor
) override
;
128 virtual PCookieStoreChild
* AllocPCookieStoreChild() override
;
130 virtual bool DeallocPCookieStoreChild(PCookieStoreChild
* aActor
) override
;
132 virtual PServiceWorkerManagerChild
* AllocPServiceWorkerManagerChild()
135 virtual bool DeallocPServiceWorkerManagerChild(
136 PServiceWorkerManagerChild
* aActor
) override
;
138 virtual already_AddRefed
<dom::cache::PCacheChild
> AllocPCacheChild() override
;
140 virtual already_AddRefed
<dom::cache::PCacheStreamControlChild
>
141 AllocPCacheStreamControlChild() override
;
143 virtual PMessagePortChild
* AllocPMessagePortChild(
144 const nsID
& aUUID
, const nsID
& aDestinationUUID
,
145 const uint32_t& aSequenceID
) override
;
147 virtual bool DeallocPMessagePortChild(PMessagePortChild
* aActor
) override
;
149 virtual PWebAuthnTransactionChild
* AllocPWebAuthnTransactionChild() override
;
151 virtual bool DeallocPWebAuthnTransactionChild(
152 PWebAuthnTransactionChild
* aActor
) override
;
154 already_AddRefed
<PServiceWorkerChild
> AllocPServiceWorkerChild(
155 const IPCServiceWorkerDescriptor
&);
157 already_AddRefed
<PServiceWorkerContainerChild
>
158 AllocPServiceWorkerContainerChild();
160 already_AddRefed
<PServiceWorkerRegistrationChild
>
161 AllocPServiceWorkerRegistrationChild(
162 const IPCServiceWorkerRegistrationDescriptor
&);
164 virtual PEndpointForReportChild
* AllocPEndpointForReportChild(
165 const nsAString
& aGroupName
,
166 const PrincipalInfo
& aPrincipalInfo
) override
;
168 virtual bool DeallocPEndpointForReportChild(
169 PEndpointForReportChild
* aActor
) override
;
172 class BackgroundChildImpl::ThreadLocal final
{
173 friend class mozilla::DefaultDelete
<ThreadLocal
>;
176 mozilla::UniquePtr
<mozilla::dom::indexedDB::ThreadLocal
>
177 mIndexedDBThreadLocal
;
178 mozilla::dom::IDBFileHandle
* mCurrentFileHandle
;
184 // Only destroyed by UniquePtr<ThreadLocal>.
189 } // namespace mozilla
191 #endif // mozilla_ipc_backgroundchildimpl_h__