Bug 1415342 - Part 1 - Move OfflineAppCacheHelper to Toolkit. r?standard8 draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 12 Apr 2018 19:16:02 +0200
changeset 785163 28f6a97f3f0ce213520600b41f91a9b38a11bb99
parent 785162 1ad181e92d42c847aa64bee0f36b9f47b27800db
child 785164 56d6e3ac981a5e4aa37acdc4db1ac9064d401a21
push id107162
push usermozilla@buttercookie.de
push dateThu, 19 Apr 2018 19:01:06 +0000
reviewersstandard8
bugs1415342
milestone61.0a1
Bug 1415342 - Part 1 - Move OfflineAppCacheHelper to Toolkit. r?standard8 The OfflineAppCacheHelper was apparently introduced after the Sanitizer had been forked for Fennec and so far nobody bothered to use it there as well. MozReview-Commit-ID: 42Uk5hfvf9y
browser/base/content/test/general/browser_offlineQuotaNotification.js
browser/components/preferences/in-content/tests/siteData/head.js
browser/modules/Sanitizer.jsm
browser/modules/SiteDataManager.jsm
browser/modules/moz.build
browser/modules/offlineAppCache.jsm
mobile/android/modules/Sanitizer.jsm
toolkit/modules/moz.build
toolkit/modules/offlineAppCache.jsm
--- a/browser/base/content/test/general/browser_offlineQuotaNotification.js
+++ b/browser/base/content/test/general/browser_offlineQuotaNotification.js
@@ -10,17 +10,17 @@ const URL = "http://mochi.test:8888/brow
 
 registerCleanupFunction(function() {
   // Clean up after ourself
   let uri = Services.io.newURI(URL);
   let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
   Services.perms.removeFromPrincipal(principal, "offline-app");
   Services.prefs.clearUserPref("offline-apps.quota.warn");
   Services.prefs.clearUserPref("offline-apps.allow_by_default");
-  let {OfflineAppCacheHelper} = ChromeUtils.import("resource:///modules/offlineAppCache.jsm", {});
+  let {OfflineAppCacheHelper} = ChromeUtils.import("resource://gre/modules/offlineAppCache.jsm", {});
   OfflineAppCacheHelper.clear();
 });
 
 // Same as the other one, but for in-content preferences
 function checkInContentPreferences(win) {
   let doc = win.document;
   let sel = doc.getElementById("categories").selectedItems[0].id;
   is(gBrowser.currentURI.spec, "about:preferences#privacy", "about:preferences loaded");
--- a/browser/components/preferences/in-content/tests/siteData/head.js
+++ b/browser/components/preferences/in-content/tests/siteData/head.js
@@ -10,17 +10,17 @@ const TEST_OFFLINE_HOST = "example.org";
 const TEST_OFFLINE_ORIGIN = "https://" + TEST_OFFLINE_HOST;
 const TEST_OFFLINE_URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", TEST_OFFLINE_ORIGIN) + "/offline/offline.html";
 const TEST_SERVICE_WORKER_URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", TEST_OFFLINE_ORIGIN) + "/service_worker_test.html";
 
 const REMOVE_DIALOG_URL = "chrome://browser/content/preferences/siteDataRemoveSelected.xul";
 
 const { DownloadUtils } = ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm", {});
 const { SiteDataManager } = ChromeUtils.import("resource:///modules/SiteDataManager.jsm", {});
-const { OfflineAppCacheHelper } = ChromeUtils.import("resource:///modules/offlineAppCache.jsm", {});
+const { OfflineAppCacheHelper } = ChromeUtils.import("resource://gre/modules/offlineAppCache.jsm", {});
 
 ChromeUtils.defineModuleGetter(this, "SiteDataTestUtils",
                                "resource://testing-common/SiteDataTestUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "serviceWorkerManager", "@mozilla.org/serviceworkers/manager;1", "nsIServiceWorkerManager");
 
 function promiseSiteDataManagerSitesUpdated() {
   return TestUtils.topicObserved("sitedatamanager:sites-updated", () => true);
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -12,17 +12,17 @@ XPCOMUtils.defineLazyModuleGetters(this,
   AppConstants: "resource://gre/modules/AppConstants.jsm",
   PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
   FormHistory: "resource://gre/modules/FormHistory.jsm",
   Downloads: "resource://gre/modules/Downloads.jsm",
   DownloadsCommon: "resource:///modules/DownloadsCommon.jsm",
   TelemetryStopwatch: "resource://gre/modules/TelemetryStopwatch.jsm",
   setTimeout: "resource://gre/modules/Timer.jsm",
   ServiceWorkerCleanUp: "resource://gre/modules/ServiceWorkerCleanUp.jsm",
-  OfflineAppCacheHelper: "resource:///modules/offlineAppCache.jsm",
+  OfflineAppCacheHelper: "resource://gre/modules/offlineAppCache.jsm",
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "sas",
                                    "@mozilla.org/storage/activity-service;1",
                                    "nsIStorageActivityService");
 XPCOMUtils.defineLazyServiceGetter(this, "quotaManagerService",
                                    "@mozilla.org/dom/quota-manager-service;1",
                                    "nsIQuotaManagerService");
--- a/browser/modules/SiteDataManager.jsm
+++ b/browser/modules/SiteDataManager.jsm
@@ -1,15 +1,15 @@
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 ChromeUtils.defineModuleGetter(this, "OfflineAppCacheHelper",
-                               "resource:///modules/offlineAppCache.jsm");
+                               "resource://gre/modules/offlineAppCache.jsm");
 ChromeUtils.defineModuleGetter(this, "ServiceWorkerCleanUp",
                                "resource://gre/modules/ServiceWorkerCleanUp.jsm");
 
 var EXPORTED_SYMBOLS = [
   "SiteDataManager"
 ];
 
 XPCOMUtils.defineLazyGetter(this, "gStringBundle", function() {
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -104,19 +104,16 @@ with Files("Windows8WindowFrameColor.jsm
     BUG_COMPONENT = ("Firefox", "Theme")
 
 with Files("WindowsJumpLists.jsm"):
     BUG_COMPONENT = ("Firefox", "Shell Integration")
 
 with Files("WindowsPreviewPerTab.jsm"):
     BUG_COMPONENT = ("Core", "Widget: Win32")
 
-with Files("offlineAppCache.jsm"):
-    BUG_COMPONENT = ("Firefox", "Preferences")
-
 with Files("webrtcUI.jsm"):
     BUG_COMPONENT = ("Firefox", "Device Permissions")
 
 with Files("ZoomUI.jsm"):
     BUG_COMPONENT = ("Firefox", "Toolbars and Customization")
 
 
 BROWSER_CHROME_MANIFESTS += [
@@ -142,17 +139,16 @@ EXTRA_JS_MODULES += [
     'ContentSearch.jsm',
     'ContentWebRTC.jsm',
     'ContextMenu.jsm',
     'ExtensionsUI.jsm',
     'Feeds.jsm',
     'FormSubmitObserver.jsm',
     'FormValidationHandler.jsm',
     'LaterRun.jsm',
-    'offlineAppCache.jsm',
     'OpenInTabsUtils.jsm',
     'PageActions.jsm',
     'PermissionUI.jsm',
     'PingCentre.jsm',
     'PluginContent.jsm',
     'ProcessHangMonitor.jsm',
     'ReaderParent.jsm',
     'RemotePrompt.jsm',
--- a/mobile/android/modules/Sanitizer.jsm
+++ b/mobile/android/modules/Sanitizer.jsm
@@ -8,16 +8,17 @@ ChromeUtils.import("resource://gre/modul
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   Accounts: "resource://gre/modules/Accounts.jsm",
   DownloadIntegration: "resource://gre/modules/DownloadIntegration.jsm",
   Downloads: "resource://gre/modules/Downloads.jsm",
   EventDispatcher: "resource://gre/modules/Messaging.jsm",
   FormHistory: "resource://gre/modules/FormHistory.jsm",
+  OfflineAppCacheHelper: "resource://gre/modules/offlineAppCache.jsm",
   OS: "resource://gre/modules/osfile.jsm",
   Task: "resource://gre/modules/Task.jsm",
   TelemetryStopwatch: "resource://gre/modules/TelemetryStopwatch.jsm",
 });
 
 var EXPORTED_SYMBOLS = ["Sanitizer"];
 
 function Sanitizer() {}
@@ -142,20 +143,19 @@ Sanitizer.prototype = {
       get canClear() {
         return true;
       }
     },
 
     offlineApps: {
       clear: function() {
         return new Promise(function(resolve, reject) {
-          var appCacheStorage = Services.cache2.appCacheStorage(Services.loadContextInfo.default, null);
-          try {
-            appCacheStorage.asyncEvictStorage(null);
-          } catch (er) {}
+          // AppCache
+          // This doesn't wait for the cleanup to be complete.
+          OfflineAppCacheHelper.clear();
 
           resolve();
         });
       },
 
       get canClear() {
           return true;
       }
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -101,16 +101,19 @@ with Files('NLP.jsm'):
     BUG_COMPONENT = ('Toolkit', 'Find Toolbar')
 
 with Files('NewTabUtils.jsm'):
     BUG_COMPONENT = ('Firefox', 'Tabbed Browser')
 
 with Files('ObjectUtils.jsm'):
     BUG_COMPONENT = ('Toolkit', 'Telemetry')
 
+with Files("offlineAppCache.jsm"):
+    BUG_COMPONENT = ("Toolkit", "Preferences")
+
 with Files('PageMenu.jsm'):
     BUG_COMPONENT = ('Firefox', 'Menus')
 
 with Files('PermissionsUtils.jsm'):
     BUG_COMPONENT = ('Toolkit', 'Add-ons Manager')
 
 with Files('PopupNotifications.jsm'):
     BUG_COMPONENT = ('Toolkit', 'Password Manager')
@@ -206,16 +209,17 @@ EXTRA_JS_MODULES += [
     'InlineSpellCheckerContent.jsm',
     'Integration.jsm',
     'JSONFile.jsm',
     'Log.jsm',
     'Memory.jsm',
     'NewTabUtils.jsm',
     'NLP.jsm',
     'ObjectUtils.jsm',
+    'offlineAppCache.jsm',
     'PageMenu.jsm',
     'PageMetadata.jsm',
     'PermissionsUtils.jsm',
     'PopupNotifications.jsm',
     'Preferences.jsm',
     'PrivateBrowsingUtils.jsm',
     'ProfileAge.jsm',
     'Promise-backend.js',
rename from browser/modules/offlineAppCache.jsm
rename to toolkit/modules/offlineAppCache.jsm