Bug 538588 - Split offline storage into http and offline cache in advanced network preferences dialog

This commit is contained in:
Michal Novotny
2011-12-16 23:36:09 +01:00
parent 206e5976ce
commit 2a319d10e9
7 changed files with 120 additions and 34 deletions

View File

@@ -68,7 +68,8 @@ var gAdvancedPane = {
#ifdef MOZ_CRASHREPORTER
this.initSubmitCrashes();
#endif
this.updateActualCacheSize();
this.updateActualCacheSize("disk");
this.updateActualCacheSize("offline");
},
/**
@@ -202,18 +203,22 @@ var gAdvancedPane = {
"", null);
},
// Retrieves the amount of space currently used by disk cache
updateActualCacheSize: function ()
// Retrieves the amount of space currently used by disk or offline cache
updateActualCacheSize: function (device)
{
var visitor = {
visitDevice: function (deviceID, deviceInfo)
{
if (deviceID == "disk") {
var actualSizeLabel = document.getElementById("actualCacheSize");
if (deviceID == device) {
var actualSizeLabel = document.getElementById(device == "disk" ?
"actualDiskCacheSize" :
"actualAppCacheSize");
var sizeStrings = DownloadUtils.convertByteUnits(deviceInfo.totalSize);
var prefStrBundle = document.getElementById("bundlePreferences");
var sizeStr = prefStrBundle.getFormattedString("actualCacheSize",
sizeStrings);
var sizeStr = prefStrBundle.getFormattedString(device == "disk" ?
"actualDiskCacheSize" :
"actualAppCacheSize",
sizeStrings);
actualSizeLabel.value = sizeStr;
}
// Do not enumerate entries
@@ -226,6 +231,7 @@ var gAdvancedPane = {
return false;
}
};
var cacheService =
Components.classes["@mozilla.org/network/cache-service;1"]
.getService(Components.interfaces.nsICacheService);
@@ -274,11 +280,23 @@ var gAdvancedPane = {
clearCache: function ()
{
var cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
.getService(Components.interfaces.nsICacheService);
.getService(Components.interfaces.nsICacheService);
try {
cacheService.evictEntries(Components.interfaces.nsICache.STORE_ANYWHERE);
} catch(ex) {}
this.updateActualCacheSize();
this.updateActualCacheSize("disk");
},
/**
* Clears the application cache.
*/
clearOfflineAppCache: function ()
{
Components.utils.import("resource:///modules/offlineAppCache.jsm");
OfflineAppCacheHelper.clear();
this.updateActualCacheSize("offline");
this.updateOfflineApps();
},
readOfflineNotify: function()
@@ -432,6 +450,7 @@ var gAdvancedPane = {
list.removeChild(item);
gAdvancedPane.offlineAppSelected();
this.updateActualCacheSize("offline");
},
// UPDATE TAB