Bug 786086 - Make the new default cache size display properly. r=michal

This commit is contained in:
Nick Hurley 2012-10-05 12:29:14 -07:00
parent 5b96566402
commit d158d44f4b

View File

@ -173,8 +173,9 @@ public:
uint32_t currentSize,
bool shouldUseOldMaxSmartSize);
private:
bool PermittedToSmartSize(nsIPrefBranch*, bool firstRun);
private:
bool mHaveProfile;
bool mDiskCacheEnabled;
@ -1595,28 +1596,27 @@ public:
if (!nsCacheService::gService || !nsCacheService::gService->mObserver)
return NS_ERROR_NOT_AVAILABLE;
nsDisableOldMaxSmartSizePrefEvent::DisableOldMaxSmartSizePref(true);
return NS_OK;
}
static void DisableOldMaxSmartSizePref(bool async)
{
nsCOMPtr<nsIPrefBranch> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (!branch) {
return;
return NS_ERROR_NOT_AVAILABLE;
}
nsresult rv = branch->SetBoolPref(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF, false);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to disable old max smart size");
return;
return rv;
}
if (async) {
nsCacheService::SetDiskSmartSize();
} else {
nsCacheService::gService->SetDiskSmartSize_Locked();
nsCacheService::SetDiskSmartSize();
if (nsCacheService::gService->mObserver->PermittedToSmartSize(branch, false)) {
rv = branch->SetIntPref(DISK_CACHE_CAPACITY_PREF, MAX_CACHE_SIZE);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to set cache capacity pref");
}
}
return NS_OK;
}
};
@ -1630,11 +1630,9 @@ nsCacheService::MarkStartingFresh()
gService->mObserver->SetUseNewMaxSmartSize(true);
if (NS_IsMainThread()) {
nsDisableOldMaxSmartSizePrefEvent::DisableOldMaxSmartSizePref(false);
} else {
NS_DispatchToMainThread(new nsDisableOldMaxSmartSizePrefEvent());
}
// We always dispatch an event here because we don't want to deal with lock
// reentrance issues.
NS_DispatchToMainThread(new nsDisableOldMaxSmartSizePrefEvent());
}
nsresult