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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_cache_CacheStorageChild_h
8 #define mozilla_dom_cache_CacheStorageChild_h
10 #include "mozilla/dom/cache/ActorChild.h"
11 #include "mozilla/dom/cache/Types.h"
12 #include "mozilla/dom/cache/PCacheStorageChild.h"
14 class nsIGlobalObject
;
16 namespace mozilla::dom
{
27 class CacheStorageChild final
: public PCacheStorageChild
, public ActorChild
{
28 friend class PCacheStorageChild
;
31 CacheStorageChild(CacheStorage
* aListener
,
32 SafeRefPtr
<CacheWorkerRef
> aWorkerRef
);
34 // Must be called by the associated CacheStorage listener in its
35 // DestroyInternal() method. Also, CacheStorage must call
36 // SendDestroyFromListener() on the actor in its destructor to trigger
37 // ActorDestroy() if it has not been called yet.
40 void ExecuteOp(nsIGlobalObject
* aGlobal
, Promise
* aPromise
,
41 nsISupports
* aParent
, const CacheOpArgs
& aArgs
);
43 // Our parent Listener object has gone out of scope and is being destroyed.
44 void StartDestroyFromListener();
46 NS_INLINE_DECL_REFCOUNTING(CacheStorageChild
, override
)
47 void NoteDeletedActor() override
;
52 void DestroyInternal();
55 // CacheWorkerRef is trying to destroy due to worker shutdown.
56 virtual void StartDestroy() override
;
58 // PCacheStorageChild methods
59 virtual void ActorDestroy(ActorDestroyReason aReason
) override
;
61 PCacheOpChild
* AllocPCacheOpChild(const CacheOpArgs
& aOpArgs
);
63 bool DeallocPCacheOpChild(PCacheOpChild
* aActor
);
66 inline uint32_t NumChildActors() { return ManagedPCacheOpChild().Count(); }
68 // Use a weak ref so actor does not hold DOM object alive past content use.
69 // The CacheStorage object must call ClearListener() to null this before its
71 CacheStorage
* MOZ_NON_OWNING_REF mListener
;
76 } // namespace mozilla::dom
78 #endif // mozilla_dom_cache_CacheStorageChild_h