зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1373183 - Part 1: Only initialize the temporary storage for estimate(). r=janv
To do this, reuse the code for initializing temporay storage in EnsureOriginIsInitializedInternal(). Thus, create a helper function called EnsureTemporaryStorageIsInitialized() and call it from both side. MozReview-Commit-ID: vNQVteoicH --HG-- extra : rebase_source : bb6101662213b099cbd7974b091c6c5e845b6311
This commit is contained in:
Родитель
a9a9e66e71
Коммит
dd96d219b4
|
@ -5236,46 +5236,11 @@ QuotaManager::EnsureOriginIsInitializedInternal(
|
|||
*aCreated = false;
|
||||
return NS_OK;
|
||||
}
|
||||
} else if (!mTemporaryStorageInitialized) {
|
||||
rv = InitializeRepository(aPersistenceType);
|
||||
} else {
|
||||
rv = EnsureTemporaryStorageIsInitialized(aPersistenceType);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// We have to cleanup partially initialized quota.
|
||||
RemoveQuota();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitializeRepository(ComplementaryPersistenceType(aPersistenceType));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// We have to cleanup partially initialized quota.
|
||||
RemoveQuota();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (gFixedLimitKB >= 0) {
|
||||
mTemporaryStorageLimit = static_cast<uint64_t>(gFixedLimitKB) * 1024;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIFile> storageDir =
|
||||
do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = storageDir->InitWithPath(GetStoragePath());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = GetTemporaryStorageLimit(storageDir, mTemporaryStorageUsage,
|
||||
&mTemporaryStorageLimit);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
mTemporaryStorageInitialized = true;
|
||||
|
||||
CheckTemporaryStorageLimits();
|
||||
}
|
||||
|
||||
bool created;
|
||||
|
@ -5338,6 +5303,62 @@ QuotaManager::EnsureOriginIsInitializedInternal(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
QuotaManager::EnsureTemporaryStorageIsInitialized(
|
||||
PersistenceType aPersistenceType)
|
||||
{
|
||||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(aPersistenceType != PERSISTENCE_TYPE_PERSISTENT);
|
||||
MOZ_ASSERT(mStorageInitialized);
|
||||
|
||||
if (mTemporaryStorageInitialized) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = InitializeRepository(aPersistenceType);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// We have to cleanup partially initialized quota.
|
||||
RemoveQuota();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = InitializeRepository(ComplementaryPersistenceType(aPersistenceType));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// We have to cleanup partially initialized quota.
|
||||
RemoveQuota();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (gFixedLimitKB >= 0) {
|
||||
mTemporaryStorageLimit = static_cast<uint64_t>(gFixedLimitKB) * 1024;
|
||||
} else {
|
||||
nsCOMPtr<nsIFile> storageDir =
|
||||
do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = storageDir->InitWithPath(GetStoragePath());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = GetTemporaryStorageLimit(storageDir, mTemporaryStorageUsage,
|
||||
&mTemporaryStorageLimit);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
mTemporaryStorageInitialized = true;
|
||||
|
||||
CheckTemporaryStorageLimits();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
QuotaManager::OriginClearCompleted(PersistenceType aPersistenceType,
|
||||
const nsACString& aOrigin)
|
||||
|
@ -7148,14 +7169,17 @@ GetOriginUsageOp::DoDirectoryWork(QuotaManager* aQuotaManager)
|
|||
nsresult rv;
|
||||
|
||||
if (mGetGroupUsage) {
|
||||
nsCOMPtr<nsIFile> directory;
|
||||
// Ensure temporary storage is initialized first. It will initialize all
|
||||
// origins for temporary storage including origins belonging to our group by
|
||||
// traversing the repositories. EnsureStorageIsInitialized is needed before
|
||||
// EnsureTemporaryStorageIsInitialized.
|
||||
rv = aQuotaManager->EnsureStorageIsInitialized();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Ensure origin is initialized first. It will initialize all origins for
|
||||
// temporary storage including origins belonging to our group.
|
||||
rv = aQuotaManager->EnsureOriginIsInitialized(PERSISTENCE_TYPE_TEMPORARY,
|
||||
mSuffix, mGroup,
|
||||
mOriginScope.GetOrigin(),
|
||||
getter_AddRefs(directory));
|
||||
rv = aQuotaManager->EnsureTemporaryStorageIsInitialized(
|
||||
PERSISTENCE_TYPE_TEMPORARY);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -298,6 +298,9 @@ public:
|
|||
nsIFile** aDirectory,
|
||||
bool* aCreated);
|
||||
|
||||
nsresult
|
||||
EnsureTemporaryStorageIsInitialized(PersistenceType aPersistenceType);
|
||||
|
||||
void
|
||||
OriginClearCompleted(PersistenceType aPersistenceType,
|
||||
const nsACString& aOrigin);
|
||||
|
|
Загрузка…
Ссылка в новой задаче