Bug 1697115 - Rationalize QuotaManager::ResetUsageForClient arguments; r=dom-storage-reviewers,sg

Differential Revision: https://phabricator.services.mozilla.com/D107616
This commit is contained in:
Jan Varga 2021-03-17 06:56:39 +00:00
Родитель b59182de8d
Коммит c546aae9a0
3 изменённых файлов: 13 добавлений и 14 удалений

Просмотреть файл

@ -5052,8 +5052,8 @@ void Datastore::ConnectionClosedCallback() {
QuotaManager* quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager);
quotaManager->ResetUsageForClient(PERSISTENCE_TYPE_DEFAULT, mOriginMetadata,
mozilla::dom::quota::Client::LS);
quotaManager->ResetUsageForClient(
ClientMetadata{mOriginMetadata, mozilla::dom::quota::Client::LS});
}
mConnection = nullptr;

Просмотреть файл

@ -3920,28 +3920,27 @@ void QuotaManager::DecreaseUsageForClient(const ClientMetadata& aClientMetadata,
}
}
void QuotaManager::ResetUsageForClient(PersistenceType aPersistenceType,
const OriginMetadata& aOriginMetadata,
Client::Type aClientType) {
void QuotaManager::ResetUsageForClient(const ClientMetadata& aClientMetadata) {
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aPersistenceType != PERSISTENCE_TYPE_PERSISTENT);
MOZ_ASSERT(IsBestEffortPersistenceType(aClientMetadata.mPersistenceType));
MutexAutoLock lock(mQuotaMutex);
GroupInfoPair* pair;
if (!mGroupInfoPairs.Get(aOriginMetadata.mGroup, &pair)) {
if (!mGroupInfoPairs.Get(aClientMetadata.mGroup, &pair)) {
return;
}
RefPtr<GroupInfo> groupInfo = pair->LockedGetGroupInfo(aPersistenceType);
RefPtr<GroupInfo> groupInfo =
pair->LockedGetGroupInfo(aClientMetadata.mPersistenceType);
if (!groupInfo) {
return;
}
RefPtr<OriginInfo> originInfo =
groupInfo->LockedGetOriginInfo(aOriginMetadata.mOrigin);
groupInfo->LockedGetOriginInfo(aClientMetadata.mOrigin);
if (originInfo) {
originInfo->LockedResetUsageForClient(aClientType);
originInfo->LockedResetUsageForClient(aClientMetadata.mClientType);
}
}
@ -8989,6 +8988,8 @@ void ClearRequestBase::DeleteFiles(QuotaManager& aQuotaManager,
const auto& metadata,
aQuotaManager.LoadFullOriginMetadataWithRestore(file));
MOZ_ASSERT(metadata.mPersistenceType == aPersistenceType);
if (!mClientType.IsNull()) {
nsAutoString clientDirectoryName;
QM_TRY(OkIf(Client::TypeToText(mClientType.Value(),
@ -9031,7 +9032,7 @@ void ClearRequestBase::DeleteFiles(QuotaManager& aQuotaManager,
metadata);
} else {
aQuotaManager.ResetUsageForClient(
aPersistenceType, metadata, mClientType.Value());
ClientMetadata{metadata, mClientType.Value()});
}
}

Просмотреть файл

@ -171,9 +171,7 @@ class QuotaManager final : public BackgroundThreadObject {
void DecreaseUsageForClient(const ClientMetadata& aClientMetadata,
int64_t aSize);
void ResetUsageForClient(PersistenceType aPersistenceType,
const OriginMetadata& aOriginMetadata,
Client::Type aClientType);
void ResetUsageForClient(const ClientMetadata& aClientMetadata);
UsageInfo GetUsageForClient(PersistenceType aPersistenceType,
const OriginMetadata& aOriginMetadata,