зеркало из https://github.com/mozilla/gecko-dev.git
Bug 911146 - Add nsIAppStartup attribute to tell whether the app was restarted; r=bsmedberg
This commit is contained in:
Родитель
46ea5c499f
Коммит
a1a0113c62
|
@ -363,6 +363,9 @@ nsAppStartup::Quit(uint32_t aMode)
|
|||
}
|
||||
|
||||
if (mRestart) {
|
||||
// Mark the next startup as a restart.
|
||||
PR_SetEnv("MOZ_APP_RESTART=1");
|
||||
|
||||
/* Firefox-restarts reuse the process so regular process start-time isn't
|
||||
a useful indicator of startup time anymore. */
|
||||
TimeStamp::RecordProcessRestart();
|
||||
|
@ -522,6 +525,19 @@ nsAppStartup::GetRestarting(bool *aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::GetWasRestarted(bool *aResult)
|
||||
{
|
||||
char *mozAppRestart = PR_GetEnv("MOZ_APP_RESTART");
|
||||
|
||||
/* When calling PR_SetEnv() with an empty value the existing variable may
|
||||
* be unset or set to the empty string depending on the underlying platform
|
||||
* thus we have to check if the variable is present and not empty. */
|
||||
*aResult = mozAppRestart && (strcmp(mozAppRestart, "") != 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppStartup::SetInterrupted(bool aInterrupted)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
interface nsICmdLineService;
|
||||
|
||||
[scriptable, uuid(380618f8-479a-435b-b58e-7398ab937531)]
|
||||
[scriptable, uuid(744d6ec0-115f-11e3-9c94-68fd99890b3c)]
|
||||
interface nsIAppStartup : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -140,6 +140,12 @@ interface nsIAppStartup : nsISupports
|
|||
*/
|
||||
readonly attribute boolean restarting;
|
||||
|
||||
/**
|
||||
* True if this is the startup following restart, i.e. if the application
|
||||
* was restarted using quit(eRestart*).
|
||||
*/
|
||||
readonly attribute boolean wasRestarted;
|
||||
|
||||
/**
|
||||
* Returns an object with main, process, firstPaint, sessionRestored properties.
|
||||
* Properties may not be available depending on platform or application
|
||||
|
|
|
@ -30,9 +30,8 @@ TimeStamp::ProcessCreation(bool& aIsInconsistent)
|
|||
* thus we have to check if the variable is present and not empty. */
|
||||
if (mozAppRestart && (strcmp(mozAppRestart, "") != 0)) {
|
||||
/* Firefox was restarted, use the first time-stamp we've taken as the new
|
||||
* process startup time and unset MOZ_APP_RESTART. */
|
||||
* process startup time. */
|
||||
ts = sFirstTimeStamp;
|
||||
PR_SetEnv("MOZ_APP_RESTART=");
|
||||
} else {
|
||||
TimeStamp now = Now();
|
||||
uint64_t uptime = ComputeProcessUptime();
|
||||
|
@ -57,7 +56,6 @@ TimeStamp::ProcessCreation(bool& aIsInconsistent)
|
|||
void
|
||||
TimeStamp::RecordProcessRestart()
|
||||
{
|
||||
PR_SetEnv("MOZ_APP_RESTART=1");
|
||||
sProcessCreation = TimeStamp();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче