tor-browser

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

ClientDirectoryLock.cpp (2426B)


      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 "ClientDirectoryLock.h"
      8 
      9 #include <utility>
     10 
     11 #include "mozilla/Assertions.h"
     12 #include "mozilla/NotNull.h"
     13 #include "mozilla/RefPtr.h"
     14 #include "mozilla/dom/Nullable.h"
     15 #include "mozilla/dom/quota/DirectoryLockCategory.h"
     16 #include "mozilla/dom/quota/OriginScope.h"
     17 #include "mozilla/dom/quota/PersistenceScope.h"
     18 #include "mozilla/dom/quota/QuotaManager.h"
     19 #include "nsString.h"
     20 
     21 namespace mozilla::dom::quota {
     22 
     23 // static
     24 RefPtr<ClientDirectoryLock> ClientDirectoryLock::Create(
     25    MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
     26    PersistenceType aPersistenceType,
     27    const quota::OriginMetadata& aOriginMetadata, Client::Type aClientType,
     28    bool aExclusive) {
     29  return MakeRefPtr<ClientDirectoryLock>(
     30      std::move(aQuotaManager),
     31      PersistenceScope::CreateFromValue(aPersistenceType),
     32      OriginScope::FromOrigin(aOriginMetadata),
     33      ClientStorageScope::CreateFromClient(aClientType), aExclusive, false,
     34      ShouldUpdateLockIdTableFlag::Yes, DirectoryLockCategory::None);
     35 }
     36 
     37 // static
     38 RefPtr<ClientDirectoryLock> ClientDirectoryLock::Create(
     39    MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
     40    const PersistenceScope& aPersistenceScope, const OriginScope& aOriginScope,
     41    const ClientStorageScope& aClientStorageScope, bool aExclusive,
     42    bool aInternal, ShouldUpdateLockIdTableFlag aShouldUpdateLockIdTableFlag,
     43    DirectoryLockCategory aCategory) {
     44  MOZ_ASSERT_IF(aOriginScope.IsOrigin(), !aOriginScope.GetOrigin().IsEmpty());
     45  MOZ_ASSERT_IF(!aInternal, aPersistenceScope.IsValue());
     46  MOZ_ASSERT_IF(!aInternal,
     47                aPersistenceScope.GetValue() != PERSISTENCE_TYPE_INVALID);
     48  MOZ_ASSERT_IF(!aInternal, aOriginScope.IsOrigin());
     49  MOZ_ASSERT_IF(!aInternal, aClientStorageScope.IsClient());
     50  MOZ_ASSERT_IF(!aInternal,
     51                aClientStorageScope.GetClientType() < Client::TypeMax());
     52 
     53  return MakeRefPtr<ClientDirectoryLock>(
     54      std::move(aQuotaManager), aPersistenceScope, aOriginScope,
     55      aClientStorageScope, aExclusive, aInternal, aShouldUpdateLockIdTableFlag,
     56      aCategory);
     57 }
     58 
     59 }  // namespace mozilla::dom::quota