about:startup - store the restored timestamp on the app startup and adjust the page to match
authorDaniel Brooks <db48x@db48x.net>
Mon, 20 Sep 2010 18:55:49 -0400
changeset 58854 f3fc7778d8c104988ebff1fe602fbacd592a4ca3
parent 58853 b93f81ea75fdc32945bf7ae555605f4d6cdf2145
child 58855 4e82cb73ec344549ab6ce705017ecca250d9c7c5
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 - store the restored timestamp on the app startup and adjust the page to match
browser/base/content/browser.js
toolkit/components/startup/public/nsIAppStartup.idl
toolkit/components/startup/src/nsAppStartup.cpp
toolkit/components/startup/src/nsAppStartup.h
toolkit/content/aboutStartup.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -496,17 +496,17 @@ const gPopupBlockerObserver = {
       item = next;
     }
 
     var foundUsablePopupURI = false;
     var pageReport = gBrowser.pageReport;
     if (pageReport) {
       for (var i = 0; i < pageReport.length; ++i) {
         // popupWindowURI will be null if the file picker popup is blocked.
-        // xxxdz this should make the option say "Show file picker" and do it (Bug 590306) 
+        // xxxdz this should make the option say "Show file picker" and do it (Bug 590306)
         if (!pageReport[i].popupWindowURI)
           continue;
         var popupURIspec = pageReport[i].popupWindowURI.spec;
 
         // Sometimes the popup URI that we get back from the pageReport
         // isn't useful (for instance, netscape.com's popup URI ends up
         // being "http://www.netscape.com", which isn't really the URI of
         // the popup they're trying to show).  This isn't going to be
@@ -4287,17 +4287,17 @@ var XULBrowserWindow = {
         // Close the Find toolbar if we're in old-style TAF mode
         gFindBar.close();
       }
 
       // XXXmano new-findbar, do something useful once it lands.
       // Of course, this is especially wrong with bfcache on...
 
       // fix bug 253793 - turn off highlight when page changes
-      gFindBar.getElement("highlight").checked = false;      
+      gFindBar.getElement("highlight").checked = false;
     }
 
     // See bug 358202, when tabs are switched during a drag operation,
     // timers don't fire on windows (bug 203573)
     if (aRequest)
       setTimeout(function () { XULBrowserWindow.asyncUpdateUI(); }, 0);
     else
       this.asyncUpdateUI();
--- a/toolkit/components/startup/public/nsIAppStartup.idl
+++ b/toolkit/components/startup/public/nsIAppStartup.idl
@@ -116,16 +116,18 @@ interface nsIAppStartup : nsISupports
 
 [scriptable, uuid(e233d663-d014-43b0-8649-7145ecf0a0b1)]
 interface nsIAppStartup2 : nsIAppStartup
 {
     /**
      * True if the application is in the process of shutting down.
      */
     readonly attribute boolean shuttingDown;
+
+    readonly attribute PRUint64 restoredTimestamp;
 };
 
 %{C++
 /**
  * This success code may be returned by nsIAppStartup::Run to indicate that the
  * application should be restarted.  This condition corresponds to the case in
  * which nsIAppStartup::Quit was called with the eRestart flag.
  */
--- a/toolkit/components/startup/src/nsAppStartup.cpp
+++ b/toolkit/components/startup/src/nsAppStartup.cpp
@@ -93,21 +93,19 @@ public:
 
     // We're done "shutting down".
     mService->mShuttingDown = PR_FALSE;
     mService->mRunning = PR_FALSE;
     return NS_OK;
   }
 };
 
-nsresult RecordStartupDuration();
 nsresult OpenStartupDatabase(mozIStorageConnection **db);
 nsresult EnsureTable(mozIStorageConnection *db, const nsACString &table,
                      const nsACString &schema);
-nsresult RecordAddonEvent(const PRUnichar *event, nsISupports *details);
 
 //
 // nsAppStartup
 //
 
 nsAppStartup::nsAppStartup() :
   mConsiderQuitStopper(0),
   mRunning(PR_FALSE),
@@ -530,27 +528,26 @@ nsAppStartup::Observe(nsISupports *aSubj
     RecordAddonEvent(aData, aSubject);
   } else {
     NS_ERROR("Unexpected observer topic.");
   }
 
   return NS_OK;
 }
 
