Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / dom / quota / OriginDirectoryLock.cpp
blobce537292550626562039fe87365d43892a4b922e
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 "OriginDirectoryLock.h"
9 #include <utility>
11 #include "nsString.h"
12 #include "mozilla/Assertions.h"
13 #include "mozilla/NotNull.h"
14 #include "mozilla/RefPtr.h"
15 #include "mozilla/dom/Nullable.h"
16 #include "mozilla/dom/quota/CommonMetadata.h"
17 #include "mozilla/dom/quota/DirectoryLockCategory.h"
18 #include "mozilla/dom/quota/OriginScope.h"
19 #include "mozilla/dom/quota/PersistenceScope.h"
20 #include "mozilla/dom/quota/QuotaManager.h"
22 namespace mozilla::dom::quota {
24 // static
25 RefPtr<OriginDirectoryLock> OriginDirectoryLock::CreateForEviction(
26 MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
27 PersistenceType aPersistenceType,
28 const quota::OriginMetadata& aOriginMetadata) {
29 MOZ_ASSERT(aPersistenceType != PERSISTENCE_TYPE_INVALID);
30 MOZ_ASSERT(!aOriginMetadata.mOrigin.IsEmpty());
31 MOZ_ASSERT(!aOriginMetadata.mStorageOrigin.IsEmpty());
33 return MakeRefPtr<OriginDirectoryLock>(
34 std::move(aQuotaManager),
35 PersistenceScope::CreateFromValue(aPersistenceType),
36 OriginScope::FromOrigin(aOriginMetadata), Nullable<Client::Type>(),
37 /* aExclusive */ true, /* aInternal */ true,
38 ShouldUpdateLockIdTableFlag::No, DirectoryLockCategory::UninitOrigins);
41 } // namespace mozilla::dom::quota