зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1146874
Part 3: Add LaunchSubprocess function to ContentParent to remove fallible code from constructor. r=billm
This commit is contained in:
Родитель
c180b80463
Коммит
6c45277de4
|
@ -679,8 +679,12 @@ ContentParent::RunNuwaProcess()
|
||||||
/* aOpener = */ nullptr,
|
/* aOpener = */ nullptr,
|
||||||
/* aIsForBrowser = */ false,
|
/* aIsForBrowser = */ false,
|
||||||
/* aIsForPreallocated = */ true,
|
/* aIsForPreallocated = */ true,
|
||||||
PROCESS_PRIORITY_BACKGROUND,
|
|
||||||
/* aIsNuwaProcess = */ true);
|
/* aIsNuwaProcess = */ true);
|
||||||
|
|
||||||
|
if (!nuwaProcess->LaunchSubprocess(PROCESS_PRIORITY_BACKGROUND)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
nuwaProcess->Init();
|
nuwaProcess->Init();
|
||||||
#ifdef MOZ_NUWA_PROCESS
|
#ifdef MOZ_NUWA_PROCESS
|
||||||
sNuwaPid = nuwaProcess->Pid();
|
sNuwaPid = nuwaProcess->Pid();
|
||||||
|
@ -699,8 +703,12 @@ ContentParent::PreallocateAppProcess()
|
||||||
new ContentParent(/* app = */ nullptr,
|
new ContentParent(/* app = */ nullptr,
|
||||||
/* aOpener = */ nullptr,
|
/* aOpener = */ nullptr,
|
||||||
/* isForBrowserElement = */ false,
|
/* isForBrowserElement = */ false,
|
||||||
/* isForPreallocated = */ true,
|
/* isForPreallocated = */ true);
|
||||||
PROCESS_PRIORITY_PREALLOC);
|
|
||||||
|
if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
process->Init();
|
process->Init();
|
||||||
return process.forget();
|
return process.forget();
|
||||||
}
|
}
|
||||||
|
@ -743,8 +751,12 @@ ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
|
||||||
process = new ContentParent(aApp,
|
process = new ContentParent(aApp,
|
||||||
/* aOpener = */ aOpener,
|
/* aOpener = */ aOpener,
|
||||||
/* isForBrowserElement = */ false,
|
/* isForBrowserElement = */ false,
|
||||||
/* isForPreallocated = */ false,
|
/* isForPreallocated = */ false);
|
||||||
aInitialPriority);
|
|
||||||
|
if (!process->LaunchSubprocess(aInitialPriority)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
process->Init();
|
process->Init();
|
||||||
process->ForwardKnownInfo();
|
process->ForwardKnownInfo();
|
||||||
|
|
||||||
|
@ -888,8 +900,12 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
|
||||||
p = new ContentParent(/* app = */ nullptr,
|
p = new ContentParent(/* app = */ nullptr,
|
||||||
aOpener,
|
aOpener,
|
||||||
aForBrowserElement,
|
aForBrowserElement,
|
||||||
/* isForPreallocated = */ false,
|
/* isForPreallocated = */ false);
|
||||||
aPriority);
|
|
||||||
|
if (!p->LaunchSubprocess(aPriority)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
p->Init();
|
p->Init();
|
||||||
}
|
}
|
||||||
p->ForwardKnownInfo();
|
p->ForwardKnownInfo();
|
||||||
|
@ -1158,6 +1174,9 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
|
||||||
constructorSender =
|
constructorSender =
|
||||||
GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
|
GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
|
||||||
initialPriority);
|
initialPriority);
|
||||||
|
if (!constructorSender) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tabId = AllocateTabId(openerTabId,
|
tabId = AllocateTabId(openerTabId,
|
||||||
aContext.AsIPCTabContext(),
|
aContext.AsIPCTabContext(),
|
||||||
|
@ -2189,11 +2208,40 @@ ContentParent::InitializeMembers()
|
||||||
mHangMonitorActor = nullptr;
|
mHangMonitorActor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PRIORITY_FOREGROUND */)
|
||||||
|
{
|
||||||
|
std::vector<std::string> extraArgs;
|
||||||
|
if (mIsNuwaProcess) {
|
||||||
|
extraArgs.push_back("-nuwa");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mSubprocess->LaunchAndWaitForProcessHandle(extraArgs)) {
|
||||||
|
MarkAsDead();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Open(mSubprocess->GetChannel(),
|
||||||
|
base::GetProcId(mSubprocess->GetChildProcessHandle()));
|
||||||
|
|
||||||
|
InitInternal(aInitialPriority,
|
||||||
|
true, /* Setup off-main thread compositing */
|
||||||
|
true /* Send registered chrome */);
|
||||||
|
|
||||||
|
ContentProcessManager::GetSingleton()->AddContentProcess(this);
|
||||||
|
|
||||||
|
ProcessHangMonitor::AddProcess(this);
|
||||||
|
|
||||||
|
// Set a reply timeout for CPOWs.
|
||||||
|
SetReplyTimeoutMs(Preferences::GetInt("dom.ipc.cpow.timeout", 0));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ContentParent::ContentParent(mozIApplication* aApp,
|
ContentParent::ContentParent(mozIApplication* aApp,
|
||||||
ContentParent* aOpener,
|
ContentParent* aOpener,
|
||||||
bool aIsForBrowser,
|
bool aIsForBrowser,
|
||||||
bool aIsForPreallocated,
|
bool aIsForPreallocated,
|
||||||
ProcessPriority aInitialPriority /* = PROCESS_PRIORITY_FOREGROUND */,
|
|
||||||
bool aIsNuwaProcess /* = false */)
|
bool aIsNuwaProcess /* = false */)
|
||||||
: nsIContentParent()
|
: nsIContentParent()
|
||||||
, mOpener(aOpener)
|
, mOpener(aOpener)
|
||||||
|
@ -2247,26 +2295,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
|
||||||
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, privs);
|
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, privs);
|
||||||
|
|
||||||
IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
|
IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
|
||||||
|
|
||||||
std::vector<std::string> extraArgs;
|
|
||||||
if (aIsNuwaProcess) {
|
|
||||||
extraArgs.push_back("-nuwa");
|
|
||||||
}
|
|
||||||
mSubprocess->LaunchAndWaitForProcessHandle(extraArgs);
|
|
||||||
|
|
||||||
Open(mSubprocess->GetChannel(),
|
|
||||||
base::GetProcId(mSubprocess->GetChildProcessHandle()));
|
|
||||||
|
|
||||||
InitInternal(aInitialPriority,
|
|
||||||
true, /* Setup off-main thread compositing */
|
|
||||||
true /* Send registered chrome */);
|
|
||||||
|
|
||||||
ContentProcessManager::GetSingleton()->AddContentProcess(this);
|
|
||||||
|
|
||||||
ProcessHangMonitor::AddProcess(this);
|
|
||||||
|
|
||||||
// Set a reply timeout for CPOWs.
|
|
||||||
SetReplyTimeoutMs(Preferences::GetInt("dom.ipc.cpow.timeout", 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOZ_NUWA_PROCESS
|
#ifdef MOZ_NUWA_PROCESS
|
||||||
|
|
|
@ -433,7 +433,6 @@ private:
|
||||||
ContentParent* aOpener,
|
ContentParent* aOpener,
|
||||||
bool aIsForBrowser,
|
bool aIsForBrowser,
|
||||||
bool aIsForPreallocated,
|
bool aIsForPreallocated,
|
||||||
hal::ProcessPriority aInitialPriority = hal::PROCESS_PRIORITY_FOREGROUND,
|
|
||||||
bool aIsNuwaProcess = false);
|
bool aIsNuwaProcess = false);
|
||||||
|
|
||||||
#ifdef MOZ_NUWA_PROCESS
|
#ifdef MOZ_NUWA_PROCESS
|
||||||
|
@ -446,7 +445,11 @@ private:
|
||||||
// The common initialization for the constructors.
|
// The common initialization for the constructors.
|
||||||
void InitializeMembers();
|
void InitializeMembers();
|
||||||
|
|
||||||
// The common initialization logic shared by all constuctors.
|
// Launch the subprocess and associated initialization.
|
||||||
|
// Returns false if the process fails to start.
|
||||||
|
bool LaunchSubprocess(hal::ProcessPriority aInitialPriority = hal::PROCESS_PRIORITY_FOREGROUND);
|
||||||
|
|
||||||
|
// Common initialization after sub process launch or adoption.
|
||||||
void InitInternal(ProcessPriority aPriority,
|
void InitInternal(ProcessPriority aPriority,
|
||||||
bool aSetupOffMainThreadCompositing,
|
bool aSetupOffMainThreadCompositing,
|
||||||
bool aSendRegisteredChrome);
|
bool aSendRegisteredChrome);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче