Bug 1343603 - Part 1 - Immediately clear cached session store history data when clearing history. r=ahunt

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

--HG--
extra : rebase_source : 5744c88e2871cd873e2484e9688deb53bf8d44f2
This commit is contained in:
Jan Henning 2017-03-02 20:29:52 +01:00
Родитель 51cfb79ec0
Коммит ff6a093d9d
1 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -233,6 +233,22 @@ SessionStore.prototype = {
// 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();