Bug 873556 - Add a timestamp to closedWindows and closedTabs. r=ttaubert
authorSeif Lotfy <seif@lotfy.com>
Wed, 08 Jan 2014 09:39:53 -0500
changeset 162548 cd03f802a3b9aede1c12cb7b2b116219b1738016
parent 162547 2e6f5635d28c38609ddd3797ed6493ef23a57e7d
child 162549 c7136dd407a6f1a02c4bf99b47cd6bfbf94a1199
push idunknown
push userunknown
push dateunknown
reviewersttaubert
bugs873556
milestone29.0a1
Bug 873556 - Add a timestamp to closedWindows and closedTabs. r=ttaubert
browser/components/sessionstore/src/SessionStore.jsm
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -1030,16 +1030,21 @@ let SessionStoreInternal = {
       }
 
 #ifndef XP_MACOSX
       // Until we decide otherwise elsewhere, this window is part of a series
       // of closing windows to quit.
       winData._shouldRestore = true;
 #endif
 
+      // Store the window's close date to figure out when each individual tab
+      // was closed. This timestamp should allow re-arranging data based on how
+      // recently something was closed.
+      winData.closedAt = Date.now();
+
       // Save the window if it has multiple tabs or a single saveable tab and
       // it's not private.
       if (!winData.isPrivate && (winData.tabs.length > 1 ||
           (winData.tabs.length == 1 && this._shouldSaveTabState(winData.tabs[0])))) {
         // we don't want to save the busy state
         delete winData.busy;
 
         this._closedWindows.unshift(winData);
@@ -1343,17 +1348,18 @@ let SessionStoreInternal = {
       let tabTitle = aTab.label;
       let tabbrowser = aWindow.gBrowser;
       tabTitle = this._replaceLoadingTitle(tabTitle, tabbrowser, aTab);
 
       this._windows[aWindow.__SSi]._closedTabs.unshift({
         state: tabState,
         title: tabTitle,
         image: tabbrowser.getIcon(aTab),
-        pos: aTab._tPos
+        pos: aTab._tPos,
+        closedAt: Date.now()
       });
       var length = this._windows[aWindow.__SSi]._closedTabs.length;
       if (length > this._max_tabs_undo)
         this._windows[aWindow.__SSi]._closedTabs.splice(this._max_tabs_undo, length - this._max_tabs_undo);
     }
   },
 
   /**