Bug 902721 - [Session Restore] Remove _dirtyWindows and replace it with a weak set; r=smacleod

This commit is contained in:
Tim Taubert 2013-08-09 04:41:59 +02:00
parent d8818c145a
commit b6b9cab220

View File

@ -311,9 +311,6 @@ let SessionStoreInternal = {
// states for all recently closed windows
_closedWindows: [],
// not-"dirty" windows usually don't need to have their data updated
_dirtyWindows: {},
// collection of session states yet to be restored
_statesToRestore: {},
@ -1000,7 +997,7 @@ let SessionStoreInternal = {
var activeWindow = this._getMostRecentBrowserWindow();
if (activeWindow)
this.activeWindowSSiCache = activeWindow.__SSi || "";
this._dirtyWindows = [];
DirtyWindows.clear();
},
/**
@ -2544,14 +2541,14 @@ let SessionStoreInternal = {
this._forEachBrowserWindow(function(aWindow) {
if (!this._isWindowLoaded(aWindow)) // window data is still in _statesToRestore
return;
if (aUpdateAll || this._dirtyWindows[aWindow.__SSi] || aWindow == activeWindow) {
if (aUpdateAll || DirtyWindows.has(aWindow) || aWindow == activeWindow) {
this._collectWindowData(aWindow);
}
else { // always update the window features (whose change alone never triggers a save operation)
this._updateWindowFeatures(aWindow);
}
});
this._dirtyWindows = [];
DirtyWindows.clear();
}
// collect the data for all windows
@ -2682,7 +2679,7 @@ let SessionStoreInternal = {
this._windows[aWindow.__SSi].__lastSessionWindowID =
aWindow.__SS_lastSessionWindowID;
this._dirtyWindows[aWindow.__SSi] = false;
DirtyWindows.remove(aWindow);
},
/* ........ Restoring Functionality .............. */
@ -3010,7 +3007,7 @@ let SessionStoreInternal = {
// It's important to set the window state to dirty so that
// we collect their data for the first time when saving state.
this._dirtyWindows[aWindow.__SSi] = true;
DirtyWindows.add(aWindow);
}
if (aTabs.length == 0) {
@ -3701,7 +3698,7 @@ let SessionStoreInternal = {
*/
saveStateDelayed: function ssi_saveStateDelayed(aWindow = null, aDelay = 2000) {
if (aWindow) {
this._dirtyWindows[aWindow.__SSi] = true;
DirtyWindows.add(aWindow);
}
if (!this._saveTimer) {
@ -4689,6 +4686,28 @@ let DyingWindowCache = {
}
};
// A weak set of dirty windows. We use it to determine which windows we need to
// recollect data for when _getCurrentState() is called.
let DirtyWindows = {
_data: new WeakMap(),
has: function (window) {
return this._data.has(window);
},
add: function (window) {
return this._data.set(window, true);
},
remove: function (window) {
this._data.delete(window);
},
clear: function (window) {
this._data.clear();
}
};
// A map storing the number of tabs last closed per windoow. This only
// stores the most recent tab-close operation, and is used to undo
// batch tab-closing operations.