about:startup - remove timestamp code from session startup, now that it's no longer necessary
authorDaniel Brooks <db48x@db48x.net>
Sun, 19 Sep 2010 13:47:02 -0400
changeset 58853 b93f81ea75fdc32945bf7ae555605f4d6cdf2145
parent 58852 6d5c509f974349280fb73a1ee497ad209c669e2d
child 58854 f3fc7778d8c104988ebff1fe602fbacd592a4ca3
push id17440
push userdb48x@yahoo.com
push dateWed, 08 Dec 2010 04:15:54 +0000
treeherdermozilla-central@a89f24bf1798 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
about:startup - remove timestamp code from session startup, now that it's no longer necessary
browser/components/sessionstore/nsISessionStartup.idl
browser/components/sessionstore/src/nsSessionStartup.js
--- a/browser/components/sessionstore/nsISessionStartup.idl
+++ b/browser/components/sessionstore/nsISessionStartup.idl
@@ -59,10 +59,9 @@ interface nsISessionStartup: nsISupports
    * either restoring state from a crash or restoring state that the user
    * requested we save on shutdown.
    */
   const unsigned long NO_SESSION = 0;
   const unsigned long RECOVER_SESSION = 1;
   const unsigned long RESUME_SESSION = 2;
 
   readonly attribute unsigned long sessionType;
-  readonly attribute unsigned long long restoredTimestamp;
 };
--- a/browser/components/sessionstore/src/nsSessionStartup.js
+++ b/browser/components/sessionstore/src/nsSessionStartup.js
@@ -1,9 +1,9 @@
-/* 
+/*
 # ***** BEGIN LICENSE BLOCK *****
 # * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 # *
 # * The contents of this file are subject to the Mozilla Public License Version
 # * 1.1 (the "License"); you may not use this file except in compliance with
 # * the License. You may obtain a copy of the License at
 # * http://www.mozilla.org/MPL/
 # *
@@ -29,43 +29,43 @@
 # * of those above. If you wish to allow use of your version of this file only
 # * under the terms of either the GPL or the LGPL, and not to allow others to
 # * use your version of this file under the terms of the MPL, indicate your
 # * decision by deleting the provisions above and replace them with the notice
 # * and other provisions required by the GPL or the LGPL. If you do not delete
 # * the provisions above, a recipient may use your version of this file under
 # * the terms of any one of the MPL, the GPL or the LGPL.
 # *
-# * ***** END LICENSE BLOCK ***** 
+# * ***** END LICENSE BLOCK *****
 */
 
 /**
 # * Session Storage and Restoration
-# * 
+# *
 # * Overview
-# * This service reads user's session file at startup, and makes a determination 
-# * as to whether the session should be restored. It will restore the session 
+# * This service reads user's session file at startup, and makes a determination
+# * as to whether the session should be restored. It will restore the session
 # * under the circumstances described below.  If the auto-start Private Browsing
 # * mode is active, however, the session is never restored.
-# * 
+# *
 # * Crash Detection
-# * The session file stores a session.state property, that 
-# * indicates whether the browser is currently running. When the browser shuts 
+# * The session file stores a session.state property, that
+# * indicates whether the browser is currently running. When the browser shuts
 # * down, the field is changed to "stopped". At startup, this field is read, and
 # * if its value is "running", then it's assumed that the browser had previously
 # * crashed, or at the very least that something bad happened, and that we should
 # * restore the session.
-# * 
+# *
 # * Forced Restarts
 # * In the event that a restart is required due to application update or extension
 # * installation, set the browser.sessionstore.resume_session_once pref to true,
 # * and the session will be restored the next time the browser starts.
-# * 
+# *
 # * Always Resume
-# * This service will always resume the session if the integer pref 
+# * This service will always resume the session if the integer pref
 # * browser.startup.page is set to 3.
 */
 
 /* :::::::: Constants and Helpers ::::::::::::::: */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
