Bug 1532203 - Implement deleteByHost for NetworkCacheCleaner and ImageCacheCleaner. r=baku
☠☠ backed out by af8f24f10ce3 ☠ ☠
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 15 Mar 2019 11:12:48 +0000
changeset 525024 a75c0f1d25e5cc5e12af608a571d6894365e6583
parent 525023 cb57c95a5e8261473504b04ec42a221b5ef5d2a5
child 525025 af8f24f10ce3fb0e5f06484d6f769569967f44d2
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1532203
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532203 - Implement deleteByHost for NetworkCacheCleaner and ImageCacheCleaner. r=baku Differential Revision: https://phabricator.services.mozilla.com/D23491
toolkit/components/cleardata/ClearDataService.jsm
--- a/toolkit/components/cleardata/ClearDataService.jsm
+++ b/toolkit/components/cleardata/ClearDataService.jsm
@@ -80,32 +80,68 @@ const CookieCleaner = {
 
       aResolve();
     });
   },
 
 };
 
 const NetworkCacheCleaner = {
+  deleteByHost(aHost, aOriginAttributes) {
+    return new Promise(aResolve => {
+      // Delete data from both HTTP and HTTPS sites.
+      let httpURI = Services.io.newURI("http://" + aHost);
+      let httpsURI = Services.io.newURI("https://" + aHost);
+      let httpPrincipal = Services.scriptSecurityManager
+                                   .createCodebasePrincipal(httpURI, aOriginAttributes);
+      let httpsPrincipal = Services.scriptSecurityManager
+                                   .createCodebasePrincipal(httpsURI, aOriginAttributes);
+
+      Services.cache2.asyncClearOrigin(httpPrincipal);
+      Services.cache2.asyncClearOrigin(httpsPrincipal);
+      aResolve();
+    });
+  },
+
   deleteByPrincipal(aPrincipal) {
     return new Promise(aResolve => {
       Services.cache2.asyncClearOrigin(aPrincipal);
       aResolve();
     });
   },
 
   deleteAll() {
     return new Promise(aResolve => {
       Services.cache2.clear();
       aResolve();
     });
   },
 };
 
 const ImageCacheCleaner = {
+  deleteByHost(aHost, aOriginAttributes) {
+    return new Promise(aResolve => {
+      let imageCache = Cc["@mozilla.org/image/tools;1"]
+                         .getService(Ci.imgITools)
+                         .getImgCacheForDocument(null);
+
+      // Delete data from both HTTP and HTTPS sites.
+      let httpURI = Services.io.newURI("http://" + aHost);
+      let httpsURI = Services.io.newURI("https://" + aHost);
+      let httpPrincipal = Services.scriptSecurityManager
+                                   .createCodebasePrincipal(httpURI, aOriginAttributes);
+      let httpsPrincipal = Services.scriptSecurityManager
+                                   .createCodebasePrincipal(httpsURI, aOriginAttributes);
+
+      imageCache.removeEntriesFromPrincipal(httpPrincipal);
+      imageCache.removeEntriesFromPrincipal(httpsPrincipal);
+      aResolve();
+    });
+  },
+
   deleteByPrincipal(aPrincipal) {
     return new Promise(aResolve => {
       let imageCache = Cc["@mozilla.org/image/tools;1"]
                          .getService(Ci.imgITools)
                          .getImgCacheForDocument(null);
       imageCache.removeEntriesFromPrincipal(aPrincipal);
       aResolve();
     });