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_LOCKREQUESTCHILD_H_
8 #define DOM_LOCKS_LOCKREQUESTCHILD_H_
10 #include "LockManagerChild.h"
11 #include "mozilla/dom/locks/PLockRequestChild.h"
12 #include "mozilla/dom/Lock.h"
13 #include "mozilla/dom/WorkerRef.h"
14 #include "nsISupportsImpl.h"
16 namespace mozilla::dom::locks
{
20 RefPtr
<Promise
> mPromise
;
21 RefPtr
<LockGrantedCallback
> mCallback
;
24 class LockRequestChild final
: public PLockRequestChild
,
26 public SupportsWeakPtr
{
27 using IPCResult
= mozilla::ipc::IPCResult
;
32 explicit LockRequestChild(
33 const LockRequest
& aRequest
,
34 const Optional
<OwningNonNull
<AbortSignal
>>& aSignal
);
36 void MaybeSetWorkerRef();
38 // TODO: Use MOZ_CAN_RUN_SCRIPT when it gains IPDL support (bug 1539864)
39 MOZ_CAN_RUN_SCRIPT_BOUNDARY IPCResult
RecvResolve(const LockMode
& aLockMode
,
41 IPCResult
Recv__delete__(bool aAborted
);
43 void ActorDestroy(ActorDestroyReason aReason
) final
;
45 void RunAbortAlgorithm() final
;
48 ~LockRequestChild() = default;
50 LockManagerChild
* CastedManager() const;
52 const LockRequest mRequest
;
54 // This prevents the worker from being GC'ed when the caller is waiting to
55 // acquire the lock and when the lock is held.
57 // The StrongWorkerRef is dropped immediately in the shutdown notification
58 // callback, and thus does not ensure any cleanup before the worker advances
59 // to the Killing state. That is ensured instead by
60 // LockManagerChild::mWorkerRef, see also the details there.
61 RefPtr
<StrongWorkerRef
> mWorkerRef
;
64 } // namespace mozilla::dom::locks
66 #endif // DOM_LOCKS_LOCKREQUESTCHILD_H_