@@ -86,17 +86,16 @@ function debug(aMsg) {
 function SessionStartup() {
 }
 
 SessionStartup.prototype = {
 
   // the state to restore at startup
   _iniString: null,
   _sessionType: Ci.nsISessionStartup.NO_SESSION,
-  _restoredTimestamp: 0,
 
 /* ........ Global Event Handlers .............. */
 
   /**
    * Initialize the component
    */
   init: function sss_init() {
     // do not need to initialize anything in auto-started private browsing sessions
@@ -108,25 +107,25 @@ SessionStartup.prototype = {
     let prefBranch = Cc["@mozilla.org/preferences-service;1"].
                      getService(Ci.nsIPrefService).getBranch("browser.");
 
     // get file references
     var dirService = Cc["@mozilla.org/file/directory_service;1"].
                      getService(Ci.nsIProperties);
     let sessionFile = dirService.get("ProfD", Ci.nsILocalFile);
     sessionFile.append("sessionstore.js");
-    
+
     let doResumeSession = prefBranch.getBoolPref("sessionstore.resume_session_once") ||
                           prefBranch.getIntPref("startup.page") == 3;
-    
+
     // only read the session file if config allows possibility of restoring
     var resumeFromCrash = prefBranch.getBoolPref("sessionstore.resume_from_crash");
     if (!resumeFromCrash && !doResumeSession || !sessionFile.exists())
       return;
-    
+
     // get string containing session state
     this._iniString = this._readStateFile(sessionFile);
     if (!this._iniString)
       return;
 
     // parse the session state into a JS object
     let initialState;
     try {
@@ -142,28 +141,25 @@ SessionStartup.prototype = {
         this._iniString = JSON.stringify(initialState);
       }
     }
     catch (ex) { debug("The session file is invalid: " + ex); }
 
     let lastSessionCrashed =
       initialState && initialState.session && initialState.session.state &&
       initialState.session.state == STATE_RUNNING_STR;
-    
+
     // set the startup type
     if (lastSessionCrashed && resumeFromCrash)
       this._sessionType = Ci.nsISessionStartup.RECOVER_SESSION;
     else if (!lastSessionCrashed && doResumeSession)
       this._sessionType = Ci.nsISessionStartup.RESUME_SESSION;
     else
       this._iniString = null; // reset the state string
 
-    Services.obs.addObserver(this, "sessionstore-browser-state-restored", true);
-    Services.obs.addObserver(this, "sessionstore-windows-restored", true);
-
     if (this._sessionType != Ci.nsISessionStartup.NO_SESSION) {
       // wait for the first browser window to open
 
       // Don't reset the initial window's default args (i.e. the home page(s))
       // if all stored tabs are pinned.
       if (!initialState.windows ||
           !initialState.windows.every(function (win)
              win.tabs.every(function (tab) tab.pinned)))
@@ -173,21 +169,21 @@ SessionStartup.prototype = {
     }
   },
 
   /**
    * Handle notifications
    */
   observe: function sss_observe(aSubject, aTopic, aData) {
     switch (aTopic) {
-    case "app-startup": 
+    case "app-startup":
       Services.obs.addObserver(this, "final-ui-startup", true);
       Services.obs.addObserver(this, "quit-application", true);
       break;
-    case "final-ui-startup": 
+    case "final-ui-startup":
       Services.obs.removeObserver(this, "final-ui-startup");
       Services.obs.removeObserver(this, "quit-application");
       this.init();
       break;
     case "quit-application":
       // no reason for initializing at this point (cf. bug 409115)
       Services.obs.removeObserver(this, "final-ui-startup");
       Services.obs.removeObserver(this, "quit-application");
@@ -195,22 +191,16 @@ SessionStartup.prototype = {
     case "domwindowopened":
       var window = aSubject;
       var self = this;
       window.addEventListener("load", function() {
         self._onWindowOpened(window);
         window.removeEventListener("load", arguments.callee, false);
       }, false);
       break;
-    case "sessionstore-browser-state-restored":
-    case "sessionstore-windows-restored":
-      this._restoredTimestamp = new Date() * 1000;
-      Services.obs.removeObserver(this, "sessionstore-browser-state-restored");
-      Services.obs.removeObserver(this, "sessionstore-windows-restored");
-      break;
     case "browser:purge-session-history":
       // reset all state on sanitization
       this._iniString = null;
       this._sessionType = Ci.nsISessionStartup.NO_SESSION;
       // no need in repeating this, since startup state won't change
       Services.obs.removeObserver(this, "browser:purge-session-history");
       break;
     }
@@ -219,17 +209,17 @@ SessionStartup.prototype = {
   /**
    * Removes the default arguments from the first browser window
    * (and removes the "domwindowopened" observer afterwards).
    */
   _onWindowOpened: function sss_onWindowOpened(aWindow) {
     var wType = aWindow.document.documentElement.getAttribute("windowtype");
     if (wType != "navigator:browser")
       return;
-    
+
     /**
      * Note: this relies on the fact that nsBrowserContentHandler will return
      * a different value the first time its getter is called after an update,
      * due to its needHomePageOverride() logic. We don't want to remove the
      * default arguments in the update case, since they include the "What's
      * New" page.
      *
      * Since we're garanteed to be at least the second caller of defaultArgs
@@ -267,20 +257,16 @@ SessionStartup.prototype = {
 
   /**
    * Get the type of pending session store, if any.
    */
   get sessionType() {
     return this._sessionType;
   },
 
-  get restoredTimestamp() {
-    return this._restoredTimestamp;
-  },
-
 /* ........ Storage API .............. */
 
   /**
    * Reads a session state file into a string and lets
    * observers modify the state before it's being used
    *
    * @param aFile is any nsIFile
    * @returns a session state string