зеркало из https://github.com/mozilla/gecko-dev.git
Bug 968604 Part 1: Fork the browser process from Nuwa. r=khuey
--HG-- extra : rebase_source : db94e3799dc8800b45e554fa07ef3f84a5cd5d78
This commit is contained in:
Родитель
40a503ac81
Коммит
da57d4296a
|
@ -438,14 +438,22 @@ ContentChild::Init(MessageLoop* aIOLoop,
|
|||
XRE_GetProcessType());
|
||||
#endif
|
||||
|
||||
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
|
||||
|
||||
GetCPOWManager();
|
||||
|
||||
InitProcessAttributes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ContentChild::InitProcessAttributes()
|
||||
{
|
||||
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (IsNuwaProcess()) {
|
||||
SetProcessName(NS_LITERAL_STRING("(Nuwa)"));
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (mIsForApp && !mIsForBrowser) {
|
||||
|
@ -454,7 +462,6 @@ ContentChild::Init(MessageLoop* aIOLoop,
|
|||
SetProcessName(NS_LITERAL_STRING("Browser"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -794,6 +801,10 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
|
|||
MOZ_ASSERT(!sFirstIdleTask);
|
||||
sFirstIdleTask = NewRunnableFunction(FirstIdle);
|
||||
MessageLoop::current()->PostIdleTask(FROM_HERE, sFirstIdleTask);
|
||||
|
||||
// Redo InitProcessAttributes() when the app or browser is really
|
||||
// launching so the attributes will be correct.
|
||||
InitProcessAttributes();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
bool Init(MessageLoop* aIOLoop,
|
||||
base::ProcessHandle aParentHandle,
|
||||
IPC::Channel* aChannel);
|
||||
void InitProcessAttributes();
|
||||
void InitXPCOM();
|
||||
|
||||
static ContentChild* GetSingleton() {
|
||||
|
|
|
@ -577,11 +577,24 @@ ContentParent::GetNewOrUsed(bool aForBrowserElement)
|
|||
return p.forget();
|
||||
}
|
||||
|
||||
nsRefPtr<ContentParent> p =
|
||||
new ContentParent(/* app = */ nullptr,
|
||||
aForBrowserElement,
|
||||
/* isForPreallocated = */ false,
|
||||
PROCESS_PRIORITY_FOREGROUND);
|
||||
// Try to take and transform the preallocated process into browser.
|
||||
nsRefPtr<ContentParent> p = PreallocatedProcessManager::Take();
|
||||
if (p) {
|
||||
p->TransformPreallocatedIntoBrowser();
|
||||
} else {
|
||||
// Failed in using the preallocated process: fork from the chrome process.
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
|
||||
// Wait until the Nuwa process forks a new process.
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
p = new ContentParent(/* app = */ nullptr,
|
||||
aForBrowserElement,
|
||||
/* isForPreallocated = */ false,
|
||||
PROCESS_PRIORITY_FOREGROUND);
|
||||
}
|
||||
|
||||
p->Init();
|
||||
sNonAppContentParents->AppendElement(p);
|
||||
return p.forget();
|
||||
|
@ -969,6 +982,14 @@ ContentParent::TransformPreallocatedIntoApp(const nsAString& aAppManifestURL)
|
|||
TryGetNameFromManifestURL(aAppManifestURL, mAppName);
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::TransformPreallocatedIntoBrowser()
|
||||
{
|
||||
// Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
|
||||
mAppManifestURL.Truncate();
|
||||
mIsForBrowser = true;
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::ShutDownProcess(bool aCloseWithError)
|
||||
{
|
||||
|
|
|
@ -297,6 +297,10 @@ private:
|
|||
// process, for the specified manifest URL.
|
||||
void TransformPreallocatedIntoApp(const nsAString& aAppManifestURL);
|
||||
|
||||
// Transform a pre-allocated app process into a browser process. If this
|
||||
// returns false, the child process has died.
|
||||
void TransformPreallocatedIntoBrowser();
|
||||
|
||||
/**
|
||||
* Mark this ContentParent as dead for the purposes of Get*().
|
||||
* This method is idempotent.
|
||||
|
|
Загрузка…
Ссылка в новой задаче