-nsresult RecordStartupDuration()
+nsresult nsAppStartup::RecordStartupDuration()
 {
   nsresult rv;
-  PRTime launched, started, finished;
-  finished = PR_Now();
+  PRTime launched, started;
+  mRestoredTimestamp = PR_Now();
 
   nsCOMPtr<mozIStorageConnection> db;
   rv = OpenStartupDatabase(getter_AddRefs(db));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  
   nsCOMPtr<mozIStorageStatement> statement;
   rv = db->CreateStatement(NS_LITERAL_CSTRING("INSERT INTO duration VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)"),
                            getter_AddRefs(statement));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIXULRuntime> runtime = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
   nsCOMPtr<nsIXULAppInfo> appinfo = do_QueryInterface(runtime);
 
@@ -562,34 +559,34 @@ nsresult RecordStartupDuration()
   appinfo->GetAppBuildID(appBuild);
   appinfo->GetPlatformVersion(platformVersion);
   appinfo->GetPlatformBuildID(platformBuild);
 
   rv = statement->BindInt64Parameter(0, launched);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = statement->BindInt64Parameter(1, started - launched);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = statement->BindInt64Parameter(2, finished - started);
+  rv = statement->BindInt64Parameter(2, mRestoredTimestamp - started);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = statement->BindStringParameter(3, NS_ConvertUTF8toUTF16(appVersion));
   NS_ENSURE_SUCCESS(rv, rv); 
   rv = statement->BindStringParameter(4, NS_ConvertUTF8toUTF16(appBuild));
   NS_ENSURE_SUCCESS(rv, rv); 
   rv = statement->BindStringParameter(5, NS_ConvertUTF8toUTF16(platformVersion));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = statement->BindStringParameter(6, NS_ConvertUTF8toUTF16(platformBuild));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = statement->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-nsresult RecordAddonEvent(const PRUnichar *event, nsISupports *details)
+nsresult nsAppStartup::RecordAddonEvent(const PRUnichar *event, nsISupports *details)
 {
   PRTime now = PR_Now();
   nsresult rv;
 
   nsCOMPtr<mozIStorageConnection> db;
   rv = OpenStartupDatabase(getter_AddRefs(db));
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -662,8 +659,15 @@ nsresult EnsureTable(mozIStorageConnecti
   rv = db->TableExists(table, &exists);
   NS_ENSURE_SUCCESS(rv, rv);
   if (!exists)
     rv = db->CreateTable(PromiseFlatCString(table).get(),
                          PromiseFlatCString(schema).get());
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
+
+NS_IMETHODIMP
+nsAppStartup::GetRestoredTimestamp(PRUint64 *aResult)
+{
+  *aResult = (PRTime)mRestoredTimestamp;
+  return NS_OK;
+}
--- a/toolkit/components/startup/src/nsAppStartup.h
+++ b/toolkit/components/startup/src/nsAppStartup.h
@@ -80,11 +80,16 @@ private:
 
   nsCOMPtr<nsIAppShell> mAppShell;
 
   PRInt32      mConsiderQuitStopper; // if > 0, Quit(eConsiderQuit) fails
   PRPackedBool mRunning;        // Have we started the main event loop?
   PRPackedBool mShuttingDown;   // Quit method reentrancy check
   PRPackedBool mAttemptingQuit; // Quit(eAttemptQuit) still trying
   PRPackedBool mRestart;        // Quit(eRestart)
+
+  PRTime mRestoredTimestamp;
+
+  nsresult RecordStartupDuration();
+  nsresult RecordAddonEvent(const PRUnichar *event, nsISupports *details);
 };
 
 #endif // nsAppStartup_h__
--- a/toolkit/content/aboutStartup.js
+++ b/toolkit/content/aboutStartup.js
@@ -75,19 +75,19 @@ let runtime = Cc["@mozilla.org/xre/runti
 try {
   displayTimestamp("launched", launched = runtime.launchTimestamp);
 } catch(x) { }
 
 displayTimestamp("started", startup = runtime.startupTimestamp);
 if (launched)
   displayDuration("started", startup - launched);
 
-let ss = Cc["@mozilla.org/browser/sessionstartup;1"]
-           .getService(Ci.nsISessionStartup);
-displayTimestamp("restored", restored = ss.restoredTimestamp);
+let app = Cc["@mozilla.org/toolkit/app-startup;1"]
+            .getService(Ci.nsIAppStartup2);
+displayTimestamp("restored", restored = app.restoredTimestamp);
 displayDuration("restored", restored - startup);
 
 ///// Next, load the database
 var file = Components.classes["@mozilla.org/file/directory_service;1"]
                      .getService(Components.interfaces.nsIProperties)
                      .get("ProfD", Components.interfaces.nsIFile);
 file.append("startup.sqlite");