From 0912179ccc3e35d8e21a4912041897700410ccc1 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 11 Jul 2019 04:40:17 +0000 Subject: [PATCH] Bug 1562305 - Make browser.cache.disk.metadata_memory_limit a static pref. r=michal Differential Revision: https://phabricator.services.mozilla.com/D37179 --HG-- extra : moz-landing-system : lando --- modules/libpref/init/StaticPrefList.h | 8 ++++++++ modules/libpref/init/all.js | 2 -- netwerk/cache2/CacheObserver.cpp | 7 ------- netwerk/cache2/CacheObserver.h | 3 +-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index 32a1ea6b3936..ce0498539860 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -726,6 +726,14 @@ VARCACHE_PREF( RelaxedAtomicBool, true ) +// Limit of recent metadata we keep in memory for faster access, in KB. +VARCACHE_PREF( + Live, + "browser.cache.disk.metadata_memory_limit", + browser_cache_disk_metadata_memory_limit, + RelaxedAtomicUint32, 250 // 0.25 MB +) + // Whether Content Blocking Third-Party Cookies UI has been enabled. VARCACHE_PREF( Live, diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 5133c94f777b..768486d8a89c 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -62,8 +62,6 @@ pref("browser.cache.disk.max_priority_chunks_memory_usage", 40960); pref("browser.cache.disk_cache_ssl", true); // 0 = once-per-session, 1 = each-time, 2 = never, 3 = when-appropriate/automatically pref("browser.cache.check_doc_frequency", 3); -// Limit of recent metadata we keep in memory for faster access, in Kb -pref("browser.cache.disk.metadata_memory_limit", 250); // 0.25 MB // The number of chunks we preload ahead of read. One chunk has currently 256kB. pref("browser.cache.disk.preload_chunk_count", 4); // 1 MB of read ahead // The half life used to re-compute cache entries frecency in hours. diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index d58e70d1c2e5..d6e09582dcc4 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -26,9 +26,6 @@ StaticRefPtr CacheObserver::sSelf; static float const kDefaultHalfLifeHours = 24.0F; // 24 hours float CacheObserver::sHalfLifeHours = kDefaultHalfLifeHours; -static uint32_t const kDefaultMetadataMemoryLimit = 250; // 0.25 MB -uint32_t CacheObserver::sMetadataMemoryLimit = kDefaultMetadataMemoryLimit; - static int32_t const kDefaultMemoryCacheCapacity = -1; // autodetect int32_t CacheObserver::sMemoryCacheCapacity = kDefaultMemoryCacheCapacity; // Cache of the calculated memory capacity based on the system memory size in KB @@ -140,10 +137,6 @@ nsresult CacheObserver::Shutdown() { } void CacheObserver::AttachToPreferences() { - mozilla::Preferences::AddUintVarCache( - &sMetadataMemoryLimit, "browser.cache.disk.metadata_memory_limit", - kDefaultMetadataMemoryLimit); - mozilla::Preferences::AddAtomicUintVarCache(&sDiskCacheCapacity, "browser.cache.disk.capacity", kDefaultDiskCacheCapacity); diff --git a/netwerk/cache2/CacheObserver.h b/netwerk/cache2/CacheObserver.h index 454731f6aed8..082ff9913124 100644 --- a/netwerk/cache2/CacheObserver.h +++ b/netwerk/cache2/CacheObserver.h @@ -34,7 +34,7 @@ class CacheObserver : public nsIObserver, public nsSupportsWeakReference { } static uint32_t MetadataMemoryLimit() // result in kilobytes. { - return sMetadataMemoryLimit; + return StaticPrefs::browser_cache_disk_metadata_memory_limit(); } static uint32_t MemoryCacheCapacity(); // result in kilobytes. static uint32_t DiskCacheCapacity() // result in kilobytes. @@ -103,7 +103,6 @@ class CacheObserver : public nsIObserver, public nsSupportsWeakReference { void StoreCacheAmountWritten(); void AttachToPreferences(); - static uint32_t sMetadataMemoryLimit; static int32_t sMemoryCacheCapacity; static int32_t sAutoMemoryCacheCapacity; static Atomic sDiskCacheCapacity;