Bug 1119878 Part 2: Change IPC code to hold ProcessID instead of ProcessHandle. r=billm, r=dvander, r=aklotz, r=cpearce
This commit is contained in:
@@ -387,30 +387,25 @@ PluginModuleContentParent::LoadModule(uint32_t aPluginId)
|
||||
|
||||
/* static */ void
|
||||
PluginModuleContentParent::AssociatePluginId(uint32_t aPluginId,
|
||||
base::ProcessId aProcessId)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
DebugOnly<PluginModuleMapping*> mapping =
|
||||
PluginModuleMapping::AssociateWithProcessId(aPluginId, aProcessId);
|
||||
PluginModuleMapping::AssociateWithProcessId(aPluginId, aOtherPid);
|
||||
MOZ_ASSERT(mapping);
|
||||
}
|
||||
|
||||
/* static */ PluginModuleContentParent*
|
||||
PluginModuleContentParent::Initialize(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
nsAutoPtr<PluginModuleMapping> moduleMapping(
|
||||
PluginModuleMapping::Resolve(aOtherProcess));
|
||||
PluginModuleMapping::Resolve(aOtherPid));
|
||||
MOZ_ASSERT(moduleMapping);
|
||||
PluginModuleContentParent* parent = moduleMapping->GetModule();
|
||||
MOZ_ASSERT(parent);
|
||||
|
||||
ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// Bug 1090578 - need to kill |aOtherProcess|, it's boned.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DebugOnly<bool> ok = parent->Open(aTransport, handle, XRE_GetIOMessageLoop(),
|
||||
DebugOnly<bool> ok = parent->Open(aTransport, aOtherPid,
|
||||
XRE_GetIOMessageLoop(),
|
||||
mozilla::ipc::ParentSide);
|
||||
MOZ_ASSERT(ok);
|
||||
|
||||
@@ -454,7 +449,7 @@ bool
|
||||
PluginModuleChromeParent::SendAssociatePluginId()
|
||||
{
|
||||
MOZ_ASSERT(mContentParent);
|
||||
return mContentParent->SendAssociatePluginId(mPluginId, OtherSidePID());
|
||||
return mContentParent->SendAssociatePluginId(mPluginId, OtherPid());
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -513,7 +508,9 @@ PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded)
|
||||
if (mAsyncInitRv != NS_ERROR_NOT_INITIALIZED || mShutdown) {
|
||||
return;
|
||||
}
|
||||
Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle());
|
||||
|
||||
Open(mSubprocess->GetChannel(),
|
||||
base::GetProcId(mSubprocess->GetChildProcessHandle()));
|
||||
|
||||
// Request Windows message deferral behavior on our channel. This
|
||||
// applies to the top level and all sub plugin protocols since they
|
||||
@@ -1221,22 +1218,29 @@ PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop)
|
||||
}
|
||||
#endif
|
||||
|
||||
mozilla::ipc::ScopedProcessHandle geckoChildProcess;
|
||||
bool childOpened = base::OpenProcessHandle(OtherPid(),
|
||||
&geckoChildProcess.rwget());
|
||||
|
||||
#ifdef XP_WIN
|
||||
// collect cpu usage for plugin processes
|
||||
|
||||
InfallibleTArray<base::ProcessHandle> processHandles;
|
||||
|
||||
processHandles.AppendElement(OtherProcess());
|
||||
if (childOpened) {
|
||||
processHandles.AppendElement(geckoChildProcess);
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
||||
{
|
||||
base::ProcessHandle handle;
|
||||
if (mFlashProcess1 && base::OpenProcessHandle(mFlashProcess1, &handle)) {
|
||||
processHandles.AppendElement(handle);
|
||||
}
|
||||
if (mFlashProcess2 && base::OpenProcessHandle(mFlashProcess2, &handle)) {
|
||||
processHandles.AppendElement(handle);
|
||||
}
|
||||
mozilla::ipc::ScopedProcessHandle flashBrokerProcess;
|
||||
if (mFlashProcess1 &&
|
||||
base::OpenProcessHandle(mFlashProcess1, &flashBrokerProcess.rwget())) {
|
||||
processHandles.AppendElement(flashBrokerProcess);
|
||||
}
|
||||
mozilla::ipc::ScopedProcessHandle flashSandboxProcess;
|
||||
if (mFlashProcess2 &&
|
||||
base::OpenProcessHandle(mFlashProcess2, &flashSandboxProcess.rwget())) {
|
||||
processHandles.AppendElement(flashSandboxProcess);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1253,8 +1257,9 @@ PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop)
|
||||
mChromeTaskFactory.NewRunnableMethod(
|
||||
&PluginModuleChromeParent::CleanupFromTimeout, isFromHangUI));
|
||||
|
||||
if (!KillProcess(OtherProcess(), 1, false))
|
||||
if (!childOpened || !KillProcess(geckoChildProcess, 1, false)) {
|
||||
NS_WARNING("failed to kill subprocess!");
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -2672,7 +2677,7 @@ PluginModuleParent::RecvPluginHideWindow(const uint32_t& aWindowId)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
||||
#if defined(XP_MACOSX)
|
||||
mac_plugin_interposing::parent::OnPluginHideWindow(aWindowId, OtherSidePID());
|
||||
mac_plugin_interposing::parent::OnPluginHideWindow(aWindowId, OtherPid());
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED(
|
||||
@@ -2893,7 +2898,15 @@ PluginModuleChromeParent::OnCrash(DWORD processID)
|
||||
{
|
||||
if (!mShutdown) {
|
||||
GetIPCChannel()->CloseWithError();
|
||||
KillProcess(OtherProcess(), 1, false);
|
||||
mozilla::ipc::ScopedProcessHandle geckoPluginChild;
|
||||
if (base::OpenProcessHandle(OtherPid(), &geckoPluginChild.rwget())) {
|
||||
if (!base::KillProcess(geckoPluginChild,
|
||||
base::PROCESS_END_KILLED_BY_USER, false)) {
|
||||
NS_ERROR("May have failed to kill child process.");
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("Failed to open child process when attempting kill.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user