tor-browser

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

LockManagerParent.h (1969B)


      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 #ifndef DOM_LOCKS_LOCKMANAGERPARENT_H_
      8 #define DOM_LOCKS_LOCKMANAGERPARENT_H_
      9 
     10 #include "mozilla/AlreadyAddRefed.h"
     11 #include "mozilla/WeakPtr.h"
     12 #include "mozilla/dom/locks/LockRequestParent.h"
     13 #include "mozilla/dom/locks/PLockManagerParent.h"
     14 #include "mozilla/ipc/PBackgroundSharedTypes.h"
     15 
     16 namespace mozilla::dom::locks {
     17 
     18 class ManagedLocks : public SupportsWeakPtr {
     19 public:
     20  NS_INLINE_DECL_REFCOUNTING(ManagedLocks)
     21 
     22  nsTArray<RefPtr<LockRequestParent>> mHeldLocks;
     23  nsTHashMap<nsStringHashKey, nsTArray<RefPtr<LockRequestParent>>> mQueueMap;
     24 
     25 private:
     26  ~ManagedLocks() = default;
     27 };
     28 
     29 class LockManagerParent final : public PLockManagerParent {
     30  using IPCResult = mozilla::ipc::IPCResult;
     31 
     32 public:
     33  NS_INLINE_DECL_REFCOUNTING(LockManagerParent)
     34 
     35  LockManagerParent(NotNull<nsIPrincipal*> aPrincipal,
     36                    const Maybe<nsID>& aClientId);
     37 
     38  void ProcessRequestQueue(nsTArray<RefPtr<LockRequestParent>>& aQueue);
     39  bool IsGrantableRequest(const IPCLockRequest& aRequest);
     40 
     41  IPCResult RecvQuery(QueryResolver&& aResolver);
     42 
     43  already_AddRefed<PLockRequestParent> AllocPLockRequestParent(
     44      const IPCLockRequest& aRequest);
     45  IPCResult RecvPLockRequestConstructor(PLockRequestParent* aActor,
     46                                        const IPCLockRequest& aRequest) final;
     47 
     48  ManagedLocks& Locks() { return *mManagedLocks; }
     49 
     50 private:
     51  ~LockManagerParent() = default;
     52 
     53  void ActorDestroy(ActorDestroyReason aWhy) final;
     54 
     55  RefPtr<ManagedLocks> mManagedLocks;
     56  nsString mClientId;
     57  NotNull<nsCOMPtr<nsIPrincipal>> mPrincipal;
     58 };
     59 
     60 }  // namespace mozilla::dom::locks
     61 
     62 #endif  // DOM_LOCKS_LOCKMANAGERPARENT_H_