Bug 1168337: Kill the processes on startup of the Nuwa test case fix the abort in the preallocated process. r=khuey
This commit is contained in:
@@ -299,6 +299,43 @@ PreallocatedProcessManagerImpl::GetSpareProcess()
|
||||
return process.forget();
|
||||
}
|
||||
|
||||
static bool
|
||||
TestCaseEnabled()
|
||||
{
|
||||
return Preferences::GetBool("dom.ipc.preallocatedProcessManager.testMode");
|
||||
}
|
||||
|
||||
static void
|
||||
SendTestOnlyNotification(const char* aMessage)
|
||||
{
|
||||
if (!TestCaseEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoSafeJSContext cx;
|
||||
nsString message;
|
||||
message.AppendPrintf("%s", aMessage);
|
||||
|
||||
nsCOMPtr<nsIMessageBroadcaster> ppmm =
|
||||
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
|
||||
|
||||
mozilla::unused << ppmm->BroadcastAsyncMessage(
|
||||
message, JS::NullHandleValue, JS::NullHandleValue, cx, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
KillOrCloseProcess(ContentParent* aProcess)
|
||||
{
|
||||
if (TestCaseEnabled()) {
|
||||
// KillHard() the process because we don't want the process to abort when we
|
||||
// close the IPC channel while it's still running and creating actors.
|
||||
aProcess->KillHard("Killed by test case.");
|
||||
}
|
||||
else {
|
||||
aProcess->Close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a ContentParent to spare process list.
|
||||
*/
|
||||
@@ -307,14 +344,7 @@ PreallocatedProcessManagerImpl::PublishSpareProcess(ContentParent* aContent)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (Preferences::GetBool("dom.ipc.preallocatedProcessManager.testMode")) {
|
||||
AutoJSContext cx;
|
||||
nsCOMPtr<nsIMessageBroadcaster> ppmm =
|
||||
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
|
||||
mozilla::unused << ppmm->BroadcastAsyncMessage(
|
||||
NS_LITERAL_STRING("TEST-ONLY:nuwa-add-new-process"),
|
||||
JS::NullHandleValue, JS::NullHandleValue, cx, 1);
|
||||
}
|
||||
SendTestOnlyNotification("TEST-ONLY:nuwa-add-new-process");
|
||||
|
||||
mSpareProcesses.AppendElement(aContent);
|
||||
}
|
||||
@@ -333,7 +363,7 @@ PreallocatedProcessManagerImpl::MaybeForgetSpare(ContentParent* aContent)
|
||||
mIsNuwaReady = false;
|
||||
while (mSpareProcesses.Length() > 0) {
|
||||
nsRefPtr<ContentParent> process = mSpareProcesses[mSpareProcesses.Length() - 1];
|
||||
process->Close();
|
||||
KillOrCloseProcess(aContent);
|
||||
mSpareProcesses.RemoveElementAt(mSpareProcesses.Length() - 1);
|
||||
}
|
||||
ScheduleDelayedNuwaFork();
|
||||
@@ -353,14 +383,8 @@ PreallocatedProcessManagerImpl::OnNuwaReady()
|
||||
ProcessPriorityManager::SetProcessPriority(mPreallocatedAppProcess,
|
||||
hal::PROCESS_PRIORITY_MASTER);
|
||||
mIsNuwaReady = true;
|
||||
if (Preferences::GetBool("dom.ipc.preallocatedProcessManager.testMode")) {
|
||||
AutoJSContext cx;
|
||||
nsCOMPtr<nsIMessageBroadcaster> ppmm =
|
||||
do_GetService("@mozilla.org/parentprocessmessagemanager;1");
|
||||
mozilla::unused << ppmm->BroadcastAsyncMessage(
|
||||
NS_LITERAL_STRING("TEST-ONLY:nuwa-ready"),
|
||||
JS::NullHandleValue, JS::NullHandleValue, cx, 1);
|
||||
}
|
||||
SendTestOnlyNotification("TEST-ONLY:nuwa-ready");
|
||||
|
||||
NuwaFork();
|
||||
}
|
||||
|
||||
@@ -370,7 +394,6 @@ PreallocatedProcessManagerImpl::PreallocatedProcessReady()
|
||||
return !mSpareProcesses.IsEmpty();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::NuwaFork()
|
||||
{
|
||||
@@ -399,7 +422,7 @@ PreallocatedProcessManagerImpl::Disable()
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
while (mSpareProcesses.Length() > 0){
|
||||
nsRefPtr<ContentParent> process = mSpareProcesses[0];
|
||||
process->Close();
|
||||
KillOrCloseProcess(process);
|
||||
mSpareProcesses.RemoveElementAt(0);
|
||||
}
|
||||
mIsNuwaReady = false;
|
||||
|
||||
Reference in New Issue
Block a user