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 #include "LockManagerParent.h"
8 #include "LockRequestParent.h"
10 #include "mozilla/dom/Promise.h"
12 namespace mozilla::dom::locks
{
14 mozilla::ipc::IPCResult
LockRequestParent::Recv__delete__(bool aAborted
) {
15 RefPtr
<LockManagerParent
> manager
=
16 static_cast<LockManagerParent
*>(Manager());
17 ManagedLocks
& managed
= manager
->Locks();
19 DebugOnly
<bool> unheld
= managed
.mHeldLocks
.RemoveElement(this);
20 MOZ_ASSERT_IF(!aAborted
, unheld
);
22 if (auto queue
= managed
.mQueueMap
.Lookup(mRequest
.name())) {
24 DebugOnly
<bool> dequeued
= queue
.Data().RemoveElement(this);
25 MOZ_ASSERT_IF(!unheld
, dequeued
);
27 manager
->ProcessRequestQueue(queue
.Data());
28 if (queue
.Data().IsEmpty()) {
29 // Remove if empty, to prevent the queue map from growing forever
33 // or else, the queue is removed during the previous lock release (since
34 // multiple held locks are possible with `shared: true`)
38 } // namespace mozilla::dom::locks