зеркало из 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,
|
||||
/* aIsForBrowser = */ false,
|
||||
/* aIsForPreallocated = */ true,
|
||||
PROCESS_PRIORITY_BACKGROUND,
|
||||
/* aIsNuwaProcess = */ true);
|
||||
|
||||
if (!nuwaProcess->LaunchSubprocess(PROCESS_PRIORITY_BACKGROUND)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nuwaProcess->Init();
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
sNuwaPid = nuwaProcess->Pid();
|
||||
|
@ -699,8 +703,12 @@ ContentParent::PreallocateAppProcess()
|
|||
new ContentParent(/* app = */ nullptr,
|
||||
/* aOpener = */ nullptr,
|
||||
/* isForBrowserElement = */ false,
|
||||
/* isForPreallocated = */ true,
|
||||
PROCESS_PRIORITY_PREALLOC);
|
||||
/* isForPreallocated = */ true);
|
||||
|
||||
if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
process->Init();
|
||||
return process.forget();
|
||||
}
|
||||
|
@ -743,8 +751,12 @@ ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
|
|||
process = new ContentParent(aApp,
|
||||
/* aOpener = */ aOpener,
|
||||
/* isForBrowserElement = */ false,
|
||||
/* isForPreallocated = */ false,
|
||||
aInitialPriority);
|
||||
/* isForPreallocated = */ false);
|
||||
|
||||
if (!process->LaunchSubprocess(aInitialPriority)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
process->Init();
|
||||
process->ForwardKnownInfo();
|
||||
|
||||
|
@ -888,8 +900,12 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
|
|||
p = new ContentParent(/* app = */ nullptr,
|
||||
aOpener,
|
||||
aForBrowserElement,
|
||||
/* isForPreallocated = */ false,
|
||||
aPriority);
|
||||
/* isForPreallocated = */ false);
|
||||
|
||||
if (!p->LaunchSubprocess(aPriority)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
p->Init();
|
||||
}
|
||||
p->ForwardKnownInfo();
|
||||
|
@ -1158,6 +1174,9 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
|
|||
constructorSender =
|
||||
GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
|
||||
initialPriority);
|
||||
if (!constructorSender) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
tabId = AllocateTabId(openerTabId,
|
||||
aContext.AsIPCTabContext(),
|
||||
|
@ -2189,11 +2208,40 @@ ContentParent::InitializeMembers()
|
|||
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* aOpener,
|
||||
bool aIsForBrowser,
|
||||
bool aIsForPreallocated,
|
||||
ProcessPriority aInitialPriority /* = PROCESS_PRIORITY_FOREGROUND */,
|
||||
bool aIsNuwaProcess /* = false */)
|
||||
: nsIContentParent()
|
||||
, mOpener(aOpener)
|
||||
|
@ -2247,26 +2295,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
|
|||
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, privs);
|
||||
|
||||
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
|
||||
|
|
|
@ -433,7 +433,6 @@ private:
|
|||
ContentParent* aOpener,
|
||||
bool aIsForBrowser,
|
||||
bool aIsForPreallocated,
|
||||
hal::ProcessPriority aInitialPriority = hal::PROCESS_PRIORITY_FOREGROUND,
|
||||
bool aIsNuwaProcess = false);
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
|
@ -446,7 +445,11 @@ private:
|
|||
// The common initialization for the constructors.
|
||||
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,
|
||||
bool aSetupOffMainThreadCompositing,
|
||||
bool aSendRegisteredChrome);
|
||||
|
|
Загрузка…
Ссылка в новой задаче