Bug 647391 - Increase maximum size for objects stored in disk cache.
authorMichal Novotny <michal.novotny@gmail.com>
Tue, 13 Sep 2011 21:24:01 +0200
changeset 78231 d13840232672f0b92c0d79f8448a6c1a5fd4f5b5
parent 78230 2705abe8d3f22d1516c3f2c5a79533f0cadabb52
child 78232 0ddd115a921caed3ef666c13554aa78ecb287954
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs647391
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 647391 - Increase maximum size for objects stored in disk cache.
modules/libpref/src/init/all.js
netwerk/cache/nsCacheService.h
netwerk/test/unit/test_bug654926.js
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -59,26 +59,26 @@ pref("general.warnOnAboutConfig", true);
 // maximum number of dated backups to keep at any time
 pref("browser.bookmarks.max_backups",       5);
 
 pref("browser.cache.disk.enable",           true);
 // Is this the first-time smartsizing has been introduced?
 pref("browser.cache.disk.smart_size.first_run", true);
 // Does the user want smart-sizing?
 pref("browser.cache.disk.smart_size.enabled", true);
-// Size explicitly set by the user. Used when smart_size.enabled == false
+// Size (in KB) explicitly set by the user. Used when smart_size.enabled == false
 pref("browser.cache.disk.capacity",         256000);
-// User-controllable max-size for entries in disk-cache. Regardless of this
-// setting, no entries bigger than 1/8 of disk-cache will be cached
-pref("browser.cache.disk.max_entry_size",    5120);
+// Max-size (in KB) for entries in disk cache. Set to -1 for no limit.
+// (Note: entries bigger than 1/8 of disk-cache are never cached)
+pref("browser.cache.disk.max_entry_size",    51200);  // 50 MB
 pref("browser.cache.memory.enable",         true);
 // -1 = determine dynamically, 0 = none, n = memory capacity in kilobytes
 //pref("browser.cache.memory.capacity",     -1);
-// User-controllable max-size for entries in mem-cache. Regardless of this
-// setting, no entries bigger than 90% of the mem-cache will be cached
+// Max-size (in KB) for entries in memory cache. Set to -1 for no limit.  
+// (Note: entries bigger than than 90% of the mem-cache are never cached)
 pref("browser.cache.memory.max_entry_size",  5120);
 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);
 
 pref("browser.cache.offline.enable",           true);
 
 // offline cache capacity in kilobytes
--- a/netwerk/cache/nsCacheService.h
+++ b/netwerk/cache/nsCacheService.h
@@ -158,19 +158,21 @@ public:
      * Methods called by nsCacheProfilePrefObserver
      */
     static void      OnProfileShutdown(PRBool cleanse);
     static void      OnProfileChanged();
 
     static void      SetDiskCacheEnabled(PRBool  enabled);
     // Sets the disk cache capacity (in kilobytes)
     static void      SetDiskCacheCapacity(PRInt32  capacity);
-    // Set max size for a disk-cache entry (in bytes). -1 disables this limit
+    // Set max size for a disk-cache entry (in KB). -1 disables limit up to
+    // 1/8th of disk cache size
     static void      SetDiskCacheMaxEntrySize(PRInt32  maxSize);
-    // Set max size for a memory-cache entry (in bytes). -1 disables this limit
+    // Set max size for a memory-cache entry (in kilobytes). -1 disables
+    // limit up to 90% of memory cache size
     static void      SetMemoryCacheMaxEntrySize(PRInt32  maxSize);
 
     static void      SetOfflineCacheEnabled(PRBool  enabled);
     // Sets the offline cache capacity (in kilobytes)
     static void      SetOfflineCacheCapacity(PRInt32  capacity);
 
     static void      SetMemoryCache();
 
--- a/netwerk/test/unit/test_bug654926.js
+++ b/netwerk/test/unit/test_bug654926.js
@@ -6,16 +6,25 @@ var _CSvc;
 function get_cache_service() {
   if (_CSvc)
     return _CSvc;
 
   return _CSvc = Cc["@mozilla.org/network/cache-service;1"].
                  getService(Ci.nsICacheService);
 }
 
+var _PSvc;
+function get_pref_service() {
+  if (_PSvc)
+    return _PSvc;
+
+  return _PSvc = Cc["@mozilla.org/preferences-service;1"].
+                 getService(Ci.nsIPrefBranch);
+}
+
 function get_ostream_for_entry(key, asFile, append, entryRef)
 {
   var cache = get_cache_service();
   var session = cache.createSession(
                   "HTTP",
                   asFile ? Ci.nsICache.STORE_ON_DISK_AS_FILE
                          : Ci.nsICache.STORE_ON_DISK,
                   Ci.nsICache.STREAM_BASED);
@@ -74,19 +83,23 @@ function write_and_check(str, data, len)
 }
 
 function write_datafile()
 {
   var entry = {};
   var oStr = get_ostream_for_entry("data", true, false, entry);
   var data = gen_1MiB();
 
-  // 6MiB
+  // max size in MB
+  var max_size = get_pref_service().
+                 getIntPref("browser.cache.disk.max_entry_size") / 1024;
+
+  // write larger entry than is allowed
   var i;
-  for (i=0 ; i<6 ; i++)
+  for (i=0 ; i<(max_size+1) ; i++)
     write_and_check(oStr, data, data.length);
 
   oStr.close();
   entry.value.close();
 
   // wait until writing is done, then append to entry
   sync_with_cache_IO_thread(append_datafile);
 }