tor-browser

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

UniversalDirectoryLock.h (2161B)


      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_QUOTA_UNIVERSALDIRECTORYLOCK_H_
      8 #define DOM_QUOTA_UNIVERSALDIRECTORYLOCK_H_
      9 
     10 #include "mozilla/dom/quota/Client.h"
     11 #include "mozilla/dom/quota/DirectoryLockImpl.h"
     12 #include "mozilla/dom/quota/PersistenceType.h"
     13 
     14 template <class T>
     15 class RefPtr;
     16 
     17 namespace mozilla {
     18 
     19 template <typename T>
     20 class MovingNotNull;
     21 
     22 }  // namespace mozilla
     23 
     24 namespace mozilla::dom {
     25 
     26 template <typename T>
     27 struct Nullable;
     28 
     29 }  // namespace mozilla::dom
     30 
     31 namespace mozilla::dom::quota {
     32 
     33 class ClientDirectoruLock;
     34 enum class DirectoryLockCategory : uint8_t;
     35 struct OriginMetadata;
     36 class OriginScope;
     37 class PersistenceScope;
     38 class QuotaManager;
     39 
     40 // A directory lock for universal use. A universal lock can handle any possible
     41 // combination of nullable persistence type, origin scope and nullable client
     42 // type.
     43 //
     44 // For example, if the persistence type is set to null, origin scope is null
     45 // and the client type is set to Client::IDB, then the lock will cover
     46 // <profile>/storage/*/*/idb
     47 //
     48 // If no property is set, then the lock will cover the entire storage directory
     49 // and its subdirectories.
     50 class UniversalDirectoryLock final : public DirectoryLockImpl {
     51  friend class QuotaManager;
     52 
     53 public:
     54  using DirectoryLockImpl::DirectoryLockImpl;
     55 
     56  RefPtr<ClientDirectoryLock> SpecializeForClient(
     57      PersistenceType aPersistenceType,
     58      const quota::OriginMetadata& aOriginMetadata,
     59      Client::Type aClientType) const;
     60 
     61 private:
     62  static RefPtr<UniversalDirectoryLock> CreateInternal(
     63      MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
     64      const PersistenceScope& aPersistenceScope,
     65      const OriginScope& aOriginScope,
     66      const ClientStorageScope& aClientStorageScope, bool aExclusive,
     67      DirectoryLockCategory aCategory);
     68 };
     69 
     70 }  // namespace mozilla::dom::quota
     71 
     72 #endif  // DOM_QUOTA_UNIVERSALDIRECTORYLOCK_H_