mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Backed out changeset 502977d27c28 (bug 1313003) for eslint failure
This commit is contained in:
parent
26e9c3ad6d
commit
9dbf7d04bf
@ -1,154 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = [
|
||||
"SiteDataManager"
|
||||
];
|
||||
|
||||
this.SiteDataManager = {
|
||||
|
||||
_qms: Services.qms,
|
||||
|
||||
_diskCache: Services.cache2.diskCacheStorage(Services.loadContextInfo.default, false),
|
||||
|
||||
_appCache: Cc["@mozilla.org/network/application-cache-service;1"].getService(Ci.nsIApplicationCacheService),
|
||||
|
||||
// A Map of sites using the persistent-storage API (have requested persistent-storage permission)
|
||||
// Key is site's origin.
|
||||
// Value is one object holding:
|
||||
// - perm: persistent-storage permision; instance of nsIPermission
|
||||
// - status: the permission granted/rejected status
|
||||
// - quotaUsage: the usage of indexedDB and localStorage.
|
||||
// - appCacheList: an array of app cache; instances of nsIApplicationCache
|
||||
// - diskCacheList: an array. Each element is object holding metadata of http cache:
|
||||
// - dataSize: that http cache size
|
||||
// - idEnhance: the id extension of that http cache
|
||||
_sites: new Map(),
|
||||
|
||||
_updateQuotaPromise: null,
|
||||
|
||||
_updateDiskCachePromise: null,
|
||||
|
||||
_quotaUsageRequests: null,
|
||||
|
||||
updateSites() {
|
||||
// Clear old data and requests first
|
||||
this._sites.clear();
|
||||
this._cancelQuotaUpdate();
|
||||
|
||||
// Collect sites granted/rejected with the persistent-storage permission
|
||||
let perm = null;
|
||||
let status = null;
|
||||
let e = Services.perms.enumerator;
|
||||
while (e.hasMoreElements()) {
|
||||
perm = e.getNext();
|
||||
status = Services.perms.testExactPermissionFromPrincipal(perm.principal, "persistent-storage");
|
||||
if (status === Ci.nsIPermissionManager.ALLOW_ACTION ||
|
||||
status === Ci.nsIPermissionManager.DENY_ACTION) {
|
||||
this._sites.set(perm.principal.origin, {
|
||||
perm: perm,
|
||||
status: status,
|
||||
quotaUsage: 0,
|
||||
appCacheList: [],
|
||||
diskCacheList: []
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this._updateQuota();
|
||||
this._updateAppCache();
|
||||
this._updateDiskCache();
|
||||
},
|
||||
|
||||
_updateQuota() {
|
||||
this._quotaUsageRequests = [];
|
||||
let promises = [];
|
||||
for (let [key, site] of this._sites) { // eslint-disable-line no-unused-vars
|
||||
promises.push(new Promise(resolve => {
|
||||
let callback = {
|
||||
onUsageResult: function (request) {
|
||||
site.quotaUsage = request.usage;
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
// XXX: The work of integrating localStorage into Quota Manager is in progress.
|
||||
// After the bug 742822 and 1286798 landed, localStorage usage will be included.
|
||||
// So currently only get indexedDB usage.
|
||||
this._quotaUsageRequests.push(
|
||||
this._qms.getUsageForPrincipal(site.perm.principal, callback));
|
||||
}));
|
||||
}
|
||||
this._updateQuotaPromise = Promise.all(promises);
|
||||
},
|
||||
|
||||
_cancelQuotaUpdate() {
|
||||
if (this._quotaUsageRequests) {
|
||||
for (let request of this._quotaUsageRequests) {
|
||||
request.cancel();
|
||||
}
|
||||
this._quotaUsageRequests = null;
|
||||
}
|
||||
},
|
||||
|
||||
_updateAppCache() {
|
||||
let groups = this._appCache.getGroups();
|
||||
for (let [key, site] of this._sites) { // eslint-disable-line no-unused-vars
|
||||
for (let group of groups) {
|
||||
let uri = Services.io.newURI(group, null, null);
|
||||
if (site.perm.matchesURI(uri, true)) {
|
||||
let cache = this._appCache.getActiveCache(group);
|
||||
site.appCacheList.push(cache);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_updateDiskCache() {
|
||||
this._updateDiskCachePromise = new Promise(resolve => {
|
||||
if (this._sites.size) {
|
||||
let sites = this._sites;
|
||||
let visitor = {
|
||||
onCacheEntryInfo: function (uri, idEnhance, dataSize) {
|
||||
for (let [key, site] of sites) { // eslint-disable-line no-unused-vars
|
||||
if (site.perm.matchesURI(uri, true)) {
|
||||
site.diskCacheList.push({
|
||||
dataSize,
|
||||
idEnhance
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
onCacheEntryVisitCompleted: function () {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
this._diskCache.asyncVisitStorage(visitor, true);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getTotalUsage() {
|
||||
return Promise.all([this._updateQuotaPromise, this._updateDiskCachePromise])
|
||||
.then(() => {
|
||||
let usage = 0;
|
||||
for (let [key, site] of this._sites) { // eslint-disable-line no-unused-vars
|
||||
let cache = null;
|
||||
for (cache of site.appCacheList) {
|
||||
usage += cache.usage;
|
||||
}
|
||||
for (cache of site.diskCacheList) {
|
||||
usage += cache.dataSize;
|
||||
}
|
||||
usage += site.quotaUsage;
|
||||
}
|
||||
return usage;
|
||||
});
|
||||
},
|
||||
};
|
@ -7,9 +7,6 @@ Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/LoadContextInfo.jsm");
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SiteDataManager",
|
||||
"resource:///modules/SiteDataManager.jsm");
|
||||
|
||||
const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
|
||||
|
||||
var gAdvancedPane = {
|
||||
@ -55,11 +52,6 @@ var gAdvancedPane = {
|
||||
this.updateActualCacheSize();
|
||||
this.updateActualAppCacheSize();
|
||||
|
||||
if (Services.prefs.getBoolPref("browser.storageManager.enabled")) {
|
||||
SiteDataManager.updateSites();
|
||||
this.updateTotalSiteDataSize();
|
||||
}
|
||||
|
||||
setEventListener("layers.acceleration.disabled", "change",
|
||||
gAdvancedPane.updateHardwareAcceleration);
|
||||
setEventListener("advancedPrefs", "select",
|
||||
@ -337,18 +329,6 @@ var gAdvancedPane = {
|
||||
gSubDialog.open("chrome://browser/content/preferences/connection.xul");
|
||||
},
|
||||
|
||||
updateTotalSiteDataSize: function () {
|
||||
SiteDataManager.getTotalUsage()
|
||||
.then(usage => {
|
||||
let size = DownloadUtils.convertByteUnits(usage);
|
||||
let prefStrBundle = document.getElementById("bundlePreferences");
|
||||
let totalSiteDataSizeLabel = document.getElementById("totalSiteDataSize");
|
||||
totalSiteDataSizeLabel.textContent = prefStrBundle.getFormattedString("totalSiteDataSize", size);
|
||||
let siteDataGroup = document.getElementById("siteDataGroup");
|
||||
siteDataGroup.hidden = false;
|
||||
});
|
||||
},
|
||||
|
||||
// Retrieves the amount of space currently used by disk cache
|
||||
updateActualCacheSize: function()
|
||||
{
|
||||
|
@ -328,15 +328,6 @@
|
||||
</vbox>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
<!-- Site Data -->
|
||||
<groupbox id="siteDataGroup" hidden="true">
|
||||
<caption><label>&siteData.label;</label></caption>
|
||||
|
||||
<hbox align="center">
|
||||
<label id="totalSiteDataSize" flex="1"></label>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</tabpanel>
|
||||
|
||||
<!-- Update -->
|
||||
|
@ -18,9 +18,5 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'SiteDataManager.jsm',
|
||||
]
|
||||
|
||||
with Files('**'):
|
||||
BUG_COMPONENT = ('Firefox', 'Preferences')
|
||||
|
@ -57,9 +57,6 @@
|
||||
|
||||
<!ENTITY offlineStorage2.label "Offline Web Content and User Data">
|
||||
|
||||
<!-- Site Data section manages sites using Storage API and is under Network -->
|
||||
<!ENTITY siteData.label "Site Data">
|
||||
|
||||
<!-- LOCALIZATION NOTE:
|
||||
The entities limitCacheSizeBefore.label and limitCacheSizeAfter.label appear on a single
|
||||
line in preferences as follows:
|
||||
|
@ -164,13 +164,6 @@ actualDiskCacheSizeCalculated=Calculating web content cache size…
|
||||
# %2$S = unit (MB, KB, etc.)
|
||||
actualAppCacheSize=Your application cache is currently using %1$S %2$S of disk space
|
||||
|
||||
####Preferences::Advanced::Network
|
||||
#LOCALIZATION NOTE: The next string is for the total usage of site data.
|
||||
# e.g., "The total usage is currently using 200 MB"
|
||||
# %1$S = size
|
||||
# %2$S = unit (MB, KB, etc.)
|
||||
totalSiteDataSize=Your stored site data 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.
|
||||
syncUnlinkConfirm.label=Unlink
|
||||
|
@ -5532,8 +5532,3 @@ pref("dom.storageManager.enabled", true);
|
||||
#else
|
||||
pref("dom.storageManager.enabled", false);
|
||||
#endif
|
||||
|
||||
// Enable the Storage management in about:preferences and persistent-storage permission request
|
||||
// To enable the DOM implementation, turn on "dom.storageManager.enabled"
|
||||
pref("browser.storageManager.enabled", false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user