Bug 881667 - Implement nsIAppStartup::startingUp. r=bsmedberg
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Fri, 11 Oct 2013 12:00:19 -0400
changeset 164305 b4f347a62071149e59562aba128b488437c8df1d
parent 164304 5836dc9eaa656426be9771e30b3769b518c243a6
child 164306 a5046a3a30eac9a613265824a8d9f2c99a53ee39
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs881667
milestone27.0a1
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
Bug 881667 - Implement nsIAppStartup::startingUp. r=bsmedberg
toolkit/components/startup/nsAppStartup.cpp
toolkit/components/startup/nsAppStartup.h
toolkit/components/startup/public/nsIAppStartup.idl
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -132,16 +132,17 @@ uint64_t ComputeAbsoluteTimestamp(PRTime
 //
 // nsAppStartup
 //
 
 nsAppStartup::nsAppStartup() :
   mConsiderQuitStopper(0),
   mRunning(false),
   mShuttingDown(false),
+  mStartingUp(true),
   mAttemptingQuit(false),
   mRestart(false),
   mInterrupted(false),
   mIsSafeModeNecessary(false),
   mStartupCrashTrackingEnded(false)
 { }
 
 
@@ -512,16 +513,33 @@ nsAppStartup::ExitLastWindowClosingSurvi
 NS_IMETHODIMP
 nsAppStartup::GetShuttingDown(bool *aResult)
 {
   *aResult = mShuttingDown;
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsAppStartup::GetStartingUp(bool *aResult)
+{
+  *aResult = mStartingUp;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsAppStartup::DoneStartingUp()
+{
+  // This must be called once at most
+  MOZ_ASSERT(mStartingUp);
+
+  mStartingUp = false;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsAppStartup::GetRestarting(bool *aResult)
 {
   *aResult = mRestart;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAppStartup::GetWasRestarted(bool *aResult)
--- a/toolkit/components/startup/nsAppStartup.h
+++ b/toolkit/components/startup/nsAppStartup.h
@@ -51,16 +51,17 @@ private:
 
   friend class nsAppExitEvent;
 
   nsCOMPtr<nsIAppShell> mAppShell;
 
   int32_t      mConsiderQuitStopper; // if > 0, Quit(eConsiderQuit) fails
   bool mRunning;        // Have we started the main event loop?
   bool mShuttingDown;   // Quit method reentrancy check
+  bool mStartingUp;     // Have we passed final-ui-startup?
   bool mAttemptingQuit; // Quit(eAttemptQuit) still trying
   bool mRestart;        // Quit(eRestart)
   bool mInterrupted;    // Was startup interrupted by an interactive prompt?
   bool mIsSafeModeNecessary;       // Whether safe mode is necessary
   bool mStartupCrashTrackingEnded; // Whether startup crash tracking has already ended
 
 #if defined(XP_WIN)
   //Interaction with OS-provided profiling probes
--- a/toolkit/components/startup/public/nsIAppStartup.idl
+++ b/toolkit/components/startup/public/nsIAppStartup.idl
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsICmdLineService;
 
-[scriptable, uuid(744d6ec0-115f-11e3-9c94-68fd99890b3c)]
+[scriptable, uuid(9edef217-e664-4938-85a7-2fe84baa1755)]
 interface nsIAppStartup : nsISupports
 {
     /**
      * Create the hidden window.
      */
     void createHiddenWindow();
 
     /**
@@ -131,16 +131,30 @@ interface nsIAppStartup : nsISupports
     void quit(in uint32_t aMode);
 
     /**
      * True if the application is in the process of shutting down.
      */
     readonly attribute boolean shuttingDown;
 
     /**
+     * True if the application is in the process of starting up.
+     *
+     * Startup is complete once all observers of final-ui-startup have returned.
+     */
+    readonly attribute boolean startingUp;
+
+    /**
+     * Mark the startup as completed.
+     *
+     * Called at the end of startup by nsAppRunner.
+     */
+    [noscript] void doneStartingUp();
+
+    /**
      * True if the application is being restarted
      */
     readonly attribute boolean restarting;
 
     /**
      * True if this is the startup following restart, i.e. if the application
      * was restarted using quit(eRestart*).
      */
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3846,16 +3846,17 @@ XREMain::XRE_mainRun()
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 #endif
 
     nsCOMPtr<nsIObserverService> obsService =
       mozilla::services::GetObserverService();
     if (obsService)
       obsService->NotifyObservers(nullptr, "final-ui-startup", nullptr);
 
+    (void)appStartup->DoneStartingUp();
     appStartup->GetShuttingDown(&mShuttingDown);
   }
 
   if (!mShuttingDown) {
     rv = cmdLine->Run();
     NS_ENSURE_SUCCESS_LOG(rv, NS_ERROR_FAILURE);
 
     appStartup->GetShuttingDown(&mShuttingDown);