Bug 665260 - Store start time in sessionstore data [r=dietrich]

This commit is contained in:
Paul O’Shannessy 2011-06-21 10:44:10 -07:00
Родитель 8b11e411f2
Коммит 65bca0d683
1 изменённых файлов: 18 добавлений и 4 удалений

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

@ -198,6 +198,10 @@ SessionStoreService.prototype = {
// time in milliseconds (Date.now()) when the session was last written to file // time in milliseconds (Date.now()) when the session was last written to file
_lastSaveTime: 0, _lastSaveTime: 0,
// time in milliseconds when the session was started (saved across sessions),
// defaults to now if no session was restored or timestamp doesn't exist
_sessionStartTime: Date.now(),
// states for all currently opened windows // states for all currently opened windows
_windows: {}, _windows: {},
@ -344,6 +348,11 @@ SessionStoreService.prototype = {
} }
} }
// Load the session start time from the previous state
this._sessionStartTime = this._initialState.session &&
this._initialState.session.startTime ||
this._sessionStartTime;
// make sure that at least the first window doesn't have anything hidden // make sure that at least the first window doesn't have anything hidden
delete this._initialState.windows[0].hidden; delete this._initialState.windows[0].hidden;
// Since nothing is hidden in the first window, it cannot be a popup // Since nothing is hidden in the first window, it cannot be a popup
@ -1509,9 +1518,13 @@ SessionStoreService.prototype = {
this._closedWindows = this._closedWindows.concat(lastSessionState._closedWindows); this._closedWindows = this._closedWindows.concat(lastSessionState._closedWindows);
this._capClosedWindows(); this._capClosedWindows();
} }
// Set recent crashes
// Set data that persists between sessions
this._recentCrashes = lastSessionState.session && this._recentCrashes = lastSessionState.session &&
lastSessionState.session.recentCrashes || 0; lastSessionState.session.recentCrashes || 0;
this._sessionStartTime = lastSessionState.session &&
lastSessionState.session.startTime ||
this._sessionStartTime;
this._lastSessionState = null; this._lastSessionState = null;
}, },
@ -3420,7 +3433,8 @@ SessionStoreService.prototype = {
oState.session = { oState.session = {
state: this._loadState == STATE_RUNNING ? STATE_RUNNING_STR : STATE_STOPPED_STR, state: this._loadState == STATE_RUNNING ? STATE_RUNNING_STR : STATE_STOPPED_STR,
lastUpdate: Date.now() lastUpdate: Date.now(),
startTime: this._sessionStartTime
}; };
if (this._recentCrashes) if (this._recentCrashes)
oState.session.recentCrashes = this._recentCrashes; oState.session.recentCrashes = this._recentCrashes;