Bug 1704628 Part 4: Avoid use of ESC to close context menu in browser_toolbox_content...
[gecko.git] / dom / cache / CacheChild.h
blobcfad35a9ed766dfbc01ecb9eb16f5a61050357c6
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_CacheChild_h
8 #define mozilla_dom_cache_CacheChild_h
10 #include "mozilla/dom/cache/ActorChild.h"
11 #include "mozilla/dom/cache/PCacheChild.h"
13 class nsIAsyncInputStream;
14 class nsIGlobalObject;
16 namespace mozilla {
17 namespace dom {
19 class Promise;
21 namespace cache {
23 class Cache;
24 class CacheOpArgs;
26 class CacheChild final : public PCacheChild, public ActorChild {
27 friend class PCacheChild;
29 public:
30 friend class mozilla::detail::BaseAutoLock<CacheChild&>;
31 using AutoLock = mozilla::detail::BaseAutoLock<CacheChild&>;
33 CacheChild();
34 ~CacheChild();
36 void SetListener(Cache* aListener);
38 // Must be called by the associated Cache listener in its DestroyInternal()
39 // method. Also, Cache must call StartDestroyFromListener() on the actor in
40 // its destructor to trigger ActorDestroy() if it has not been called yet.
41 void ClearListener();
43 void ExecuteOp(nsIGlobalObject* aGlobal, Promise* aPromise,
44 nsISupports* aParent, const CacheOpArgs& aArgs);
46 // Our parent Listener object has gone out of scope and is being destroyed.
47 void StartDestroyFromListener();
49 private:
50 // ActorChild methods
52 // WorkerRef is trying to destroy due to worker shutdown.
53 virtual void StartDestroy() override;
55 // PCacheChild methods
56 virtual void ActorDestroy(ActorDestroyReason aReason) override;
58 PCacheOpChild* AllocPCacheOpChild(const CacheOpArgs& aOpArgs);
60 bool DeallocPCacheOpChild(PCacheOpChild* aActor);
62 // utility methods
63 void NoteDeletedActor();
65 void MaybeFlushDelayedDestroy();
67 // Methods used to temporarily force the actor alive. Only called from
68 // AutoLock.
69 void Lock();
71 void Unlock();
73 // Use a weak ref so actor does not hold DOM object alive past content use.
74 // The Cache object must call ClearListener() to null this before its
75 // destroyed.
76 Cache* MOZ_NON_OWNING_REF mListener;
77 uint32_t mNumChildActors;
78 bool mDelayedDestroy;
79 bool mLocked;
81 NS_DECL_OWNINGTHREAD
84 } // namespace cache
85 } // namespace dom
86 } // namespace mozilla
88 #endif // mozilla_dom_cache_CacheChild_h