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
Родитель 6fbf6cf8f6
Коммит 9776ec5e71
7 изменённых файлов: 120 добавлений и 34 удалений

Просмотреть файл

@ -204,24 +204,13 @@ Sanitizer.prototype = {
offlineApps: {
clear: function ()
{
const Cc = Components.classes;
const Ci = Components.interfaces;
var cacheService = Cc["@mozilla.org/network/cache-service;1"].
getService(Ci.nsICacheService);
try {
// Offline app data is "timeless", and doesn't respect
// the setting of timespan, it always clears everything
cacheService.evictEntries(Ci.nsICache.STORE_OFFLINE);
} catch(er) {}
var storageManagerService = Cc["@mozilla.org/dom/storagemanager;1"].
getService(Ci.nsIDOMStorageManager);
storageManagerService.clearOfflineApps();
Components.utils.import("resource:///modules/offlineAppCache.jsm");
OfflineAppCacheHelper.clear();
},
get canClear()
{
return true;
return true;
}
},

Просмотреть файл

@ -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

Просмотреть файл

@ -234,12 +234,12 @@
</hbox>
</groupbox>
<!-- Cache/Offline apps -->
<groupbox id="offlineGroup">
<caption label="&offlineStorage.label;"/>
<!-- Cache -->
<groupbox id="cacheGroup">
<caption label="&httpCache.label;"/>
<hbox align="center">
<label id="actualCacheSize" flex="1"/>
<label id="actualDiskCacheSize" flex="1"/>
<button id="clearCacheButton" icon="clear"
label="&clearCacheNow.label;" accesskey="&clearCacheNow.accesskey;"
oncommand="gAdvancedPane.clearCache();"/>
@ -260,6 +260,18 @@
aria-labelledby="useCacheBefore cacheSize useCacheAfter"/>
<label id="useCacheAfter" flex="1">&limitCacheSizeAfter.label;</label>
</hbox>
</groupbox>
<!-- Offline apps -->
<groupbox id="offlineGroup">
<caption label="&offlineStorage2.label;"/>
<hbox align="center">
<label id="actualAppCacheSize" flex="1"/>
<button id="clearOfflineAppCacheButton" icon="clear"
label="&clearOfflineAppCacheNow.label;" accesskey="&clearOfflineAppCacheNow.accesskey;"
oncommand="gAdvancedPane.clearOfflineAppCache();"/>
</hbox>
<hbox align="center">
<checkbox id="offlineNotify" flex="1"
label="&offlineNotify.label;" accesskey="&offlineNotify.accesskey;"
@ -272,7 +284,7 @@
</hbox>
<hbox>
<vbox flex="1">
<label id="offlineAppsListLabel">&offlineAppsList.label;</label>
<label id="offlineAppsListLabel">&offlineAppsList2.label;</label>
<listbox id="offlineAppsList"
style="height: &offlineAppsList.height;;"
flex="1"

Просмотреть файл

@ -40,7 +40,9 @@
<!ENTITY connectionSettings.label "Settings…">
<!ENTITY connectionSettings.accesskey "e">
<!ENTITY offlineStorage.label "Offline Storage">
<!ENTITY httpCache.label "Cached Web Content">
<!ENTITY offlineStorage2.label "Offline Web Content and User Data">
<!-- LOCALIZATION NOTE:
The entities limitCacheSizeBefore.label and limitCacheSizeAfter.label appear on a single
@ -53,6 +55,8 @@
<!ENTITY limitCacheSizeAfter.label "MB of space">
<!ENTITY clearCacheNow.label "Clear Now">
<!ENTITY clearCacheNow.accesskey "C">
<!ENTITY clearOfflineAppCacheNow.label "Clear Now">
<!ENTITY clearOfflineAppCacheNow.accesskey "N">
<!ENTITY overrideSmartCacheSize.label "Override automatic cache management">
<!ENTITY overrideSmartCacheSize.accesskey "O">
@ -84,7 +88,7 @@
<!ENTITY offlineNotifyExceptions.label "Exceptions…">
<!ENTITY offlineNotifyExceptions.accesskey "x">
<!ENTITY offlineAppsList.label "The following websites have stored data for offline use:">
<!ENTITY offlineAppsList2.label "The following websites are allowed to store data for offline use:">
<!ENTITY offlineAppsList.height "7em">
<!ENTITY offlineAppsListRemove.label "Remove…">
<!ENTITY offlineAppsListRemove.accesskey "R">

Просмотреть файл

@ -105,11 +105,18 @@ offlinepermissionstext=The following websites are not allowed to store data for
offlinepermissionstitle=Offline Data
####Preferences::Advanced::Network
#LOCALIZATION NOTE: The next string is for the disk usage of the http cache.
# e.g., "Your cache is currently using 200 MB"
#LOCALIZATION NOTE: The next string is for the disk usage of the web content cache.
# e.g., "Your web content cache is currently using 200 MB"
# %1$S = size
# %2$S = unit (MB, KB, etc.)
actualCacheSize=Your cache is currently using %1$S %2$S of disk space
actualDiskCacheSize=Your web content cache is currently using %1$S %2$S of disk space
####Preferences::Advanced::Network
#LOCALIZATION NOTE: The next string is for the disk usage of the application cache.
# e.g., "Your application cache is currently using 200 MB"
# %1$S = size
# %2$S = unit (MB, KB, etc.)
actualAppCacheSize=Your application cache is currently using %1$S %2$S of disk space
syncUnlink.title=Do you want to unlink your device?
syncUnlink.label=This device will no longer be associated with your Sync account. All of your personal data, both on this device and in your Sync account, will remain intact.

Просмотреть файл

@ -51,6 +51,7 @@ endif
EXTRA_JS_MODULES = \
openLocationLastURL.jsm \
NetworkPrioritizer.jsm \
offlineAppCache.jsm \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)

Просмотреть файл

@ -0,0 +1,54 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Honza Bambas <honzab.moz@firemni.cz>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
let EXPORTED_SYMBOLS = ["OfflineAppCacheHelper"];
const Cc = Components.classes;
const Ci = Components.interfaces;
let OfflineAppCacheHelper = {
clear: function() {
var cacheService = Cc["@mozilla.org/network/cache-service;1"].
getService(Ci.nsICacheService);
try {
cacheService.evictEntries(Ci.nsICache.STORE_OFFLINE);
} catch(er) {}
var storageManagerService = Cc["@mozilla.org/dom/storagemanager;1"].
getService(Ci.nsIDOMStorageManager);
storageManagerService.clearOfflineApps();
}
};