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 522026 a75c0f1d25e5cc5e12af608a571d6894365e6583
parent 522025 cb57c95a5e8261473504b04ec42a221b5ef5d2a5
child 522027 af8f24f10ce3fb0e5f06484d6f769569967f44d2
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [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();
     });