зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1416066 - Delay initialization of sProcessType for child processes in ScriptPreloader since remoteType in ContentChild is not ready yet. r=kmag
MozReview-Commit-ID: FTmQMbKhlR --HG-- extra : rebase_source : c6414c627d05ce7510a97850c143d0b8e04c852c
This commit is contained in:
Родитель
62198551fb
Коммит
c66f4c3e82
|
@ -240,10 +240,10 @@ ScriptPreloader::ScriptPreloader()
|
|||
: mMonitor("[ScriptPreloader.mMonitor]")
|
||||
, mSaveMonitor("[ScriptPreloader.mSaveMonitor]")
|
||||
{
|
||||
// We do not set the process type for child processes here because the
|
||||
// remoteType in ContentChild is not ready yet.
|
||||
if (XRE_IsParentProcess()) {
|
||||
sProcessType = ProcessType::Parent;
|
||||
} else {
|
||||
sProcessType = GetChildProcessType(dom::ContentChild::GetSingleton()->GetRemoteType());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
|
@ -254,13 +254,8 @@ ScriptPreloader::ScriptPreloader()
|
|||
// as idle tasks for the first browser window have completed.
|
||||
obs->AddObserver(this, STARTUP_COMPLETE_TOPIC, false);
|
||||
obs->AddObserver(this, CACHE_WRITE_TOPIC, false);
|
||||
} else {
|
||||
// In the child process, we need to freeze the script cache before any
|
||||
// untrusted code has been executed. The insertion of the first DOM
|
||||
// document element may sometimes be earlier than is ideal, but at
|
||||
// least it should always be safe.
|
||||
obs->AddObserver(this, DOC_ELEM_INSERTED_TOPIC, false);
|
||||
}
|
||||
|
||||
obs->AddObserver(this, SHUTDOWN_TOPIC, false);
|
||||
obs->AddObserver(this, CLEANUP_TOPIC, false);
|
||||
obs->AddObserver(this, CACHE_INVALIDATE_TOPIC, false);
|
||||
|
@ -367,6 +362,7 @@ ScriptPreloader::Observe(nsISupports* subject, const char* topic, const char16_t
|
|||
mStartupFinished = true;
|
||||
} else if (!strcmp(topic, CACHE_WRITE_TOPIC)) {
|
||||
obs->RemoveObserver(this, CACHE_WRITE_TOPIC);
|
||||
|
||||
MOZ_ASSERT(mStartupFinished);
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
|
@ -503,6 +499,16 @@ ScriptPreloader::InitCache(const Maybe<ipc::FileDescriptor>& cacheFile, ScriptCa
|
|||
|
||||
mCacheInitialized = true;
|
||||
mChildActor = cacheChild;
|
||||
sProcessType = GetChildProcessType(dom::ContentChild::GetSingleton()->GetRemoteType());
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
MOZ_RELEASE_ASSERT(obs);
|
||||
|
||||
// In the child process, we need to freeze the script cache before any
|
||||
// untrusted code has been executed. The insertion of the first DOM
|
||||
// document element may sometimes be earlier than is ideal, but at
|
||||
// least it should always be safe.
|
||||
obs->AddObserver(this, DOC_ELEM_INSERTED_TOPIC, false);
|
||||
|
||||
RegisterWeakMemoryReporter(this);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче