Bug 1343603 - Part 1 - Immediately clear cached session store history data when clearing history. r=ahunt a=gchang
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 02 Mar 2017 20:29:52 +0100
changeset 395060 600604082021c59612d17b697c0d373bc03a08cf
parent 395059 dcd1390b419ed5ca803121e019d414f3af875f53
child 395061 147c73709841da67c170f0dfc835e7293683a387
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahunt, gchang
bugs1343603, 1337940
milestone54.0a2
Bug 1343603 - Part 1 - Immediately clear cached session store history data when clearing history. r=ahunt a=gchang The session store keeps a serialised copy of a tab's session history around so that the gathering of the data (which can be somewhat expensive) can be decoupled from writing it to disk. When the user clears Firefox's history, we therefore need to discard this data as well (except for the currently open entry), so it doesn't stick around until the next time some navigation/history change occurs in that tab. Otherwise, if Firefox or just the tab is closed before the purged state has been re-collected by the session store, the supposedly purged session history will resurface when the tab is restored again. Bug 1337940 means that we'll now catch the history notifications caused by the session history being purged, however - we still need to handle zombified tabs separately, since as far as the rest of Gecko is concerned, those simply consist of a plain "about:blank" browser with the true state being stashed away in the session store data, so the purging of the live session history data won't have any real effect - the history purging on the tab happens after the session store receives the "browser:purge-session-history" notification, meaning that these changes received through the regular history notifications won't get written to disk immediately Therefore we now explicitly purge the session history data of all tabs in our notification handler, so this state can then immediately be saved to disk. MozReview-Commit-ID: KkR0Tif9BBk
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -237,16 +237,32 @@ SessionStore.prototype = {
       case "browser:purge-session-tabs":
       case "browser:purge-session-history": // catch sanitization
         log(aTopic);
         this._clearDisk();
 
         // Clear all data about closed tabs
         this._forgetClosedTabs();
 
+        // Clear all cached session history data.
+        if (aTopic == "browser:purge-session-history") {
+          this._forEachBrowserWindow((window) => {
+            let tabs = window.BrowserApp.tabs;
+            for (let i = 0; i < tabs.length; i++) {
+              let data = tabs[i].browser.__SS_data;
+              let sHistory = data.entries;
+              // Copy the current history entry to the end...
+              sHistory.push(sHistory[data.index - 1]);
+              // ... and then remove everything else.
+              sHistory.splice(0, sHistory.length - 1);
+              data.index = 1;
+            }
+          });
+        }
+
         if (this._loadState == STATE_RUNNING) {
           // Save the purged state immediately
           this.saveState();
         } else if (this._loadState <= STATE_QUITTING) {
           this.saveStateDelayed();
           if (this._loadState == STATE_QUITTING_FLUSHED) {
             this.flushPendingState();
           }