Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / locks / LockManagerChild.h
blob79ae8390e3883aed026eaa011494f28da0553d2a
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 DOM_LOCKS_LOCKMANAGERCHILD_H_
8 #define DOM_LOCKS_LOCKMANAGERCHILD_H_
10 #include "mozilla/dom/locks/PLockManagerChild.h"
11 #include "mozilla/dom/Promise.h"
12 #include "mozilla/dom/WorkerRef.h"
13 #include "nsIUUIDGenerator.h"
15 namespace mozilla::dom::locks {
17 struct LockRequest;
19 class LockManagerChild final : public PLockManagerChild {
20 public:
21 NS_INLINE_DECL_REFCOUNTING(LockManagerChild)
23 static void NotifyBFCacheOnMainThread(nsPIDOMWindowInner* aInner,
24 bool aCreated);
26 explicit LockManagerChild(nsIGlobalObject* aOwner);
28 nsIGlobalObject* GetParentObject() const { return mOwner; };
30 void RequestLock(const LockRequest& aRequest, const LockOptions& aOptions);
32 void NotifyRequestDestroy() const;
34 void NotifyToWindow(bool aCreated) const;
36 private:
37 ~LockManagerChild() = default;
39 nsCOMPtr<nsIGlobalObject> mOwner;
41 // This WorkerRef is deleted by destructor.
43 // Here we want to make sure the IPC layer deletes the actor before allowing
44 // WorkerPrivate deletion, since managed LockRequestChild holds a reference to
45 // global object (currently via mRequest member variable) and thus deleting
46 // the worker first causes an assertion failure. Having this ensures that all
47 // LockRequestChild instances must first have been deleted.
49 // (Because each LockRequestChild's ActorLifecycleProxy will hold
50 // a strong reference to its manager LockManagerChild's ActorLifecycleProxy,
51 // which means that the LockManagerChild will only be destroyed once all
52 // LockRequestChild instances have been destroyed. At that point, all
53 // references to the global should have been dropped, and then the
54 // LockManagerChild IPCWorkerRef will be dropped and the worker will be able
55 // to transition to the Killing state.)
57 // ActorDestroy can't release this since it does not guarantee to destruct and
58 // GC the managees (LockRequestChild) immediately.
59 RefPtr<IPCWorkerRef> mWorkerRef;
62 } // namespace mozilla::dom::locks
64 #endif // DOM_LOCKS_LOCKMANAGERCHILD_H_