Bug 1422365 - Introduce nsIClearDataService - part 12 - session history, r=johannh
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 01 Jun 2018 14:30:01 +0200
changeset 420846 22de53cb87c4a41098bd7a3b2569bf05f1f753cd
parent 420845 59a46331ca79bc5851fc38c98a7429717fbec69f
child 420847 9be5e7c20ed3f42b4b324d06e9e43b6303955b74
push id103898
push useramarchesini@mozilla.com
push dateFri, 01 Jun 2018 12:31:55 +0000
treeherdermozilla-inbound@ee1e13b50338 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1422365
milestone62.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 1422365 - Introduce nsIClearDataService - part 12 - session history, r=johannh
browser/modules/Sanitizer.jsm
toolkit/components/cleardata/ClearDataService.js
toolkit/components/cleardata/nsIClearDataService.idl
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -332,21 +332,19 @@ var Sanitizer = {
         await clearData(range, Ci.nsIClearDataService.CLEAR_DOM_STORAGES);
       }
     },
 
     history: {
       async clear(range) {
         let refObj = {};
         TelemetryStopwatch.start("FX_SANITIZE_HISTORY", refObj);
-        await clearData(range, Ci.nsIClearDataService.CLEAR_HISTORY);
+        await clearData(range, Ci.nsIClearDataService.CLEAR_HISTORY |
+                               Ci.nsIClearDataService.CLEAR_SESSION_HISTORY);
         TelemetryStopwatch.finish("FX_SANITIZE_HISTORY", refObj);
-
-        let clearStartingTime = range ? String(range[0]) : "";
-        Services.obs.notifyObservers(null, "browser:purge-session-history", clearStartingTime);
       }
     },
 
     formdata: {
       async clear(range) {
         let seenException;
         let refObj = {};
         TelemetryStopwatch.start("FX_SANITIZE_FORMDATA", refObj);
--- a/toolkit/components/cleardata/ClearDataService.js
+++ b/toolkit/components/cleardata/ClearDataService.js
@@ -442,16 +442,32 @@ const HistoryCleaner = {
     });
   },
 
   deleteAll() {
     return PlacesUtils.history.clear();
   },
 };
 
+const SessionHistoryCleaner = {
+  deleteByRange(aFrom, aTo) {
+    return new Promise(aResolve => {
+      Services.obs.notifyObservers(null, "browser:purge-session-history", String(aFrom));
+      aResolve();
+    });
+  },
+
+  deleteAll() {
+    return new Promise(aResolve => {
+      Services.obs.notifyObservers(null, "browser:purge-session-history");
+      aResolve();
+    });
+  },
+};
+
 // Here the map of Flags-Cleaner.
 const FLAGS_MAP = [
  { flag: Ci.nsIClearDataService.CLEAR_COOKIES,
    cleaner: CookieCleaner },
 
  { flag: Ci.nsIClearDataService.CLEAR_NETWORK_CACHE,
    cleaner: NetworkCacheCleaner },
 
@@ -479,16 +495,19 @@ const FLAGS_MAP = [
  { flag: Ci.nsIClearDataService.CLEAR_PREDICTOR_NETWORK_DATA,
    cleaner: PredictorNetworkCleaner, },
 
  { flag: Ci.nsIClearDataService.CLEAR_DOM_PUSH_NOTIFICATIONS,
    cleaner: PushNotificationsCleaner, },
 
  { flag: Ci.nsIClearDataService.CLEAR_HISTORY,
    cleaner: HistoryCleaner, },
+
+ { flag: Ci.nsIClearDataService.CLEAR_SESSION_HISTORY,
+   cleaner: SessionHistoryCleaner, },
 ];
 
 this.ClearDataService = function() {};
 
 ClearDataService.prototype = Object.freeze({
   classID: Components.ID("{0c06583d-7dd8-4293-b1a5-912205f779aa}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsIClearDataService]),
   _xpcom_factory: XPCOMUtils.generateSingletonFactory(ClearDataService),
--- a/toolkit/components/cleardata/nsIClearDataService.idl
+++ b/toolkit/components/cleardata/nsIClearDataService.idl
@@ -138,23 +138,27 @@ interface nsIClearDataService : nsISuppo
    */
   const uint32_t CLEAR_DOM_PUSH_NOTIFICATIONS = 1 << 10;
 
   /**
    * Places history
    */
   const uint32_t CLEAR_HISTORY = 1 << 11;
 
+  /**
+   * Session history
+   */
+  const uint32_t CLEAR_SESSION_HISTORY = 1 << 12;
+
   /* TODO
   const uint32_t CLEAR_EME = 1 << 4;
   const uint32_t CLEAR_PERMISSIONS = 1 << 7;
   const uint32_t CLEAR_CONTENT_PREFERENCES = 1 << 9;
   const uint32_t CLEAR_HSTS = 1 << 12;
   const uint32_t CLEAR_HPKP = 1 << 13;
-  const uint32_t CLEAR_SESSION_HISTORY = 1 << 15;
   const uint32_t CLEAR_FORMDATA = 1 << 16;
   const uint32_t CLEAR_AUTH_TOKENS = 1 << 17;
   const uint32_t CLEAR_LOGINS = 1 << 18;
   */
 
   /**
    * Use this value to delete all the data.
    */