Bug 1781201 - Remove mNeedsQuotaManagerInit from OriginOperationBase; r=hsingh

We now ensure that QuotaManager exists before any operation is created. This is
required because GetInfoFromValidatedPrinciplaInfo can't be a static anymore.

Differential Revision: https://phabricator.services.mozilla.com/D176870
This commit is contained in:
Jan Varga 2023-05-03 02:05:11 +00:00
parent 7e73a61a52
commit f28c9ada6b

View File

@ -816,7 +816,6 @@ class OriginOperationBase : public BackgroundThreadObject, public Runnable {
bool mActorDestroyed; bool mActorDestroyed;
protected: protected:
bool mNeedsQuotaManagerInit;
bool mNeedsStorageInit; bool mNeedsStorageInit;
public: public:
@ -840,7 +839,6 @@ class OriginOperationBase : public BackgroundThreadObject, public Runnable {
mResultCode(NS_OK), mResultCode(NS_OK),
mState(State_Initial), mState(State_Initial),
mActorDestroyed(false), mActorDestroyed(false),
mNeedsQuotaManagerInit(false),
mNeedsStorageInit(false) {} mNeedsStorageInit(false) {}
// Reference counted. // Reference counted.
@ -7263,9 +7261,7 @@ nsresult OriginOperationBase::Init() {
return NS_ERROR_ABORT; return NS_ERROR_ABORT;
} }
if (mNeedsQuotaManagerInit) { MOZ_ASSERT(QuotaManager::Get());
QM_TRY(QuotaManager::EnsureCreated());
}
Open(); Open();
@ -7797,6 +7793,8 @@ PQuotaUsageRequestParent* Quota::AllocPQuotaUsageRequestParent(
return nullptr; return nullptr;
} }
QM_TRY(QuotaManager::EnsureCreated(), nullptr);
auto actor = [&]() -> RefPtr<QuotaUsageRequestBase> { auto actor = [&]() -> RefPtr<QuotaUsageRequestBase> {
switch (aParams.type()) { switch (aParams.type()) {
case UsageRequestParams::TAllUsageParams: case UsageRequestParams::TAllUsageParams:
@ -7864,6 +7862,8 @@ PQuotaRequestParent* Quota::AllocPQuotaRequestParent(
return nullptr; return nullptr;
} }
QM_TRY(QuotaManager::EnsureCreated(), nullptr);
auto actor = [&]() -> RefPtr<QuotaRequestBase> { auto actor = [&]() -> RefPtr<QuotaRequestBase> {
switch (aParams.type()) { switch (aParams.type()) {
case RequestParams::TStorageNameParams: case RequestParams::TStorageNameParams:
@ -8038,7 +8038,6 @@ mozilla::ipc::IPCResult Quota::RecvAbortOperationsForProcess(
void QuotaUsageRequestBase::Init(Quota& aQuota) { void QuotaUsageRequestBase::Init(Quota& aQuota) {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = true; mNeedsStorageInit = true;
} }
@ -8368,7 +8367,6 @@ GetOriginUsageOp::GetOriginUsageOp(const UsageRequestParams& aParams)
mFromMemory = params.fromMemory(); mFromMemory = params.fromMemory();
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = true; mNeedsStorageInit = true;
} }
@ -8442,7 +8440,6 @@ void GetOriginUsageOp::GetResponse(UsageRequestResponse& aResponse) {
void QuotaRequestBase::Init(Quota& aQuota) { void QuotaRequestBase::Init(Quota& aQuota) {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = true; mNeedsStorageInit = true;
} }
@ -8477,7 +8474,6 @@ StorageNameOp::StorageNameOp()
AssertIsOnOwningThread(); AssertIsOnOwningThread();
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = false; mNeedsStorageInit = false;
} }
@ -8511,7 +8507,6 @@ InitializedRequestBase::InitializedRequestBase(const char* aRunnableName)
AssertIsOnOwningThread(); AssertIsOnOwningThread();
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = false; mNeedsStorageInit = false;
} }
@ -8567,7 +8562,6 @@ InitOp::InitOp()
AssertIsOnOwningThread(); AssertIsOnOwningThread();
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = false; mNeedsStorageInit = false;
} }
@ -8595,7 +8589,6 @@ InitTemporaryStorageOp::InitTemporaryStorageOp()
AssertIsOnOwningThread(); AssertIsOnOwningThread();
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = false; mNeedsStorageInit = false;
} }
@ -8632,7 +8625,6 @@ InitializeOriginRequestBase::InitializeOriginRequestBase(
MOZ_ASSERT(principalMetadata.mOrigin == principalMetadata.mStorageOrigin); MOZ_ASSERT(principalMetadata.mOrigin == principalMetadata.mStorageOrigin);
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = false; mNeedsStorageInit = false;
// Overwrite NormalOriginOperationBase default values. // Overwrite NormalOriginOperationBase default values.
@ -8773,7 +8765,6 @@ ResetOrClearOp::ResetOrClearOp(bool aClear)
AssertIsOnOwningThread(); AssertIsOnOwningThread();
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = false; mNeedsStorageInit = false;
} }
@ -9186,7 +9177,6 @@ ResetOriginOp::ResetOriginOp(const RequestParams& aParams)
QuotaManager::GetOriginFromValidatedPrincipalInfo(params.principalInfo()); QuotaManager::GetOriginFromValidatedPrincipalInfo(params.principalInfo());
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = false; mNeedsStorageInit = false;
// Overwrite NormalOriginOperationBase default values. // Overwrite NormalOriginOperationBase default values.
@ -9393,7 +9383,6 @@ EstimateOp::EstimateOp(const EstimateParams& aParams)
AssertIsOnOwningThread(); AssertIsOnOwningThread();
// Overwrite OriginOperationBase default values. // Overwrite OriginOperationBase default values.
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = true; mNeedsStorageInit = true;
} }
@ -9437,7 +9426,6 @@ ListOriginsOp::ListOriginsOp()
void ListOriginsOp::Init(Quota& aQuota) { void ListOriginsOp::Init(Quota& aQuota) {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
mNeedsQuotaManagerInit = true;
mNeedsStorageInit = true; mNeedsStorageInit = true;
} }