mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1781201 - Convert GetInfoFromValidatedPrincipalInfo to a non-static method; r=hsingh
The method will need to access members of the QuotaManager class, so it can't be static anymore. Differential Revision: https://phabricator.services.mozilla.com/D176872
This commit is contained in:
parent
573fdf0764
commit
989747c705
18
dom/cache/Context.cpp
vendored
18
dom/cache/Context.cpp
vendored
@ -357,20 +357,20 @@ Context::QuotaInitRunnable::Run() {
|
||||
break;
|
||||
}
|
||||
|
||||
mDirectoryMetadata.emplace(
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(*mPrincipalInfo));
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated(), QM_PROPAGATE,
|
||||
[&resolver](const auto rv) { resolver->Resolve(rv); });
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(QuotaManager::Get());
|
||||
auto* const quotaManager = QuotaManager::Get();
|
||||
MOZ_DIAGNOSTIC_ASSERT(quotaManager);
|
||||
|
||||
mDirectoryMetadata.emplace(
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(*mPrincipalInfo));
|
||||
|
||||
// Open directory
|
||||
RefPtr<DirectoryLock> directoryLock =
|
||||
QuotaManager::Get()->CreateDirectoryLock(PERSISTENCE_TYPE_DEFAULT,
|
||||
*mDirectoryMetadata,
|
||||
quota::Client::DOMCACHE,
|
||||
/* aExclusive */ false);
|
||||
RefPtr<DirectoryLock> directoryLock = quotaManager->CreateDirectoryLock(
|
||||
PERSISTENCE_TYPE_DEFAULT, *mDirectoryMetadata,
|
||||
quota::Client::DOMCACHE,
|
||||
/* aExclusive */ false);
|
||||
|
||||
// DirectoryLock::Acquire() will hold a reference to us as a listener. We
|
||||
// will then get DirectoryLockAcquired() on the owning thread when it is
|
||||
|
@ -38,8 +38,14 @@ mozilla::ipc::IPCResult CreateFileSystemManagerParent(
|
||||
IPC_OK(),
|
||||
[aResolver](const auto&) { aResolver(NS_ERROR_DOM_SECURITY_ERR); });
|
||||
|
||||
QM_TRY(quota::QuotaManager::EnsureCreated(), IPC_OK(),
|
||||
[aResolver](const auto&) { aResolver(NS_ERROR_FAILURE); });
|
||||
|
||||
auto* const quotaManager = quota::QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
quota::OriginMetadata originMetadata(
|
||||
quota::QuotaManager::GetInfoFromValidatedPrincipalInfo(aPrincipalInfo),
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(aPrincipalInfo),
|
||||
quota::PERSISTENCE_TYPE_DEFAULT);
|
||||
|
||||
// Block use for now in PrivateBrowsing
|
||||
|
@ -214,9 +214,8 @@ FileSystemDataManager::GetOrCreateFileSystemDataManager(
|
||||
Registered<FileSystemDataManager>(std::move(dataManager)), __func__);
|
||||
}
|
||||
|
||||
QM_TRY_UNWRAP(RefPtr<quota::QuotaManager> quotaManager,
|
||||
quota::QuotaManager::GetOrCreate(),
|
||||
CreatePromise::CreateAndReject(NS_ERROR_FAILURE, __func__));
|
||||
RefPtr<quota::QuotaManager> quotaManager = quota::QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
QM_TRY_UNWRAP(auto streamTransportService,
|
||||
MOZ_TO_RESULT_GET_TYPED(nsCOMPtr<nsIEventTarget>,
|
||||
|
@ -14922,6 +14922,11 @@ nsresult FactoryOp::FinishOpen() {
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated());
|
||||
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
const PrincipalInfo& principalInfo = mCommonParams.principalInfo();
|
||||
|
||||
const DatabaseMetadata& metadata = mCommonParams.metadata();
|
||||
@ -14938,7 +14943,7 @@ nsresult FactoryOp::FinishOpen() {
|
||||
MOZ_ASSERT(principalInfo.type() == PrincipalInfo::TContentPrincipalInfo);
|
||||
|
||||
mOriginMetadata = {
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(principalInfo),
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(principalInfo),
|
||||
persistenceType};
|
||||
|
||||
mEnforcingQuota = persistenceType != PERSISTENCE_TYPE_PERSISTENT;
|
||||
@ -14950,11 +14955,6 @@ nsresult FactoryOp::FinishOpen() {
|
||||
mDatabaseId.Append('*');
|
||||
mDatabaseId.Append(NS_ConvertUTF16toUTF8(metadata.name()));
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated());
|
||||
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
// Need to get database file path before opening the directory.
|
||||
// XXX: For what reason?
|
||||
QM_TRY_UNWRAP(
|
||||
|
@ -6654,6 +6654,8 @@ nsresult PrepareDatastoreOp::Start() {
|
||||
MOZ_ASSERT(!QuotaClient::IsShuttingDownOnBackgroundThread());
|
||||
MOZ_ASSERT(MayProceed());
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated());
|
||||
|
||||
const LSRequestCommonParams& commonParams =
|
||||
mForPreload
|
||||
? mParams.get_LSRequestPreloadDatastoreParams().commonParams()
|
||||
@ -6670,7 +6672,8 @@ nsresult PrepareDatastoreOp::Start() {
|
||||
PrincipalInfo::TContentPrincipalInfo);
|
||||
|
||||
PrincipalMetadata principalMetadata =
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(storagePrincipalInfo);
|
||||
QuotaManager::Get()->GetInfoFromValidatedPrincipalInfo(
|
||||
storagePrincipalInfo);
|
||||
|
||||
mOriginMetadata.mSuffix = std::move(principalMetadata.mSuffix);
|
||||
mOriginMetadata.mGroup = std::move(principalMetadata.mGroup);
|
||||
@ -6840,10 +6843,11 @@ nsresult PrepareDatastoreOp::BeginDatastorePreparationInternal() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated());
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
// Open directory
|
||||
mPendingDirectoryLock = QuotaManager::Get()->CreateDirectoryLock(
|
||||
mPendingDirectoryLock = quotaManager->CreateDirectoryLock(
|
||||
PERSISTENCE_TYPE_DEFAULT, mOriginMetadata,
|
||||
mozilla::dom::quota::Client::LS,
|
||||
/* aExclusive */ false);
|
||||
|
@ -6420,7 +6420,6 @@ bool QuotaManager::IsPrincipalInfoValid(const PrincipalInfo& aPrincipalInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
PrincipalMetadata QuotaManager::GetInfoFromValidatedPrincipalInfo(
|
||||
const PrincipalInfo& aPrincipalInfo) {
|
||||
MOZ_ASSERT(IsPrincipalInfoValid(aPrincipalInfo));
|
||||
@ -8352,10 +8351,13 @@ GetOriginUsageOp::GetOriginUsageOp(const UsageRequestParams& aParams)
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(aParams.type() == UsageRequestParams::TOriginUsageParams);
|
||||
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
const OriginUsageParams& params = aParams.get_OriginUsageParams();
|
||||
|
||||
PrincipalMetadata principalMetadata =
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(params.principalInfo());
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(params.principalInfo());
|
||||
MOZ_ASSERT(principalMetadata.mOrigin == principalMetadata.mStorageOrigin);
|
||||
|
||||
mSuffix = std::move(principalMetadata.mSuffix);
|
||||
@ -8620,8 +8622,11 @@ InitializeOriginRequestBase::InitializeOriginRequestBase(
|
||||
mCreated(false) {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
auto principalMetadata =
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(aPrincipalInfo);
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(aPrincipalInfo);
|
||||
MOZ_ASSERT(principalMetadata.mOrigin == principalMetadata.mStorageOrigin);
|
||||
|
||||
// Overwrite OriginOperationBase default values.
|
||||
@ -8723,7 +8728,7 @@ GetFullOriginMetadataOp::GetFullOriginMetadataOp(
|
||||
const GetFullOriginMetadataParams& aParams)
|
||||
: QuotaRequestBase("dom::quota::GetFullOriginMetadataOp",
|
||||
/* aExclusive */ false),
|
||||
mOriginMetadata(QuotaManager::GetInfoFromValidatedPrincipalInfo(
|
||||
mOriginMetadata(QuotaManager::Get()->GetInfoFromValidatedPrincipalInfo(
|
||||
aParams.principalInfo()),
|
||||
aParams.persistenceType()) {
|
||||
AssertIsOnOwningThread();
|
||||
@ -9225,9 +9230,12 @@ void PersistRequestBase::Init(Quota& aQuota) {
|
||||
|
||||
mPersistenceType.SetValue(PERSISTENCE_TYPE_DEFAULT);
|
||||
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
// Figure out which origin we're dealing with.
|
||||
PrincipalMetadata principalMetadata =
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(mPrincipalInfo);
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(mPrincipalInfo);
|
||||
MOZ_ASSERT(principalMetadata.mOrigin == principalMetadata.mStorageOrigin);
|
||||
|
||||
mSuffix = std::move(principalMetadata.mSuffix);
|
||||
@ -9377,7 +9385,7 @@ void PersistOp::GetResponse(RequestResponse& aResponse) {
|
||||
|
||||
EstimateOp::EstimateOp(const EstimateParams& aParams)
|
||||
: QuotaRequestBase("dom::quota::EstimateOp", /* aExclusive */ false),
|
||||
mOriginMetadata(QuotaManager::GetInfoFromValidatedPrincipalInfo(
|
||||
mOriginMetadata(QuotaManager::Get()->GetInfoFromValidatedPrincipalInfo(
|
||||
aParams.principalInfo()),
|
||||
PERSISTENCE_TYPE_DEFAULT) {
|
||||
AssertIsOnOwningThread();
|
||||
@ -9767,6 +9775,9 @@ nsresult StorageOperationBase::ProcessOriginDirectories() {
|
||||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(!mOriginProps.IsEmpty());
|
||||
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
#ifdef QM_PRINCIPALINFO_VERIFICATION_ENABLED
|
||||
nsTArray<PrincipalInfo> principalInfos;
|
||||
#endif
|
||||
@ -9815,7 +9826,7 @@ nsresult StorageOperationBase::ProcessOriginDirectories() {
|
||||
PrincipalInfo principalInfo(contentPrincipalInfo);
|
||||
|
||||
originProps.mOriginMetadata = {
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(principalInfo),
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(principalInfo),
|
||||
*originProps.mPersistenceType};
|
||||
|
||||
#ifdef QM_PRINCIPALINFO_VERIFICATION_ENABLED
|
||||
|
@ -419,7 +419,7 @@ class QuotaManager final : public BackgroundThreadObject {
|
||||
|
||||
static bool IsPrincipalInfoValid(const PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
static PrincipalMetadata GetInfoFromValidatedPrincipalInfo(
|
||||
PrincipalMetadata GetInfoFromValidatedPrincipalInfo(
|
||||
const PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
static nsAutoCString GetOriginFromValidatedPrincipalInfo(
|
||||
|
@ -864,6 +864,8 @@ PBackgroundSDBRequestParent* Connection::AllocPBackgroundSDBRequestParent(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated(), nullptr);
|
||||
|
||||
RefPtr<ConnectionOperationBase> actor;
|
||||
|
||||
switch (aParams.type()) {
|
||||
@ -1098,6 +1100,9 @@ nsresult OpenOp::FinishOpen() {
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
const PrincipalInfo& principalInfo = GetConnection()->GetPrincipalInfo();
|
||||
|
||||
PersistenceType persistenceType = GetConnection()->GetPersistenceType();
|
||||
@ -1108,7 +1113,7 @@ nsresult OpenOp::FinishOpen() {
|
||||
MOZ_ASSERT(principalInfo.type() == PrincipalInfo::TContentPrincipalInfo);
|
||||
|
||||
mOriginMetadata = {
|
||||
QuotaManager::GetInfoFromValidatedPrincipalInfo(principalInfo),
|
||||
quotaManager->GetInfoFromValidatedPrincipalInfo(principalInfo),
|
||||
persistenceType};
|
||||
}
|
||||
|
||||
@ -1121,16 +1126,12 @@ nsresult OpenOp::FinishOpen() {
|
||||
}
|
||||
}
|
||||
|
||||
QM_TRY(QuotaManager::EnsureCreated());
|
||||
|
||||
// Open the directory
|
||||
MOZ_ASSERT(QuotaManager::Get());
|
||||
|
||||
RefPtr<DirectoryLock> directoryLock =
|
||||
QuotaManager::Get()->CreateDirectoryLock(
|
||||
GetConnection()->GetPersistenceType(), mOriginMetadata,
|
||||
mozilla::dom::quota::Client::SDB,
|
||||
/* aExclusive */ false);
|
||||
RefPtr<DirectoryLock> directoryLock = quotaManager->CreateDirectoryLock(
|
||||
GetConnection()->GetPersistenceType(), mOriginMetadata,
|
||||
mozilla::dom::quota::Client::SDB,
|
||||
/* aExclusive */ false);
|
||||
|
||||
mState = State::DirectoryOpenPending;
|
||||
directoryLock->Acquire(this);
|
||||
|
Loading…
Reference in New Issue
Block a user