1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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_LockManager_h
8 #define mozilla_dom_LockManager_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/ErrorResult.h"
13 #include "mozilla/dom/BindingDeclarations.h"
14 #include "mozilla/dom/Lock.h"
15 #include "mozilla/dom/LockManagerBinding.h"
16 #include "mozilla/dom/WorkerRef.h"
17 #include "nsCycleCollectionParticipant.h"
18 #include "nsHashKeys.h"
19 #include "nsTHashMap.h"
20 #include "nsTHashSet.h"
21 #include "nsWrapperCache.h"
23 class nsIGlobalObject
;
25 namespace mozilla::dom
{
27 class LockGrantedCallback
;
31 class LockManagerChild
;
34 class LockManager final
: public nsISupports
, public nsWrapperCache
{
36 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
37 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(LockManager
)
39 explicit LockManager(nsIGlobalObject
* aGlobal
);
41 nsIGlobalObject
* GetParentObject() const { return mOwner
; }
43 JSObject
* WrapObject(JSContext
* aCx
,
44 JS::Handle
<JSObject
*> aGivenProto
) override
;
46 already_AddRefed
<Promise
> Request(const nsAString
& aName
,
47 LockGrantedCallback
& aCallback
,
49 already_AddRefed
<Promise
> Request(const nsAString
& aName
,
50 const LockOptions
& aOptions
,
51 LockGrantedCallback
& aCallback
,
54 already_AddRefed
<Promise
> Query(ErrorResult
& aRv
);
59 ~LockManager() = default;
61 nsCOMPtr
<nsIGlobalObject
> mOwner
;
62 RefPtr
<locks::LockManagerChild
> mActor
;
64 RefPtr
<WeakWorkerRef
> mWorkerRef
;
67 } // namespace mozilla::dom
69 #endif // mozilla_dom_LockManager_h