зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1526891 - Part 17: Remove initialization on main thread from quota request parent actors; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D20926
This commit is contained in:
Родитель
d4e6cf1df0
Коммит
93fc3f1b66
|
@ -652,12 +652,6 @@ class OriginOperationBase : public BackgroundThreadObject, public Runnable {
|
|||
// Not yet run.
|
||||
State_Initial,
|
||||
|
||||
// Running initialization on the main thread.
|
||||
State_Initializing,
|
||||
|
||||
// Running initialization on the owning thread.
|
||||
State_FinishingInit,
|
||||
|
||||
// Running quota manager initialization on the owning thread.
|
||||
State_CreatingQuotaManager,
|
||||
|
||||
|
@ -724,12 +718,6 @@ class OriginOperationBase : public BackgroundThreadObject, public Runnable {
|
|||
void AdvanceState() {
|
||||
switch (mState) {
|
||||
case State_Initial:
|
||||
mState = State_Initializing;
|
||||
return;
|
||||
case State_Initializing:
|
||||
mState = State_FinishingInit;
|
||||
return;
|
||||
case State_FinishingInit:
|
||||
mState = State_CreatingQuotaManager;
|
||||
return;
|
||||
case State_CreatingQuotaManager:
|
||||
|
@ -752,8 +740,6 @@ class OriginOperationBase : public BackgroundThreadObject, public Runnable {
|
|||
NS_IMETHOD
|
||||
Run() override;
|
||||
|
||||
virtual nsresult DoInitOnMainThread() { return NS_OK; }
|
||||
|
||||
virtual void Open() = 0;
|
||||
|
||||
nsresult DirectoryOpen();
|
||||
|
@ -767,8 +753,6 @@ class OriginOperationBase : public BackgroundThreadObject, public Runnable {
|
|||
private:
|
||||
nsresult Init();
|
||||
|
||||
nsresult InitOnMainThread();
|
||||
|
||||
nsresult FinishInit();
|
||||
|
||||
nsresult QuotaManagerOpen();
|
||||
|
@ -991,8 +975,6 @@ class GetOriginUsageOp final : public QuotaUsageRequestBase {
|
|||
private:
|
||||
~GetOriginUsageOp() {}
|
||||
|
||||
MOZ_IS_CLASS_INIT virtual nsresult DoInitOnMainThread() override;
|
||||
|
||||
virtual nsresult DoDirectoryWork(QuotaManager* aQuotaManager) override;
|
||||
|
||||
void GetResponse(UsageRequestResponse& aResponse) override;
|
||||
|
@ -1062,8 +1044,6 @@ class InitOriginOp final : public QuotaRequestBase {
|
|||
private:
|
||||
~InitOriginOp() {}
|
||||
|
||||
nsresult DoInitOnMainThread() override;
|
||||
|
||||
nsresult DoDirectoryWork(QuotaManager* aQuotaManager) override;
|
||||
|
||||
void GetResponse(RequestResponse& aResponse) override;
|
||||
|
@ -1115,8 +1095,6 @@ class ClearOriginOp final : public ClearRequestBase {
|
|||
private:
|
||||
~ClearOriginOp() {}
|
||||
|
||||
nsresult DoInitOnMainThread() override;
|
||||
|
||||
void GetResponse(RequestResponse& aResponse) override;
|
||||
};
|
||||
|
||||
|
@ -1131,8 +1109,6 @@ class ClearDataOp final : public ClearRequestBase {
|
|||
private:
|
||||
~ClearDataOp() {}
|
||||
|
||||
nsresult DoInitOnMainThread() override;
|
||||
|
||||
void GetResponse(RequestResponse& aResponse) override;
|
||||
};
|
||||
|
||||
|
@ -1148,9 +1124,6 @@ class PersistRequestBase : public QuotaRequestBase {
|
|||
|
||||
protected:
|
||||
explicit PersistRequestBase(const PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
private:
|
||||
nsresult DoInitOnMainThread() override;
|
||||
};
|
||||
|
||||
class PersistedOp final : public PersistRequestBase {
|
||||
|
@ -6033,16 +6006,6 @@ OriginOperationBase::Run() {
|
|||
break;
|
||||
}
|
||||
|
||||
case State_Initializing: {
|
||||
rv = InitOnMainThread();
|
||||
break;
|
||||
}
|
||||
|
||||
case State_FinishingInit: {
|
||||
rv = FinishInit();
|
||||
break;
|
||||
}
|
||||
|
||||
case State_CreatingQuotaManager: {
|
||||
rv = QuotaManagerOpen();
|
||||
break;
|
||||
|
@ -6110,38 +6073,6 @@ nsresult OriginOperationBase::Init() {
|
|||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mState == State_Initial);
|
||||
|
||||
AdvanceState();
|
||||
|
||||
if (mNeedsMainThreadInit) {
|
||||
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(this));
|
||||
} else {
|
||||
AdvanceState();
|
||||
MOZ_ALWAYS_SUCCEEDS(Run());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult OriginOperationBase::InitOnMainThread() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mState == State_Initializing);
|
||||
|
||||
nsresult rv = DoInitOnMainThread();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
AdvanceState();
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult OriginOperationBase::FinishInit() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mState == State_FinishingInit);
|
||||
|
||||
if (QuotaManager::IsShuttingDown()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -7068,36 +6999,14 @@ bool GetOriginUsageOp::Init(Quota* aQuota) {
|
|||
return false;
|
||||
}
|
||||
|
||||
mNeedsMainThreadInit = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult GetOriginUsageOp::DoInitOnMainThread() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(GetState() == State_Initializing);
|
||||
MOZ_ASSERT(mNeedsMainThreadInit);
|
||||
|
||||
const PrincipalInfo& principalInfo = mParams.principalInfo();
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
PrincipalInfoToPrincipal(principalInfo, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Figure out which origin we're dealing with.
|
||||
nsCString origin;
|
||||
rv =
|
||||
QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, &origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(mParams.principalInfo(),
|
||||
&mSuffix, &mGroup, &origin);
|
||||
|
||||
mOriginScope.SetFromOrigin(origin);
|
||||
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult GetOriginUsageOp::DoDirectoryWork(QuotaManager* aQuotaManager) {
|
||||
|
@ -7254,36 +7163,14 @@ bool InitOriginOp::Init(Quota* aQuota) {
|
|||
|
||||
mPersistenceType.SetValue(mParams.persistenceType());
|
||||
|
||||
mNeedsMainThreadInit = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult InitOriginOp::DoInitOnMainThread() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(GetState() == State_Initializing);
|
||||
MOZ_ASSERT(mNeedsMainThreadInit);
|
||||
|
||||
const PrincipalInfo& principalInfo = mParams.principalInfo();
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
PrincipalInfoToPrincipal(principalInfo, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Figure out which origin we're dealing with.
|
||||
nsCString origin;
|
||||
rv =
|
||||
QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, &origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(mParams.principalInfo(),
|
||||
&mSuffix, &mGroup, &origin);
|
||||
|
||||
mOriginScope.SetFromOrigin(origin);
|
||||
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult InitOriginOp::DoDirectoryWork(QuotaManager* aQuotaManager) {
|
||||
|
@ -7587,37 +7474,10 @@ bool ClearOriginOp::Init(Quota* aQuota) {
|
|||
mPersistenceType.SetValue(mParams.persistenceType());
|
||||
}
|
||||
|
||||
if (mParams.clientTypeIsExplicit()) {
|
||||
MOZ_ASSERT(mParams.clientType() != Client::TYPE_MAX);
|
||||
|
||||
mClientType.SetValue(mParams.clientType());
|
||||
}
|
||||
|
||||
mNeedsMainThreadInit = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult ClearOriginOp::DoInitOnMainThread() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(GetState() == State_Initializing);
|
||||
MOZ_ASSERT(mNeedsMainThreadInit);
|
||||
|
||||
const PrincipalInfo& principalInfo = mParams.principalInfo();
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
PrincipalInfoToPrincipal(principalInfo, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Figure out which origin we're dealing with.
|
||||
nsCString origin;
|
||||
rv = QuotaManager::GetInfoFromPrincipal(principal, nullptr, nullptr, &origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(mParams.principalInfo(),
|
||||
nullptr, nullptr, &origin);
|
||||
|
||||
if (mParams.matchAll()) {
|
||||
mOriginScope.SetFromPrefix(origin);
|
||||
|
@ -7625,7 +7485,13 @@ nsresult ClearOriginOp::DoInitOnMainThread() {
|
|||
mOriginScope.SetFromOrigin(origin);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
if (mParams.clientTypeIsExplicit()) {
|
||||
MOZ_ASSERT(mParams.clientType() != Client::TYPE_MAX);
|
||||
|
||||
mClientType.SetValue(mParams.clientType());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClearOriginOp::GetResponse(RequestResponse& aResponse) {
|
||||
|
@ -7653,21 +7519,11 @@ bool ClearDataOp::Init(Quota* aQuota) {
|
|||
return false;
|
||||
}
|
||||
|
||||
mNeedsMainThreadInit = true;
|
||||
mOriginScope.SetFromPattern(mParams.pattern());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult ClearDataOp::DoInitOnMainThread() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(GetState() == State_Initializing);
|
||||
MOZ_ASSERT(mNeedsMainThreadInit);
|
||||
|
||||
mOriginScope.SetFromJSONPattern(mParams.pattern());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void ClearDataOp::GetResponse(RequestResponse& aResponse) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
|
@ -7689,34 +7545,14 @@ bool PersistRequestBase::Init(Quota* aQuota) {
|
|||
|
||||
mPersistenceType.SetValue(PERSISTENCE_TYPE_DEFAULT);
|
||||
|
||||
mNeedsMainThreadInit = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult PersistRequestBase::DoInitOnMainThread() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(GetState() == State_Initializing);
|
||||
MOZ_ASSERT(mNeedsMainThreadInit);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
PrincipalInfoToPrincipal(mPrincipalInfo, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Figure out which origin we're dealing with.
|
||||
nsCString origin;
|
||||
rv =
|
||||
QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, &origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(mPrincipalInfo, &mSuffix,
|
||||
&mGroup, &origin);
|
||||
|
||||
mOriginScope.SetFromOrigin(origin);
|
||||
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
PersistedOp::PersistedOp(const RequestParams& aParams)
|
||||
|
|
|
@ -10,6 +10,9 @@ include PBackgroundSharedTypes;
|
|||
|
||||
include "mozilla/dom/quota/SerializationHelpers.h";
|
||||
|
||||
using mozilla::OriginAttributesPattern
|
||||
from "mozilla/OriginAttributes.h";
|
||||
|
||||
using mozilla::dom::quota::PersistenceType
|
||||
from "mozilla/dom/quota/PersistenceType.h";
|
||||
|
||||
|
@ -76,7 +79,7 @@ struct ResetOriginParams
|
|||
|
||||
struct ClearDataParams
|
||||
{
|
||||
nsString pattern;
|
||||
OriginAttributesPattern pattern;
|
||||
};
|
||||
|
||||
struct ClearAllParams
|
||||
|
|
|
@ -573,11 +573,14 @@ QuotaManagerService::ClearStoragesForOriginAttributesPattern(
|
|||
const nsAString& aPattern, nsIQuotaRequest** _retval) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
OriginAttributesPattern pattern;
|
||||
MOZ_ALWAYS_TRUE(pattern.Init(aPattern));
|
||||
|
||||
RefPtr<Request> request = new Request();
|
||||
|
||||
ClearDataParams params;
|
||||
|
||||
params.pattern() = aPattern;
|
||||
params.pattern() = pattern;
|
||||
|
||||
nsAutoPtr<PendingRequestInfo> info(new RequestInfo(request, params));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче