Bug 1343603 - Part 1: Immediately clear cached session store history data when clearing history. r=ahunt, a=ritu
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 02 Mar 2017 20:29:52 +0100
changeset 379011 3e68000c437c77dadc5e58f0a8b88fadf4ce145a
parent 379010 dc8c26683d20ca523a1fa2e23dcbef9c09cbe43d
child 379012 6938c2c43242ccd602ea0254c171d5ca75ce7ed9
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahunt, ritu
bugs1343603, 1337940
Bug 1343603 - Part 1: Immediately clear cached session store history data when clearing history. r=ahunt, a=ritu 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
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -240,16 +240,32 @@ SessionStore.prototype = {
       case "browser:purge-session-tabs":
       case "browser:purge-session-history": // catch sanitization
         // Clear all data about closed tabs
+        // 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
         } else if (this._loadState <= STATE_QUITTING) {
           if (this._loadState == STATE_QUITTING_FLUSHED) {