Bug 865022 - Set the http cache size to match the size of the /cache partition r=vingtetun

This commit is contained in:
Fabrice Desré 2013-05-17 15:57:10 -07:00
parent 00be9ce5e6
commit 99900c7eda

View File

@ -1209,3 +1209,19 @@ Services.obs.addObserver(function(aSubject, aTopic, aData) {
pageURL: data.pageURL
});
}, "activity-done", false);
#ifdef MOZ_WIDGET_GONK
// Devices don't have all the same partition size for /cache where we
// store the http cache.
(function setHTTPCacheSize() {
let path = Services.prefs.getCharPref("browser.cache.disk.parent_directory");
let volumeService = Cc["@mozilla.org/telephony/volume-service;1"]
.getService(Ci.nsIVolumeService);
let stats = volumeService.createOrGetVolumeByPath(path).getStats();
// We must set the size in KB, and keep a bit of free space.
let size = Math.floor(stats.totalBytes / 1024) - 1024;
Services.prefs.setIntPref("browser.cache.disk.capacity", size);
}) ()
#endif