Use 1 GB cache size while we wait for the smart size event. r=jst, a=beta7

This commit is contained in:
Jason Duell 2010-09-29 16:41:03 -07:00
parent bb69c203d1
commit 3fdec5a382

View File

@ -606,6 +606,9 @@ nsCacheProfilePrefObserver::PermittedToSmartSize(nsIPrefBranch* branch, PRBool
return false;
}
}
// Set manual setting to MAX cache size as starting val for any
// adjustment by user: (bug 559942 comment 65)
branch->SetIntPref(DISK_CACHE_CAPACITY_PREF, MAX_CACHE_SIZE);
}
PRBool smartSizeEnabled;
rv = branch->GetBoolPref(DISK_CACHE_SMART_SIZE_ENABLED_PREF,
@ -680,17 +683,21 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
if (NS_FAILED(rv))
firstSmartSizeRun = PR_FALSE;
if (PermittedToSmartSize(branch, firstSmartSizeRun)) {
// Prevent unnecessary eviction before smart size event returns
// Avoid evictions: use previous cache size while we wait for smart
// size event to update mDiskCacheCapacity
if (!firstSmartSizeRun) {
PRInt32 oldSmartSize;
rv = branch->GetIntPref(DISK_CACHE_SMART_SIZE_PREF,
&oldSmartSize);
mDiskCacheCapacity = oldSmartSize;
} else {
rv = branch->SetIntPref(DISK_CACHE_CAPACITY_PREF,
MAX_CACHE_SIZE);
if (NS_FAILED(rv))
NS_WARNING("Failed setting capacity pref");
PRInt32 oldCapacity;
rv = branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &oldCapacity);
if (NS_SUCCEEDED(rv)) {
mDiskCacheCapacity = oldCapacity;
} else {
mDiskCacheCapacity = DEFAULT_CACHE_SIZE;
}
}
nsCOMPtr<nsIRunnable> event =
new nsGetSmartSizeEvent(!!firstSmartSizeRun);