tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

LockRequestParent.cpp (1344B)


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