Backed out 2 changesets (bug 1539720) for causing caret related failures. CLOSED...
[gecko.git] / dom / cache / CacheStorageChild.h
blob3e653b7812ebec7118512f3b4500a2a5ddd69a56
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 {
18 class Promise;
20 namespace cache {
22 class CacheOpArgs;
23 class CacheStorage;
24 class CacheWorkerRef;
25 class PCacheChild;
27 class CacheStorageChild final : public PCacheStorageChild, public ActorChild {
28 friend class PCacheStorageChild;
30 public:
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.
38 void ClearListener();
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;
49 private:
50 ~CacheStorageChild();
52 void DestroyInternal();
54 // ActorChild methods
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);
65 // utility methods
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
70 // destroyed.
71 CacheStorage* MOZ_NON_OWNING_REF mListener;
72 bool mDelayedDestroy;
75 } // namespace cache
76 } // namespace mozilla::dom
78 #endif // mozilla_dom_cache_CacheStorageChild_h