Bug 1195496 - Add PROFILE_READY Gecko state; r=snorp

Many Gecko operations depend on the profile being available. This
patch adds a PROFILE_READY Gecko state so that we can queue calls
until profile is loaded.
This commit is contained in:
Jim Chen
2015-08-19 18:14:47 -04:00
parent 35dfb7e84b
commit eaad07e686
4 changed files with 39 additions and 1 deletions

View File

@@ -196,8 +196,9 @@ nsAppShell::Init()
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
if (obsServ) {
obsServ->AddObserver(this, "xpcom-shutdown", false);
obsServ->AddObserver(this, "browser-delayed-startup-finished", false);
obsServ->AddObserver(this, "profile-do-change", false);
obsServ->AddObserver(this, "xpcom-shutdown", false);
}
if (sPowerManagerService)
@@ -226,6 +227,16 @@ nsAppShell::Observe(nsISupports* aSubject,
} else if (!strcmp(aTopic, "browser-delayed-startup-finished")) {
NS_CreateServicesFromCategory("browser-delayed-startup-finished", nullptr,
"browser-delayed-startup-finished");
} else if (!strcmp(aTopic, "profile-do-change")) {
if (jni::IsAvailable()) {
widget::GeckoThread::SetState(
widget::GeckoThread::State::PROFILE_READY());
}
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
if (obsServ) {
obsServ->RemoveObserver(this, "profile-do-change");
}
}
return NS_OK;
}