зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1749504 - Add not null strong reference to QuotaManager from OriginOperatiosBase; r=dom-storage-reviewers,jstutte
OriginOperationBase and the derived classes currently must get QuotaManager by calling QuotaManager::Get() and usually asserting that the returned value is not null. Now when OriginOperationBase is created and destroyed only on the PBackground thread, a new not null strong reference to QuotaManager can be added to OriginOperationBase which will eliminate the need for calling QuotaManager::Get. Calling QuotaManager::Get less is desired because such a call can get more expensive in future. Changes done in this patch: - added not null strong reference to QuotaManager from OriginOperationBase - adjusted constructors of derived classes - adjusted factories for origin operations - started using the new member in some places (instead of calling QuotaManager::Get) - removed some now unnecessary QuotaManager::Get calls Differential Revision: https://phabricator.services.mozilla.com/D185645
This commit is contained in:
Родитель
3eced41528
Коммит
d03985bb1c
|
@ -2583,7 +2583,8 @@ void QuotaManager::UpdateOriginAccessTime(
|
|||
|
||||
MutexAutoUnlock autoUnlock(mQuotaMutex);
|
||||
|
||||
auto op = CreateSaveOriginAccessTimeOp(aOriginMetadata, timestamp);
|
||||
auto op = CreateSaveOriginAccessTimeOp(WrapMovingNotNullUnchecked(this),
|
||||
aOriginMetadata, timestamp);
|
||||
|
||||
RegisterNormalOriginOp(*op);
|
||||
|
||||
|
@ -4859,7 +4860,7 @@ RefPtr<BoolPromise> QuotaManager::InitializeStorage() {
|
|||
return BoolPromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
|
||||
auto initializeStorageOp = CreateInitOp();
|
||||
auto initializeStorageOp = CreateInitOp(WrapMovingNotNullUnchecked(this));
|
||||
|
||||
RegisterNormalOriginOp(*initializeStorageOp);
|
||||
|
||||
|
@ -5167,7 +5168,8 @@ nsresult QuotaManager::EnsureTemporaryStorageIsInitialized() {
|
|||
RefPtr<BoolPromise> QuotaManager::ClearPrivateRepository() {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
auto clearPrivateRepositoryOp = CreateClearPrivateRepositoryOp();
|
||||
auto clearPrivateRepositoryOp =
|
||||
CreateClearPrivateRepositoryOp(WrapMovingNotNullUnchecked(this));
|
||||
|
||||
RegisterNormalOriginOp(*clearPrivateRepositoryOp);
|
||||
|
||||
|
@ -5179,7 +5181,7 @@ RefPtr<BoolPromise> QuotaManager::ClearPrivateRepository() {
|
|||
RefPtr<BoolPromise> QuotaManager::ClearStorage() {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
auto clearStorageOp = CreateClearStorageOp();
|
||||
auto clearStorageOp = CreateClearStorageOp(WrapMovingNotNullUnchecked(this));
|
||||
|
||||
RegisterNormalOriginOp(*clearStorageOp);
|
||||
|
||||
|
@ -5207,7 +5209,8 @@ RefPtr<BoolPromise> QuotaManager::ClearStorage() {
|
|||
RefPtr<BoolPromise> QuotaManager::ShutdownStorage() {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
auto shutdownStorageOp = CreateShutdownStorageOp();
|
||||
auto shutdownStorageOp =
|
||||
CreateShutdownStorageOp(WrapMovingNotNullUnchecked(this));
|
||||
|
||||
RegisterNormalOriginOp(*shutdownStorageOp);
|
||||
|
||||
|
@ -6106,8 +6109,11 @@ void QuotaManager::FinalizeOriginEviction(
|
|||
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
auto finalizeOriginEviction = [locks = std::move(aLocks)]() mutable {
|
||||
RefPtr<OriginOperationBase> op =
|
||||
CreateFinalizeOriginEvictionOp(std::move(locks));
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
RefPtr<OriginOperationBase> op = CreateFinalizeOriginEvictionOp(
|
||||
WrapMovingNotNull(quotaManager), std::move(locks));
|
||||
|
||||
op->RunImmediately();
|
||||
};
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
namespace mozilla::dom::quota {
|
||||
|
||||
NormalOriginOperationBase::NormalOriginOperationBase(
|
||||
const char* aName, const Nullable<PersistenceType>& aPersistenceType,
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager, const char* aName,
|
||||
const Nullable<PersistenceType>& aPersistenceType,
|
||||
const OriginScope& aOriginScope, const Nullable<Client::Type>& aClientType,
|
||||
bool aExclusive)
|
||||
: OriginOperationBase(aName),
|
||||
: OriginOperationBase(std::move(aQuotaManager), aName),
|
||||
mOriginScope(aOriginScope),
|
||||
mPersistenceType(aPersistenceType),
|
||||
mClientType(aClientType),
|
||||
|
@ -29,15 +30,13 @@ NormalOriginOperationBase::~NormalOriginOperationBase() {
|
|||
|
||||
RefPtr<DirectoryLock> NormalOriginOperationBase::CreateDirectoryLock() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(QuotaManager::Get());
|
||||
|
||||
return QuotaManager::Get()->CreateDirectoryLockInternal(
|
||||
return mQuotaManager->CreateDirectoryLockInternal(
|
||||
mPersistenceType, mOriginScope, mClientType, mExclusive);
|
||||
}
|
||||
|
||||
RefPtr<BoolPromise> NormalOriginOperationBase::Open() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(QuotaManager::Get());
|
||||
|
||||
RefPtr<DirectoryLock> directoryLock = CreateDirectoryLock();
|
||||
|
||||
|
@ -61,7 +60,6 @@ RefPtr<BoolPromise> NormalOriginOperationBase::Open() {
|
|||
|
||||
void NormalOriginOperationBase::UnblockOpen() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(QuotaManager::Get());
|
||||
|
||||
SendResults();
|
||||
|
||||
|
@ -69,7 +67,7 @@ void NormalOriginOperationBase::UnblockOpen() {
|
|||
mDirectoryLock = nullptr;
|
||||
}
|
||||
|
||||
QuotaManager::Get()->UnregisterNormalOriginOp(*this);
|
||||
mQuotaManager->UnregisterNormalOriginOp(*this);
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom::quota
|
||||
|
|
|
@ -37,7 +37,8 @@ class NormalOriginOperationBase
|
|||
// is included). The compiler would complain otherwise because it wouldn't
|
||||
// know how to call DirectoryLock::AddRef/Release in the constructor and
|
||||
// destructor
|
||||
NormalOriginOperationBase(const char* aName,
|
||||
NormalOriginOperationBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName,
|
||||
const Nullable<PersistenceType>& aPersistenceType,
|
||||
const OriginScope& aOriginScope,
|
||||
const Nullable<Client::Type>& aClientType,
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
OriginOperationBase::OriginOperationBase(const char* aName)
|
||||
OriginOperationBase::OriginOperationBase(
|
||||
MovingNotNull<RefPtr<QuotaManager>>&& aQuotaManager, const char* aName)
|
||||
: BackgroundThreadObject(GetCurrentSerialEventTarget()),
|
||||
mQuotaManager(std::move(aQuotaManager)),
|
||||
mResultCode(NS_OK),
|
||||
mActorDestroyed(false)
|
||||
#ifdef QM_COLLECTING_OPERATION_TELEMETRY
|
||||
|
@ -37,18 +39,12 @@ OriginOperationBase::~OriginOperationBase() {
|
|||
void OriginOperationBase::RunImmediately() {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
[self = RefPtr(this)]() {
|
||||
if (QuotaManager::IsShuttingDown()) {
|
||||
return BoolPromise::CreateAndReject(NS_ERROR_ABORT, __func__);
|
||||
}
|
||||
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
QM_TRY(MOZ_TO_RESULT(self->DoInit(*quotaManager)),
|
||||
QM_TRY(MOZ_TO_RESULT(self->DoInit(*self->mQuotaManager)),
|
||||
CreateAndRejectBoolPromise);
|
||||
|
||||
return self->Open();
|
||||
|
@ -71,7 +67,7 @@ void OriginOperationBase::RunImmediately() {
|
|||
return BoolPromise::CreateAndResolve(true, __func__);
|
||||
})
|
||||
#endif
|
||||
->Then(quotaManager->IOThread(), __func__,
|
||||
->Then(mQuotaManager->IOThread(), __func__,
|
||||
[selfHolder = fs::TargetPtrHolder(this)](
|
||||
const BoolPromise::ResolveOrRejectValue& aValue) {
|
||||
if (aValue.IsReject()) {
|
||||
|
@ -79,10 +75,8 @@ void OriginOperationBase::RunImmediately() {
|
|||
__func__);
|
||||
}
|
||||
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
QM_TRY(MOZ_TO_RESULT(quotaManager), CreateAndRejectBoolPromise);
|
||||
|
||||
QM_TRY(MOZ_TO_RESULT(selfHolder->DoDirectoryWork(*quotaManager)),
|
||||
QM_TRY(MOZ_TO_RESULT(selfHolder->DoDirectoryWork(
|
||||
*selfHolder->mQuotaManager)),
|
||||
CreateAndRejectBoolPromise);
|
||||
|
||||
return BoolPromise::CreateAndResolve(true, __func__);
|
||||
|
|
|
@ -8,20 +8,20 @@
|
|||
#define DOM_QUOTA_ORIGINOPERATIONBASE_H_
|
||||
|
||||
#include "ErrorList.h"
|
||||
#include "mozilla/NotNull.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/dom/quota/Config.h"
|
||||
#include "mozilla/dom/quota/ForwardDecls.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
template <class T>
|
||||
class RefPtr;
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
class QuotaManager;
|
||||
|
||||
class OriginOperationBase : public BackgroundThreadObject {
|
||||
protected:
|
||||
const NotNull<RefPtr<QuotaManager>> mQuotaManager;
|
||||
nsresult mResultCode;
|
||||
|
||||
private:
|
||||
|
@ -53,7 +53,8 @@ class OriginOperationBase : public BackgroundThreadObject {
|
|||
void RunImmediately();
|
||||
|
||||
protected:
|
||||
explicit OriginOperationBase(const char* aName);
|
||||
OriginOperationBase(MovingNotNull<RefPtr<QuotaManager>>&& aQuotaManager,
|
||||
const char* aName);
|
||||
|
||||
// Reference counted.
|
||||
virtual ~OriginOperationBase();
|
||||
|
|
|
@ -73,9 +73,10 @@ class FinalizeOriginEvictionOp : public OriginOperationBase {
|
|||
nsTArray<RefPtr<OriginDirectoryLock>> mLocks;
|
||||
|
||||
public:
|
||||
explicit FinalizeOriginEvictionOp(
|
||||
nsTArray<RefPtr<OriginDirectoryLock>>&& aLocks)
|
||||
: OriginOperationBase("dom::quota::FinalizeOriginEvictionOp"),
|
||||
FinalizeOriginEvictionOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
nsTArray<RefPtr<OriginDirectoryLock>>&& aLocks)
|
||||
: OriginOperationBase(std::move(aQuotaManager),
|
||||
"dom::quota::FinalizeOriginEvictionOp"),
|
||||
mLocks(std::move(aLocks)) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
@ -95,10 +96,11 @@ class SaveOriginAccessTimeOp : public NormalOriginOperationBase {
|
|||
int64_t mTimestamp;
|
||||
|
||||
public:
|
||||
SaveOriginAccessTimeOp(const OriginMetadata& aOriginMetadata,
|
||||
SaveOriginAccessTimeOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const OriginMetadata& aOriginMetadata,
|
||||
int64_t aTimestamp)
|
||||
: NormalOriginOperationBase(
|
||||
"dom::quota::SaveOriginAccessTimeOp",
|
||||
std::move(aQuotaManager), "dom::quota::SaveOriginAccessTimeOp",
|
||||
Nullable<PersistenceType>(aOriginMetadata.mPersistenceType),
|
||||
OriginScope::FromOrigin(aOriginMetadata.mOrigin),
|
||||
Nullable<Client::Type>(),
|
||||
|
@ -118,9 +120,10 @@ class SaveOriginAccessTimeOp : public NormalOriginOperationBase {
|
|||
|
||||
class ClearPrivateRepositoryOp : public ResolvableNormalOriginOp<bool> {
|
||||
public:
|
||||
ClearPrivateRepositoryOp()
|
||||
explicit ClearPrivateRepositoryOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: ResolvableNormalOriginOp(
|
||||
"dom::quota::ClearPrivateRepositoryOp",
|
||||
std::move(aQuotaManager), "dom::quota::ClearPrivateRepositoryOp",
|
||||
Nullable<PersistenceType>(PERSISTENCE_TYPE_PRIVATE),
|
||||
OriginScope::FromNull(), Nullable<Client::Type>(),
|
||||
/* aExclusive */ true) {
|
||||
|
@ -137,10 +140,11 @@ class ClearPrivateRepositoryOp : public ResolvableNormalOriginOp<bool> {
|
|||
|
||||
class ShutdownStorageOp : public ResolvableNormalOriginOp<bool> {
|
||||
public:
|
||||
ShutdownStorageOp()
|
||||
explicit ShutdownStorageOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: ResolvableNormalOriginOp(
|
||||
"dom::quota::ShutdownStorageOp", Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(), Nullable<Client::Type>(),
|
||||
std::move(aQuotaManager), "dom::quota::ShutdownStorageOp",
|
||||
Nullable<PersistenceType>(), OriginScope::FromNull(),
|
||||
Nullable<Client::Type>(),
|
||||
/* aExclusive */ true) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
@ -189,7 +193,8 @@ class GetUsageOp final : public QuotaUsageRequestBase,
|
|||
bool mGetAll;
|
||||
|
||||
public:
|
||||
explicit GetUsageOp(const UsageRequestParams& aParams);
|
||||
GetUsageOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams);
|
||||
|
||||
private:
|
||||
~GetUsageOp() = default;
|
||||
|
@ -222,7 +227,8 @@ class GetOriginUsageOp final : public QuotaUsageRequestBase {
|
|||
bool mFromMemory;
|
||||
|
||||
public:
|
||||
explicit GetOriginUsageOp(const UsageRequestParams& aParams);
|
||||
GetOriginUsageOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams);
|
||||
|
||||
private:
|
||||
~GetOriginUsageOp() = default;
|
||||
|
@ -240,7 +246,7 @@ class StorageNameOp final : public QuotaRequestBase {
|
|||
nsString mName;
|
||||
|
||||
public:
|
||||
StorageNameOp();
|
||||
explicit StorageNameOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
private:
|
||||
~StorageNameOp() = default;
|
||||
|
@ -256,7 +262,8 @@ class InitializedRequestBase : public QuotaRequestBase {
|
|||
protected:
|
||||
bool mInitialized;
|
||||
|
||||
InitializedRequestBase(const char* aName);
|
||||
InitializedRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName);
|
||||
|
||||
private:
|
||||
RefPtr<DirectoryLock> CreateDirectoryLock() override;
|
||||
|
@ -264,8 +271,10 @@ class InitializedRequestBase : public QuotaRequestBase {
|
|||
|
||||
class StorageInitializedOp final : public InitializedRequestBase {
|
||||
public:
|
||||
StorageInitializedOp()
|
||||
: InitializedRequestBase("dom::quota::StorageInitializedOp") {}
|
||||
explicit StorageInitializedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: InitializedRequestBase(std::move(aQuotaManager),
|
||||
"dom::quota::StorageInitializedOp") {}
|
||||
|
||||
private:
|
||||
~StorageInitializedOp() = default;
|
||||
|
@ -277,8 +286,10 @@ class StorageInitializedOp final : public InitializedRequestBase {
|
|||
|
||||
class TemporaryStorageInitializedOp final : public InitializedRequestBase {
|
||||
public:
|
||||
TemporaryStorageInitializedOp()
|
||||
: InitializedRequestBase("dom::quota::StorageInitializedOp") {}
|
||||
explicit TemporaryStorageInitializedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: InitializedRequestBase(std::move(aQuotaManager),
|
||||
"dom::quota::StorageInitializedOp") {}
|
||||
|
||||
private:
|
||||
~TemporaryStorageInitializedOp() = default;
|
||||
|
@ -290,7 +301,7 @@ class TemporaryStorageInitializedOp final : public InitializedRequestBase {
|
|||
|
||||
class InitOp final : public ResolvableNormalOriginOp<bool> {
|
||||
public:
|
||||
InitOp();
|
||||
explicit InitOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
private:
|
||||
~InitOp() = default;
|
||||
|
@ -302,7 +313,8 @@ class InitOp final : public ResolvableNormalOriginOp<bool> {
|
|||
|
||||
class InitTemporaryStorageOp final : public QuotaRequestBase {
|
||||
public:
|
||||
InitTemporaryStorageOp();
|
||||
explicit InitTemporaryStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
private:
|
||||
~InitTemporaryStorageOp() = default;
|
||||
|
@ -321,7 +333,8 @@ class InitializeOriginRequestBase : public QuotaRequestBase {
|
|||
bool mIsPrivate;
|
||||
bool mCreated;
|
||||
|
||||
InitializeOriginRequestBase(const char* aName,
|
||||
InitializeOriginRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName,
|
||||
PersistenceType aPersistenceType,
|
||||
const PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
|
@ -330,7 +343,9 @@ class InitializeOriginRequestBase : public QuotaRequestBase {
|
|||
|
||||
class InitializePersistentOriginOp final : public InitializeOriginRequestBase {
|
||||
public:
|
||||
explicit InitializePersistentOriginOp(const RequestParams& aParams);
|
||||
InitializePersistentOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
private:
|
||||
~InitializePersistentOriginOp() = default;
|
||||
|
@ -342,7 +357,8 @@ class InitializePersistentOriginOp final : public InitializeOriginRequestBase {
|
|||
|
||||
class InitializeTemporaryOriginOp final : public InitializeOriginRequestBase {
|
||||
public:
|
||||
explicit InitializeTemporaryOriginOp(const RequestParams& aParams);
|
||||
InitializeTemporaryOriginOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
private:
|
||||
~InitializeTemporaryOriginOp() = default;
|
||||
|
@ -359,7 +375,8 @@ class GetFullOriginMetadataOp : public QuotaRequestBase {
|
|||
Maybe<FullOriginMetadata> mMaybeFullOriginMetadata;
|
||||
|
||||
public:
|
||||
explicit GetFullOriginMetadataOp(const GetFullOriginMetadataParams& aParams);
|
||||
GetFullOriginMetadataOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const GetFullOriginMetadataParams& aParams);
|
||||
|
||||
private:
|
||||
nsresult DoInit(QuotaManager& aQuotaManager) override;
|
||||
|
@ -373,7 +390,7 @@ class GetFullOriginMetadataOp : public QuotaRequestBase {
|
|||
|
||||
class ClearStorageOp final : public ResolvableNormalOriginOp<bool> {
|
||||
public:
|
||||
ClearStorageOp();
|
||||
explicit ClearStorageOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
private:
|
||||
~ClearStorageOp() = default;
|
||||
|
@ -389,17 +406,19 @@ class ClearStorageOp final : public ResolvableNormalOriginOp<bool> {
|
|||
|
||||
class ClearRequestBase : public QuotaRequestBase {
|
||||
protected:
|
||||
ClearRequestBase(const char* aName, bool aExclusive)
|
||||
: QuotaRequestBase(aName, aExclusive) {
|
||||
ClearRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName, bool aExclusive)
|
||||
: QuotaRequestBase(std::move(aQuotaManager), aName, aExclusive) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
||||
ClearRequestBase(const char* aName,
|
||||
ClearRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName,
|
||||
const Nullable<PersistenceType>& aPersistenceType,
|
||||
const OriginScope& aOriginScope,
|
||||
const Nullable<Client::Type>& aClientType, bool aExclusive)
|
||||
: QuotaRequestBase(aName, aPersistenceType, aOriginScope, aClientType,
|
||||
aExclusive) {}
|
||||
: QuotaRequestBase(std::move(aQuotaManager), aName, aPersistenceType,
|
||||
aOriginScope, aClientType, aExclusive) {}
|
||||
|
||||
void DeleteFiles(QuotaManager& aQuotaManager,
|
||||
PersistenceType aPersistenceType);
|
||||
|
@ -412,7 +431,8 @@ class ClearOriginOp final : public ClearRequestBase {
|
|||
const bool mMatchAll;
|
||||
|
||||
public:
|
||||
explicit ClearOriginOp(const RequestParams& aParams);
|
||||
ClearOriginOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
private:
|
||||
~ClearOriginOp() = default;
|
||||
|
@ -424,7 +444,8 @@ class ClearDataOp final : public ClearRequestBase {
|
|||
const ClearDataParams mParams;
|
||||
|
||||
public:
|
||||
explicit ClearDataOp(const RequestParams& aParams);
|
||||
ClearDataOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
private:
|
||||
~ClearDataOp() = default;
|
||||
|
@ -434,7 +455,8 @@ class ClearDataOp final : public ClearRequestBase {
|
|||
|
||||
class ResetOriginOp final : public QuotaRequestBase {
|
||||
public:
|
||||
explicit ResetOriginOp(const RequestParams& aParams);
|
||||
ResetOriginOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
private:
|
||||
~ResetOriginOp() = default;
|
||||
|
@ -454,7 +476,8 @@ class PersistRequestBase : public QuotaRequestBase {
|
|||
bool mIsPrivate;
|
||||
|
||||
protected:
|
||||
explicit PersistRequestBase(const PrincipalInfo& aPrincipalInfo);
|
||||
PersistRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
nsresult DoInit(QuotaManager& aQuotaManager) override;
|
||||
};
|
||||
|
@ -463,7 +486,8 @@ class PersistedOp final : public PersistRequestBase {
|
|||
bool mPersisted;
|
||||
|
||||
public:
|
||||
explicit PersistedOp(const RequestParams& aParams);
|
||||
PersistedOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
private:
|
||||
~PersistedOp() = default;
|
||||
|
@ -475,7 +499,8 @@ class PersistedOp final : public PersistRequestBase {
|
|||
|
||||
class PersistOp final : public PersistRequestBase {
|
||||
public:
|
||||
explicit PersistOp(const RequestParams& aParams);
|
||||
PersistOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
private:
|
||||
~PersistOp() = default;
|
||||
|
@ -491,7 +516,8 @@ class EstimateOp final : public QuotaRequestBase {
|
|||
std::pair<uint64_t, uint64_t> mUsageAndLimit;
|
||||
|
||||
public:
|
||||
explicit EstimateOp(const EstimateParams& aParams);
|
||||
EstimateOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const EstimateParams& aParams);
|
||||
|
||||
private:
|
||||
~EstimateOp() = default;
|
||||
|
@ -511,7 +537,7 @@ class ListOriginsOp final : public QuotaRequestBase,
|
|||
nsTArray<nsCString> mOrigins;
|
||||
|
||||
public:
|
||||
ListOriginsOp();
|
||||
explicit ListOriginsOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
private:
|
||||
~ListOriginsOp() = default;
|
||||
|
@ -530,98 +556,130 @@ class ListOriginsOp final : public QuotaRequestBase,
|
|||
} // namespace
|
||||
|
||||
RefPtr<OriginOperationBase> CreateFinalizeOriginEvictionOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
nsTArray<RefPtr<OriginDirectoryLock>>&& aLocks) {
|
||||
return MakeRefPtr<FinalizeOriginEvictionOp>(std::move(aLocks));
|
||||
return MakeRefPtr<FinalizeOriginEvictionOp>(std::move(aQuotaManager),
|
||||
std::move(aLocks));
|
||||
}
|
||||
|
||||
RefPtr<NormalOriginOperationBase> CreateSaveOriginAccessTimeOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const OriginMetadata& aOriginMetadata, int64_t aTimestamp) {
|
||||
return MakeRefPtr<SaveOriginAccessTimeOp>(aOriginMetadata, aTimestamp);
|
||||
return MakeRefPtr<SaveOriginAccessTimeOp>(std::move(aQuotaManager),
|
||||
aOriginMetadata, aTimestamp);
|
||||
}
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearPrivateRepositoryOp() {
|
||||
return MakeRefPtr<ClearPrivateRepositoryOp>();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearPrivateRepositoryOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<ClearPrivateRepositoryOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateShutdownStorageOp() {
|
||||
return MakeRefPtr<ShutdownStorageOp>();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateShutdownStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<ShutdownStorageOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<QuotaUsageRequestBase> CreateGetUsageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams) {
|
||||
return MakeRefPtr<GetUsageOp>(aParams);
|
||||
return MakeRefPtr<GetUsageOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaUsageRequestBase> CreateGetOriginUsageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams) {
|
||||
return MakeRefPtr<GetOriginUsageOp>(aParams);
|
||||
return MakeRefPtr<GetOriginUsageOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateStorageNameOp() {
|
||||
return MakeRefPtr<StorageNameOp>();
|
||||
RefPtr<QuotaRequestBase> CreateStorageNameOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<StorageNameOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateStorageInitializedOp() {
|
||||
return MakeRefPtr<StorageInitializedOp>();
|
||||
RefPtr<QuotaRequestBase> CreateStorageInitializedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<StorageInitializedOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateTemporaryStorageInitializedOp() {
|
||||
return MakeRefPtr<TemporaryStorageInitializedOp>();
|
||||
RefPtr<QuotaRequestBase> CreateTemporaryStorageInitializedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<TemporaryStorageInitializedOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateInitOp() {
|
||||
return MakeRefPtr<InitOp>();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateInitOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<InitOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateInitTemporaryStorageOp() {
|
||||
return MakeRefPtr<InitTemporaryStorageOp>();
|
||||
RefPtr<QuotaRequestBase> CreateInitTemporaryStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<InitTemporaryStorageOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateInitializePersistentOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams) {
|
||||
return MakeRefPtr<InitializePersistentOriginOp>(aParams);
|
||||
return MakeRefPtr<InitializePersistentOriginOp>(std::move(aQuotaManager),
|
||||
aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateInitializeTemporaryOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams) {
|
||||
return MakeRefPtr<InitializeTemporaryOriginOp>(aParams);
|
||||
return MakeRefPtr<InitializeTemporaryOriginOp>(std::move(aQuotaManager),
|
||||
aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateGetFullOriginMetadataOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const GetFullOriginMetadataParams& aParams) {
|
||||
return MakeRefPtr<GetFullOriginMetadataOp>(aParams);
|
||||
return MakeRefPtr<GetFullOriginMetadataOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearStorageOp() {
|
||||
return MakeRefPtr<ClearStorageOp>();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<ClearStorageOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateClearOriginOp(const RequestParams& aParams) {
|
||||
return MakeRefPtr<ClearOriginOp>(aParams);
|
||||
RefPtr<QuotaRequestBase> CreateClearOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams) {
|
||||
return MakeRefPtr<ClearOriginOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateClearDataOp(const RequestParams& aParams) {
|
||||
return MakeRefPtr<ClearDataOp>(aParams);
|
||||
RefPtr<QuotaRequestBase> CreateClearDataOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams) {
|
||||
return MakeRefPtr<ClearDataOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateResetOriginOp(const RequestParams& aParams) {
|
||||
return MakeRefPtr<ResetOriginOp>(aParams);
|
||||
RefPtr<QuotaRequestBase> CreateResetOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams) {
|
||||
return MakeRefPtr<ResetOriginOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreatePersistedOp(const RequestParams& aParams) {
|
||||
return MakeRefPtr<PersistedOp>(aParams);
|
||||
RefPtr<QuotaRequestBase> CreatePersistedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams) {
|
||||
return MakeRefPtr<PersistedOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreatePersistOp(const RequestParams& aParams) {
|
||||
return MakeRefPtr<PersistOp>(aParams);
|
||||
RefPtr<QuotaRequestBase> CreatePersistOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams) {
|
||||
return MakeRefPtr<PersistOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateEstimateOp(const EstimateParams& aParams) {
|
||||
return MakeRefPtr<EstimateOp>(aParams);
|
||||
RefPtr<QuotaRequestBase> CreateEstimateOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const EstimateParams& aParams) {
|
||||
return MakeRefPtr<EstimateOp>(std::move(aQuotaManager), aParams);
|
||||
}
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateListOriginsOp() {
|
||||
return MakeRefPtr<ListOriginsOp>();
|
||||
RefPtr<QuotaRequestBase> CreateListOriginsOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager) {
|
||||
return MakeRefPtr<ListOriginsOp>(std::move(aQuotaManager));
|
||||
}
|
||||
|
||||
RefPtr<BoolPromise> FinalizeOriginEvictionOp::Open() {
|
||||
|
@ -788,8 +846,9 @@ nsresult TraverseRepositoryHelper::TraverseRepository(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
GetUsageOp::GetUsageOp(const UsageRequestParams& aParams)
|
||||
: QuotaUsageRequestBase("dom::quota::GetUsageOp"),
|
||||
GetUsageOp::GetUsageOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams)
|
||||
: QuotaUsageRequestBase(std::move(aQuotaManager), "dom::quota::GetUsageOp"),
|
||||
mGetAll(aParams.get_AllUsageParams().getAll()) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aParams.type() == UsageRequestParams::TAllUsageParams);
|
||||
|
@ -918,11 +977,15 @@ void GetUsageOp::GetResponse(UsageRequestResponse& aResponse) {
|
|||
aResponse.get_AllUsageResponse().originUsages() = std::move(mOriginUsages);
|
||||
}
|
||||
|
||||
GetOriginUsageOp::GetOriginUsageOp(const UsageRequestParams& aParams)
|
||||
: QuotaUsageRequestBase("dom::quota::GetOriginUsageOp"),
|
||||
GetOriginUsageOp::GetOriginUsageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams)
|
||||
: QuotaUsageRequestBase(std::move(aQuotaManager),
|
||||
"dom::quota::GetOriginUsageOp"),
|
||||
mParams(aParams.get_OriginUsageParams()),
|
||||
mUsage(0),
|
||||
mFileUsage(0) {
|
||||
mFileUsage(0),
|
||||
mIsPrivate(false) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aParams.type() == UsageRequestParams::TOriginUsageParams);
|
||||
|
||||
|
@ -1016,8 +1079,9 @@ void GetOriginUsageOp::GetResponse(UsageRequestResponse& aResponse) {
|
|||
aResponse = usageResponse;
|
||||
}
|
||||
|
||||
StorageNameOp::StorageNameOp()
|
||||
: QuotaRequestBase("dom::quota::StorageNameOp", /* aExclusive */ false) {
|
||||
StorageNameOp::StorageNameOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: QuotaRequestBase(std::move(aQuotaManager), "dom::quota::StorageNameOp",
|
||||
/* aExclusive */ false) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
||||
|
@ -1043,8 +1107,10 @@ void StorageNameOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = storageNameResponse;
|
||||
}
|
||||
|
||||
InitializedRequestBase::InitializedRequestBase(const char* aName)
|
||||
: QuotaRequestBase(aName, /* aExclusive */ false), mInitialized(false) {
|
||||
InitializedRequestBase::InitializedRequestBase(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager, const char* aName)
|
||||
: QuotaRequestBase(std::move(aQuotaManager), aName, /* aExclusive */ false),
|
||||
mInitialized(false) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
||||
|
@ -1093,11 +1159,12 @@ void TemporaryStorageInitializedOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = temporaryStorageInitializedResponse;
|
||||
}
|
||||
|
||||
InitOp::InitOp()
|
||||
: ResolvableNormalOriginOp(
|
||||
"dom::quota::InitOp", Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(), Nullable<Client::Type>(),
|
||||
/* aExclusive */ false) {
|
||||
InitOp::InitOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: ResolvableNormalOriginOp(std::move(aQuotaManager), "dom::quota::InitOp",
|
||||
Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(),
|
||||
Nullable<Client::Type>(),
|
||||
/* aExclusive */ false) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
||||
|
@ -1113,8 +1180,10 @@ nsresult InitOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
|
|||
|
||||
bool InitOp::GetResolveValue() { return true; }
|
||||
|
||||
InitTemporaryStorageOp::InitTemporaryStorageOp()
|
||||
: QuotaRequestBase("dom::quota::InitTemporaryStorageOp",
|
||||
InitTemporaryStorageOp::InitTemporaryStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: QuotaRequestBase(std::move(aQuotaManager),
|
||||
"dom::quota::InitTemporaryStorageOp",
|
||||
/* aExclusive */ false) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
@ -1139,9 +1208,9 @@ void InitTemporaryStorageOp::GetResponse(RequestResponse& aResponse) {
|
|||
}
|
||||
|
||||
InitializeOriginRequestBase::InitializeOriginRequestBase(
|
||||
const char* aName, const PersistenceType aPersistenceType,
|
||||
const PrincipalInfo& aPrincipalInfo)
|
||||
: QuotaRequestBase(aName,
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager, const char* aName,
|
||||
const PersistenceType aPersistenceType, const PrincipalInfo& aPrincipalInfo)
|
||||
: QuotaRequestBase(std::move(aQuotaManager), aName,
|
||||
/* aExclusive */ false),
|
||||
mPrincipalInfo(aPrincipalInfo),
|
||||
mCreated(false) {
|
||||
|
@ -1170,9 +1239,10 @@ nsresult InitializeOriginRequestBase::DoInit(QuotaManager& aQuotaManager) {
|
|||
}
|
||||
|
||||
InitializePersistentOriginOp::InitializePersistentOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams)
|
||||
: InitializeOriginRequestBase(
|
||||
"dom::quota::InitializePersistentOriginOp",
|
||||
std::move(aQuotaManager), "dom::quota::InitializePersistentOriginOp",
|
||||
PERSISTENCE_TYPE_PERSISTENT,
|
||||
aParams.get_InitializePersistentOriginParams().principalInfo()) {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -1208,9 +1278,10 @@ void InitializePersistentOriginOp::GetResponse(RequestResponse& aResponse) {
|
|||
}
|
||||
|
||||
InitializeTemporaryOriginOp::InitializeTemporaryOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams)
|
||||
: InitializeOriginRequestBase(
|
||||
"dom::quota::InitializeTemporaryOriginOp",
|
||||
std::move(aQuotaManager), "dom::quota::InitializeTemporaryOriginOp",
|
||||
aParams.get_InitializeTemporaryOriginParams().persistenceType(),
|
||||
aParams.get_InitializeTemporaryOriginParams().principalInfo()) {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -1250,8 +1321,10 @@ void InitializeTemporaryOriginOp::GetResponse(RequestResponse& aResponse) {
|
|||
}
|
||||
|
||||
GetFullOriginMetadataOp::GetFullOriginMetadataOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const GetFullOriginMetadataParams& aParams)
|
||||
: QuotaRequestBase("dom::quota::GetFullOriginMetadataOp",
|
||||
: QuotaRequestBase(std::move(aQuotaManager),
|
||||
"dom::quota::GetFullOriginMetadataOp",
|
||||
/* aExclusive */ false),
|
||||
mParams(aParams) {
|
||||
AssertIsOnOwningThread();
|
||||
|
@ -1303,10 +1376,12 @@ void GetFullOriginMetadataOp::GetResponse(RequestResponse& aResponse) {
|
|||
std::move(mMaybeFullOriginMetadata);
|
||||
}
|
||||
|
||||
ClearStorageOp::ClearStorageOp()
|
||||
ClearStorageOp::ClearStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: ResolvableNormalOriginOp(
|
||||
"dom::quota::ClearStorageOp", Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(), Nullable<Client::Type>(),
|
||||
std::move(aQuotaManager), "dom::quota::ClearStorageOp",
|
||||
Nullable<PersistenceType>(), OriginScope::FromNull(),
|
||||
Nullable<Client::Type>(),
|
||||
/* aExclusive */ true) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
@ -1611,8 +1686,10 @@ nsresult ClearRequestBase::DoDirectoryWork(QuotaManager& aQuotaManager) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
ClearOriginOp::ClearOriginOp(const RequestParams& aParams)
|
||||
: ClearRequestBase("dom::quota::ClearOriginOp", /* aExclusive */ true),
|
||||
ClearOriginOp::ClearOriginOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams)
|
||||
: ClearRequestBase(std::move(aQuotaManager), "dom::quota::ClearOriginOp",
|
||||
/* aExclusive */ true),
|
||||
mParams(aParams.get_ClearOriginParams().commonParams()),
|
||||
mMatchAll(aParams.get_ClearOriginParams().matchAll()) {
|
||||
MOZ_ASSERT(aParams.type() == RequestParams::TClearOriginParams);
|
||||
|
@ -1642,8 +1719,10 @@ void ClearOriginOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = ClearOriginResponse();
|
||||
}
|
||||
|
||||
ClearDataOp::ClearDataOp(const RequestParams& aParams)
|
||||
: ClearRequestBase("dom::quota::ClearDataOp", /* aExclusive */ true),
|
||||
ClearDataOp::ClearDataOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams)
|
||||
: ClearRequestBase(std::move(aQuotaManager), "dom::quota::ClearDataOp",
|
||||
/* aExclusive */ true),
|
||||
mParams(aParams) {
|
||||
MOZ_ASSERT(aParams.type() == RequestParams::TClearDataParams);
|
||||
|
||||
|
@ -1656,8 +1735,10 @@ void ClearDataOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = ClearDataResponse();
|
||||
}
|
||||
|
||||
ResetOriginOp::ResetOriginOp(const RequestParams& aParams)
|
||||
: QuotaRequestBase("dom::quota::ResetOriginOp", /* aExclusive */ true) {
|
||||
ResetOriginOp::ResetOriginOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams)
|
||||
: QuotaRequestBase(std::move(aQuotaManager), "dom::quota::ResetOriginOp",
|
||||
/* aExclusive */ true) {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aParams.type() == RequestParams::TResetOriginParams);
|
||||
|
||||
|
@ -1697,10 +1778,14 @@ void ResetOriginOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = ResetOriginResponse();
|
||||
}
|
||||
|
||||
PersistRequestBase::PersistRequestBase(const PrincipalInfo& aPrincipalInfo)
|
||||
: QuotaRequestBase("dom::quota::PersistRequestBase",
|
||||
PersistRequestBase::PersistRequestBase(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const PrincipalInfo& aPrincipalInfo)
|
||||
: QuotaRequestBase(std::move(aQuotaManager),
|
||||
"dom::quota::PersistRequestBase",
|
||||
/* aExclusive */ false),
|
||||
mPrincipalInfo(aPrincipalInfo) {
|
||||
mPrincipalInfo(aPrincipalInfo),
|
||||
mIsPrivate(false) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
mPersistenceType.SetValue(PERSISTENCE_TYPE_DEFAULT);
|
||||
|
@ -1725,8 +1810,10 @@ nsresult PersistRequestBase::DoInit(QuotaManager& aQuotaManager) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PersistedOp::PersistedOp(const RequestParams& aParams)
|
||||
: PersistRequestBase(aParams.get_PersistedParams().principalInfo()),
|
||||
PersistedOp::PersistedOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams)
|
||||
: PersistRequestBase(std::move(aQuotaManager),
|
||||
aParams.get_PersistedParams().principalInfo()),
|
||||
mPersisted(false) {
|
||||
MOZ_ASSERT(aParams.type() == RequestParams::TPersistedParams);
|
||||
}
|
||||
|
@ -1784,8 +1871,10 @@ void PersistedOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = persistedResponse;
|
||||
}
|
||||
|
||||
PersistOp::PersistOp(const RequestParams& aParams)
|
||||
: PersistRequestBase(aParams.get_PersistParams().principalInfo()) {
|
||||
PersistOp::PersistOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams)
|
||||
: PersistRequestBase(std::move(aQuotaManager),
|
||||
aParams.get_PersistParams().principalInfo()) {
|
||||
MOZ_ASSERT(aParams.type() == RequestParams::TPersistParams);
|
||||
}
|
||||
|
||||
|
@ -1865,8 +1954,10 @@ void PersistOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = PersistResponse();
|
||||
}
|
||||
|
||||
EstimateOp::EstimateOp(const EstimateParams& aParams)
|
||||
: QuotaRequestBase("dom::quota::EstimateOp", /* aExclusive */ false),
|
||||
EstimateOp::EstimateOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const EstimateParams& aParams)
|
||||
: QuotaRequestBase(std::move(aQuotaManager), "dom::quota::EstimateOp",
|
||||
/* aExclusive */ false),
|
||||
mParams(aParams) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
@ -1917,8 +2008,9 @@ void EstimateOp::GetResponse(RequestResponse& aResponse) {
|
|||
aResponse = estimateResponse;
|
||||
}
|
||||
|
||||
ListOriginsOp::ListOriginsOp()
|
||||
: QuotaRequestBase("dom::quota::ListOriginsOp", /* aExclusive */ false),
|
||||
ListOriginsOp::ListOriginsOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager)
|
||||
: QuotaRequestBase(std::move(aQuotaManager), "dom::quota::ListOriginsOp",
|
||||
/* aExclusive */ false),
|
||||
TraverseRepositoryHelper() {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,12 @@
|
|||
template <class T>
|
||||
class RefPtr;
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
namespace mozilla {
|
||||
|
||||
template <typename T>
|
||||
class MovingNotNull;
|
||||
|
||||
namespace dom::quota {
|
||||
|
||||
class EstimateParams;
|
||||
class GetFullOriginMetadataParams;
|
||||
|
@ -22,6 +27,7 @@ class NormalOriginOperationBase;
|
|||
class OriginDirectoryLock;
|
||||
struct OriginMetadata;
|
||||
class OriginOperationBase;
|
||||
class QuotaManager;
|
||||
class QuotaRequestBase;
|
||||
class QuotaUsageRequestBase;
|
||||
class RequestParams;
|
||||
|
@ -30,56 +36,85 @@ class ResolvableNormalOriginOp;
|
|||
class UsageRequestParams;
|
||||
|
||||
RefPtr<OriginOperationBase> CreateFinalizeOriginEvictionOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
nsTArray<RefPtr<OriginDirectoryLock>>&& aLocks);
|
||||
|
||||
RefPtr<NormalOriginOperationBase> CreateSaveOriginAccessTimeOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const OriginMetadata& aOriginMetadata, int64_t aTimestamp);
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearPrivateRepositoryOp();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearPrivateRepositoryOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateShutdownStorageOp();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateShutdownStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<QuotaUsageRequestBase> CreateGetUsageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaUsageRequestBase> CreateGetOriginUsageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const UsageRequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateStorageNameOp();
|
||||
RefPtr<QuotaRequestBase> CreateStorageNameOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateStorageInitializedOp();
|
||||
RefPtr<QuotaRequestBase> CreateStorageInitializedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateTemporaryStorageInitializedOp();
|
||||
RefPtr<QuotaRequestBase> CreateTemporaryStorageInitializedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateInitOp();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateInitOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateInitTemporaryStorageOp();
|
||||
RefPtr<QuotaRequestBase> CreateInitTemporaryStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateInitializePersistentOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateInitializeTemporaryOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateGetFullOriginMetadataOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const GetFullOriginMetadataParams& aParams);
|
||||
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearStorageOp();
|
||||
RefPtr<ResolvableNormalOriginOp<bool>> CreateClearStorageOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateClearOriginOp(const RequestParams& aParams);
|
||||
RefPtr<QuotaRequestBase> CreateClearOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateClearDataOp(const RequestParams& aParams);
|
||||
RefPtr<QuotaRequestBase> CreateClearDataOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateResetOriginOp(const RequestParams& aParams);
|
||||
RefPtr<QuotaRequestBase> CreateResetOriginOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreatePersistedOp(const RequestParams& aParams);
|
||||
RefPtr<QuotaRequestBase> CreatePersistedOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreatePersistOp(const RequestParams& aParams);
|
||||
RefPtr<QuotaRequestBase> CreatePersistOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const RequestParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateEstimateOp(const EstimateParams& aParams);
|
||||
RefPtr<QuotaRequestBase> CreateEstimateOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const EstimateParams& aParams);
|
||||
|
||||
RefPtr<QuotaRequestBase> CreateListOriginsOp();
|
||||
RefPtr<QuotaRequestBase> CreateListOriginsOp(
|
||||
MovingNotNull<RefPtr<QuotaManager>> aQuotaManager);
|
||||
|
||||
} // namespace mozilla::dom::quota
|
||||
} // namespace dom::quota
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_QUOTA_ORIGINOPERATIONS_H_
|
||||
|
|
|
@ -323,17 +323,16 @@ PQuotaUsageRequestParent* Quota::AllocPQuotaUsageRequestParent(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated(), nullptr);
|
||||
|
||||
MOZ_ASSERT(QuotaManager::Get());
|
||||
QM_TRY_UNWRAP(const NotNull<RefPtr<QuotaManager>> quotaManager,
|
||||
QuotaManager::GetOrCreate(), nullptr);
|
||||
|
||||
auto actor = [&]() -> RefPtr<QuotaUsageRequestBase> {
|
||||
switch (aParams.type()) {
|
||||
case UsageRequestParams::TAllUsageParams:
|
||||
return CreateGetUsageOp(aParams);
|
||||
return CreateGetUsageOp(quotaManager, aParams);
|
||||
|
||||
case UsageRequestParams::TOriginUsageParams:
|
||||
return CreateGetOriginUsageOp(aParams);
|
||||
return CreateGetOriginUsageOp(quotaManager, aParams);
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Should never get here!");
|
||||
|
@ -342,7 +341,7 @@ PQuotaUsageRequestParent* Quota::AllocPQuotaUsageRequestParent(
|
|||
|
||||
MOZ_ASSERT(actor);
|
||||
|
||||
QuotaManager::Get()->RegisterNormalOriginOp(*actor);
|
||||
quotaManager->RegisterNormalOriginOp(*actor);
|
||||
|
||||
// Transfer ownership to IPDL.
|
||||
return actor.forget().take();
|
||||
|
@ -392,54 +391,53 @@ PQuotaRequestParent* Quota::AllocPQuotaRequestParent(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated(), nullptr);
|
||||
|
||||
MOZ_ASSERT(QuotaManager::Get());
|
||||
QM_TRY_UNWRAP(const NotNull<RefPtr<QuotaManager>> quotaManager,
|
||||
QuotaManager::GetOrCreate(), nullptr);
|
||||
|
||||
auto actor = [&]() -> RefPtr<QuotaRequestBase> {
|
||||
switch (aParams.type()) {
|
||||
case RequestParams::TStorageNameParams:
|
||||
return CreateStorageNameOp();
|
||||
return CreateStorageNameOp(quotaManager);
|
||||
|
||||
case RequestParams::TStorageInitializedParams:
|
||||
return CreateStorageInitializedOp();
|
||||
return CreateStorageInitializedOp(quotaManager);
|
||||
|
||||
case RequestParams::TTemporaryStorageInitializedParams:
|
||||
return CreateTemporaryStorageInitializedOp();
|
||||
return CreateTemporaryStorageInitializedOp(quotaManager);
|
||||
|
||||
case RequestParams::TInitTemporaryStorageParams:
|
||||
return CreateInitTemporaryStorageOp();
|
||||
return CreateInitTemporaryStorageOp(quotaManager);
|
||||
|
||||
case RequestParams::TInitializePersistentOriginParams:
|
||||
return CreateInitializePersistentOriginOp(aParams);
|
||||
return CreateInitializePersistentOriginOp(quotaManager, aParams);
|
||||
|
||||
case RequestParams::TInitializeTemporaryOriginParams:
|
||||
return CreateInitializeTemporaryOriginOp(aParams);
|
||||
return CreateInitializeTemporaryOriginOp(quotaManager, aParams);
|
||||
|
||||
case RequestParams::TGetFullOriginMetadataParams:
|
||||
return CreateGetFullOriginMetadataOp(
|
||||
aParams.get_GetFullOriginMetadataParams());
|
||||
quotaManager, aParams.get_GetFullOriginMetadataParams());
|
||||
|
||||
case RequestParams::TClearOriginParams:
|
||||
return CreateClearOriginOp(aParams);
|
||||
return CreateClearOriginOp(quotaManager, aParams);
|
||||
|
||||
case RequestParams::TResetOriginParams:
|
||||
return CreateResetOriginOp(aParams);
|
||||
return CreateResetOriginOp(quotaManager, aParams);
|
||||
|
||||
case RequestParams::TClearDataParams:
|
||||
return CreateClearDataOp(aParams);
|
||||
return CreateClearDataOp(quotaManager, aParams);
|
||||
|
||||
case RequestParams::TPersistedParams:
|
||||
return CreatePersistedOp(aParams);
|
||||
return CreatePersistedOp(quotaManager, aParams);
|
||||
|
||||
case RequestParams::TPersistParams:
|
||||
return CreatePersistOp(aParams);
|
||||
return CreatePersistOp(quotaManager, aParams);
|
||||
|
||||
case RequestParams::TEstimateParams:
|
||||
return CreateEstimateOp(aParams.get_EstimateParams());
|
||||
return CreateEstimateOp(quotaManager, aParams.get_EstimateParams());
|
||||
|
||||
case RequestParams::TListOriginsParams:
|
||||
return CreateListOriginsOp();
|
||||
return CreateListOriginsOp(quotaManager);
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Should never get here!");
|
||||
|
@ -448,7 +446,7 @@ PQuotaRequestParent* Quota::AllocPQuotaRequestParent(
|
|||
|
||||
MOZ_ASSERT(actor);
|
||||
|
||||
QuotaManager::Get()->RegisterNormalOriginOp(*actor);
|
||||
quotaManager->RegisterNormalOriginOp(*actor);
|
||||
|
||||
// Transfer ownership to IPDL.
|
||||
return actor.forget().take();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "QuotaRequestBase.h"
|
||||
|
||||
#include "mozilla/dom/quota/PQuotaUsageRequest.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
|
|
|
@ -17,17 +17,20 @@ class RequestResponse;
|
|||
class QuotaRequestBase : public NormalOriginOperationBase,
|
||||
public PQuotaRequestParent {
|
||||
protected:
|
||||
QuotaRequestBase(const char* aName, bool aExclusive)
|
||||
: NormalOriginOperationBase(aName, Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(),
|
||||
Nullable<Client::Type>(), aExclusive) {}
|
||||
QuotaRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName, bool aExclusive)
|
||||
: NormalOriginOperationBase(
|
||||
std::move(aQuotaManager), aName, Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(), Nullable<Client::Type>(), aExclusive) {}
|
||||
|
||||
QuotaRequestBase(const char* aName,
|
||||
QuotaRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName,
|
||||
const Nullable<PersistenceType>& aPersistenceType,
|
||||
const OriginScope& aOriginScope,
|
||||
const Nullable<Client::Type>& aClientType, bool aExclusive)
|
||||
: NormalOriginOperationBase(aName, aPersistenceType, aOriginScope,
|
||||
aClientType, aExclusive) {}
|
||||
: NormalOriginOperationBase(std::move(aQuotaManager), aName,
|
||||
aPersistenceType, aOriginScope, aClientType,
|
||||
aExclusive) {}
|
||||
|
||||
// Subclasses use this override to set the IPDL response value.
|
||||
virtual void GetResponse(RequestResponse& aResponse) = 0;
|
||||
|
|
|
@ -26,11 +26,12 @@ class UsageRequestResponse;
|
|||
class QuotaUsageRequestBase : public NormalOriginOperationBase,
|
||||
public PQuotaUsageRequestParent {
|
||||
protected:
|
||||
QuotaUsageRequestBase(const char* aName)
|
||||
: NormalOriginOperationBase(aName, Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(),
|
||||
Nullable<Client::Type>(),
|
||||
/* aExclusive */ false) {}
|
||||
QuotaUsageRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName)
|
||||
: NormalOriginOperationBase(
|
||||
std::move(aQuotaManager), aName, Nullable<PersistenceType>(),
|
||||
OriginScope::FromNull(), Nullable<Client::Type>(),
|
||||
/* aExclusive */ false) {}
|
||||
|
||||
mozilla::Result<UsageInfo, nsresult> GetUsageForOrigin(
|
||||
QuotaManager& aQuotaManager, PersistenceType aPersistenceType,
|
||||
|
|
|
@ -25,13 +25,15 @@ class ResolvableNormalOriginOp : public NormalOriginOperationBase {
|
|||
}
|
||||
|
||||
protected:
|
||||
ResolvableNormalOriginOp(const char* aName,
|
||||
ResolvableNormalOriginOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
|
||||
const char* aName,
|
||||
const Nullable<PersistenceType>& aPersistenceType,
|
||||
const OriginScope& aOriginScope,
|
||||
const Nullable<Client::Type> aClientType,
|
||||
bool aExclusive)
|
||||
: NormalOriginOperationBase(aName, aPersistenceType, aOriginScope,
|
||||
aClientType, aExclusive) {
|
||||
: NormalOriginOperationBase(std::move(aQuotaManager), aName,
|
||||
aPersistenceType, aOriginScope, aClientType,
|
||||
aExclusive) {
|
||||
AssertIsOnOwningThread();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче