зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1645051 - Calculated smart max cache size shouldn't overwrite browser.cache.disk.capacity pref r=necko-reviewers,mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D83377
This commit is contained in:
Родитель
01241894f0
Коммит
0e25e01126
|
@ -760,6 +760,13 @@
|
|||
value: true
|
||||
mirror: always
|
||||
|
||||
# Disk cache capacity in kilobytes. It's used only when
|
||||
# browser.cache.disk.smart_size.enabled == false
|
||||
- name: browser.cache.disk.capacity
|
||||
type: RelaxedAtomicUint32
|
||||
value: 256000
|
||||
mirror: always
|
||||
|
||||
# Enable/Disable Origin based cache isolation
|
||||
- name: browser.cache.cache_isolation
|
||||
type: RelaxedAtomicBool
|
||||
|
|
|
@ -241,9 +241,6 @@ pref("general.warnOnAboutConfig", true);
|
|||
// maximum number of dated backups to keep at any time
|
||||
pref("browser.bookmarks.max_backups", 5);
|
||||
|
||||
// Size (in KB) explicitly set by the user. Used when smart_size.enabled == false
|
||||
pref("browser.cache.disk.capacity", 256000);
|
||||
|
||||
pref("browser.cache.disk_cache_ssl", true);
|
||||
// The half life used to re-compute cache entries frecency in hours.
|
||||
pref("browser.cache.frecency_half_life_hours", 6);
|
||||
|
|
|
@ -4132,7 +4132,7 @@ nsresult CacheFileIOManager::UpdateSmartCacheSize(int64_t aFreeSpace) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
CacheObserver::SetDiskCacheCapacity(smartSize);
|
||||
CacheObserver::SetSmartDiskCacheCapacity(smartSize);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -29,9 +29,11 @@ float CacheObserver::sHalfLifeHours = kDefaultHalfLifeHours;
|
|||
// Cache of the calculated memory capacity based on the system memory size in KB
|
||||
int32_t CacheObserver::sAutoMemoryCacheCapacity = -1;
|
||||
|
||||
static uint32_t const kDefaultDiskCacheCapacity = 250 * 1024; // 250 MB
|
||||
Atomic<uint32_t, Relaxed> CacheObserver::sDiskCacheCapacity(
|
||||
kDefaultDiskCacheCapacity);
|
||||
// The default value will be overwritten as soon as the correct smart size is
|
||||
// calculated by CacheFileIOManager::UpdateSmartCacheSize(). It's limited to 1GB
|
||||
// just for case the size is never calculated which might in theory happen if
|
||||
// GetDiskSpaceAvailable() always fails.
|
||||
Atomic<uint32_t, Relaxed> CacheObserver::sSmartDiskCacheCapacity(1024 * 1024);
|
||||
|
||||
static bool kDefaultCacheFSReported = false;
|
||||
bool CacheObserver::sCacheFSReported = kDefaultCacheFSReported;
|
||||
|
@ -87,10 +89,6 @@ nsresult CacheObserver::Shutdown() {
|
|||
}
|
||||
|
||||
void CacheObserver::AttachToPreferences() {
|
||||
mozilla::Preferences::AddAtomicUintVarCache(&sDiskCacheCapacity,
|
||||
"browser.cache.disk.capacity",
|
||||
kDefaultDiskCacheCapacity);
|
||||
|
||||
mozilla::Preferences::GetComplex(
|
||||
"browser.cache.disk.parent_directory", NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(mCacheParentDirectoryOverride));
|
||||
|
@ -140,26 +138,14 @@ uint32_t CacheObserver::MemoryCacheCapacity() {
|
|||
}
|
||||
|
||||
// static
|
||||
void CacheObserver::SetDiskCacheCapacity(uint32_t aCapacity) {
|
||||
sDiskCacheCapacity = aCapacity;
|
||||
|
||||
if (!sSelf) {
|
||||
return;
|
||||
void CacheObserver::SetSmartDiskCacheCapacity(uint32_t aCapacity) {
|
||||
sSmartDiskCacheCapacity = aCapacity;
|
||||
}
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
sSelf->StoreDiskCacheCapacity();
|
||||
} else {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NewRunnableMethod("net::CacheObserver::StoreDiskCacheCapacity",
|
||||
sSelf.get(), &CacheObserver::StoreDiskCacheCapacity);
|
||||
NS_DispatchToMainThread(event);
|
||||
}
|
||||
}
|
||||
|
||||
void CacheObserver::StoreDiskCacheCapacity() {
|
||||
mozilla::Preferences::SetInt("browser.cache.disk.capacity",
|
||||
sDiskCacheCapacity);
|
||||
// static
|
||||
uint32_t CacheObserver::DiskCacheCapacity() {
|
||||
return SmartCacheSizeEnabled() ? sSmartDiskCacheCapacity
|
||||
: StaticPrefs::browser_cache_disk_capacity();
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -38,11 +38,8 @@ class CacheObserver : public nsIObserver, public nsSupportsWeakReference {
|
|||
return StaticPrefs::browser_cache_disk_metadata_memory_limit();
|
||||
}
|
||||
static uint32_t MemoryCacheCapacity(); // result in kilobytes.
|
||||
static uint32_t DiskCacheCapacity() // result in kilobytes.
|
||||
{
|
||||
return sDiskCacheCapacity;
|
||||
}
|
||||
static void SetDiskCacheCapacity(uint32_t); // parameter in kilobytes.
|
||||
static uint32_t DiskCacheCapacity(); // result in kilobytes.
|
||||
static void SetSmartDiskCacheCapacity(uint32_t); // parameter in kilobytes.
|
||||
static uint32_t DiskFreeSpaceSoftLimit() // result in kilobytes.
|
||||
{
|
||||
return StaticPrefs::browser_cache_disk_free_space_soft_limit();
|
||||
|
@ -103,14 +100,13 @@ class CacheObserver : public nsIObserver, public nsSupportsWeakReference {
|
|||
private:
|
||||
static StaticRefPtr<CacheObserver> sSelf;
|
||||
|
||||
void StoreDiskCacheCapacity();
|
||||
void StoreCacheFSReported();
|
||||
void StoreHashStatsReported();
|
||||
void StoreCacheAmountWritten();
|
||||
void AttachToPreferences();
|
||||
|
||||
static int32_t sAutoMemoryCacheCapacity;
|
||||
static Atomic<uint32_t, Relaxed> sDiskCacheCapacity;
|
||||
static Atomic<uint32_t, Relaxed> sSmartDiskCacheCapacity;
|
||||
static float sHalfLifeHours;
|
||||
static bool sCacheFSReported;
|
||||
static bool sHashStatsReported;
|
||||
|
|
Загрузка…
Ссылка в новой задаче