mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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:
parent
8e1e75d04b
commit
666e96adb9
@ -39,18 +39,13 @@ ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
}
|
||||
|
||||
/*static*/ ContentBridgeChild*
|
||||
ContentBridgeChild::Create(Transport* aTransport, ProcessId aOtherProcess)
|
||||
ContentBridgeChild::Create(Transport* aTransport, ProcessId aOtherPid)
|
||||
{
|
||||
nsRefPtr<ContentBridgeChild> bridge =
|
||||
new ContentBridgeChild(aTransport);
|
||||
ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// XXX need to kill |aOtherProcess|, it's boned
|
||||
return nullptr;
|
||||
}
|
||||
bridge->mSelfRef = bridge;
|
||||
|
||||
DebugOnly<bool> ok = bridge->Open(aTransport, handle, XRE_GetIOMessageLoop());
|
||||
DebugOnly<bool> ok = bridge->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop());
|
||||
MOZ_ASSERT(ok);
|
||||
return bridge;
|
||||
}
|
||||
|
@ -42,18 +42,14 @@ ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
}
|
||||
|
||||
/*static*/ ContentBridgeParent*
|
||||
ContentBridgeParent::Create(Transport* aTransport, ProcessId aOtherProcess)
|
||||
ContentBridgeParent::Create(Transport* aTransport, ProcessId aOtherPid)
|
||||
{
|
||||
nsRefPtr<ContentBridgeParent> bridge =
|
||||
new ContentBridgeParent(aTransport);
|
||||
ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// XXX need to kill |aOtherProcess|, it's boned
|
||||
return nullptr;
|
||||
}
|
||||
bridge->mSelfRef = bridge;
|
||||
|
||||
DebugOnly<bool> ok = bridge->Open(aTransport, handle, XRE_GetIOMessageLoop());
|
||||
DebugOnly<bool> ok = bridge->Open(aTransport, aOtherPid,
|
||||
XRE_GetIOMessageLoop());
|
||||
MOZ_ASSERT(ok);
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
|
@ -607,7 +607,7 @@ NS_INTERFACE_MAP_END
|
||||
|
||||
bool
|
||||
ContentChild::Init(MessageLoop* aIOLoop,
|
||||
base::ProcessHandle aParentHandle,
|
||||
base::ProcessId aParentPid,
|
||||
IPC::Channel* aChannel)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
@ -639,7 +639,7 @@ ContentChild::Init(MessageLoop* aIOLoop,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Open(aChannel, aParentHandle, aIOLoop)) {
|
||||
if (!Open(aChannel, aParentPid, aIOLoop)) {
|
||||
return false;
|
||||
}
|
||||
sSingleton = this;
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
};
|
||||
|
||||
bool Init(MessageLoop* aIOLoop,
|
||||
base::ProcessHandle aParentHandle,
|
||||
base::ProcessId aParentPid,
|
||||
IPC::Channel* aChannel);
|
||||
void InitProcessAttributes();
|
||||
void InitXPCOM();
|
||||
|
@ -1716,39 +1716,31 @@ ContentParent::OnBeginSyncTransaction() {
|
||||
void
|
||||
ContentParent::OnChannelConnected(int32_t pid)
|
||||
{
|
||||
ProcessHandle handle;
|
||||
if (!base::OpenPrivilegedProcessHandle(pid, &handle)) {
|
||||
NS_WARNING("Can't open handle to child process.");
|
||||
}
|
||||
else {
|
||||
// we need to close the existing handle before setting a new one.
|
||||
base::CloseProcessHandle(OtherProcess());
|
||||
SetOtherProcess(handle);
|
||||
SetOtherProcessId(pid);
|
||||
|
||||
#if defined(ANDROID) || defined(LINUX)
|
||||
// Check nice preference
|
||||
int32_t nice = Preferences::GetInt("dom.ipc.content.nice", 0);
|
||||
// Check nice preference
|
||||
int32_t nice = Preferences::GetInt("dom.ipc.content.nice", 0);
|
||||
|
||||
// Environment variable overrides preference
|
||||
char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
|
||||
if (relativeNicenessStr) {
|
||||
nice = atoi(relativeNicenessStr);
|
||||
}
|
||||
|
||||
/* make the GUI thread have higher priority on single-cpu devices */
|
||||
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
|
||||
if (infoService) {
|
||||
int32_t cpus;
|
||||
nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
|
||||
if (NS_FAILED(rv)) {
|
||||
cpus = 1;
|
||||
}
|
||||
if (nice != 0 && cpus == 1) {
|
||||
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Environment variable overrides preference
|
||||
char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
|
||||
if (relativeNicenessStr) {
|
||||
nice = atoi(relativeNicenessStr);
|
||||
}
|
||||
|
||||
/* make the GUI thread have higher priority on single-cpu devices */
|
||||
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
|
||||
if (infoService) {
|
||||
int32_t cpus;
|
||||
nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
|
||||
if (NS_FAILED(rv)) {
|
||||
cpus = 1;
|
||||
}
|
||||
if (nice != 0 && cpus == 1) {
|
||||
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -2154,7 +2146,8 @@ ContentParent::ContentParent(mozIApplication* aApp,
|
||||
}
|
||||
mSubprocess->LaunchAndWaitForProcessHandle(extraArgs);
|
||||
|
||||
Open(mSubprocess->GetChannel(), mSubprocess->GetOwnedChildProcessHandle());
|
||||
Open(mSubprocess->GetChannel(),
|
||||
base::GetProcId(mSubprocess->GetChildProcessHandle()));
|
||||
|
||||
InitInternal(aInitialPriority,
|
||||
true, /* Setup off-main thread compositing */
|
||||
@ -2228,7 +2221,7 @@ ContentParent::ContentParent(ContentParent* aTemplate,
|
||||
CloneOpenedToplevels(aTemplate, aFds, aPid, &cloneContext);
|
||||
|
||||
Open(mSubprocess->GetChannel(),
|
||||
mSubprocess->GetChildProcessHandle());
|
||||
base::GetProcId(mSubprocess->GetChildProcessHandle()));
|
||||
|
||||
// Set the subprocess's priority (bg if we're a preallocated process, fg
|
||||
// otherwise). We do this first because we're likely /lowering/ its CPU and
|
||||
@ -2256,9 +2249,6 @@ ContentParent::~ContentParent()
|
||||
mForceKillTimer->Cancel();
|
||||
}
|
||||
|
||||
if (OtherProcess())
|
||||
base::CloseProcessHandle(OtherProcess());
|
||||
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
// We should be removed from all these lists in ActorDestroy.
|
||||
@ -3303,19 +3293,26 @@ ContentParent::KillHard(const char* aReason)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!KillProcess(OtherProcess(), 1, false)) {
|
||||
ProcessHandle otherProcessHandle;
|
||||
if (!base::OpenProcessHandle(OtherPid(), &otherProcessHandle)) {
|
||||
NS_ERROR("Failed to open child process when attempting kill.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!KillProcess(otherProcessHandle, base::PROCESS_END_KILLED_BY_USER,
|
||||
false)) {
|
||||
NS_WARNING("failed to kill subprocess!");
|
||||
}
|
||||
|
||||
if (mSubprocess) {
|
||||
mSubprocess->SetAlreadyDead();
|
||||
}
|
||||
|
||||
// EnsureProcessTerminated has responsibilty for closing otherProcessHandle.
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(&ProcessWatcher::EnsureProcessTerminated,
|
||||
OtherProcess(), /*force=*/true));
|
||||
// We've now closed the OtherProcess() handle, so must set it to null to
|
||||
// prevent our dtor closing it twice.
|
||||
SetOtherProcess(0);
|
||||
otherProcessHandle, /*force=*/true));
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -23,7 +23,7 @@ bool
|
||||
ContentProcess::Init()
|
||||
{
|
||||
mContent.Init(IOThreadChild::message_loop(),
|
||||
ParentHandle(),
|
||||
ParentPid(),
|
||||
IOThreadChild::channel());
|
||||
mXREEmbed.Start();
|
||||
mContent.InitXPCOM();
|
||||
|
@ -23,8 +23,8 @@ class ContentProcess : public mozilla::ipc::ProcessChild
|
||||
typedef mozilla::ipc::ProcessChild ProcessChild;
|
||||
|
||||
public:
|
||||
explicit ContentProcess(ProcessHandle mParentHandle)
|
||||
: ProcessChild(mParentHandle)
|
||||
explicit ContentProcess(ProcessId aParentPid)
|
||||
: ProcessChild(aParentPid)
|
||||
{ }
|
||||
|
||||
~ContentProcess()
|
||||
|
@ -111,11 +111,14 @@ template<class Toplevel>
|
||||
inline bool
|
||||
CrashReporterParent::GeneratePairedMinidump(Toplevel* t)
|
||||
{
|
||||
CrashReporter::ProcessHandle child;
|
||||
mozilla::ipc::ScopedProcessHandle child;
|
||||
#ifdef XP_MACOSX
|
||||
child = t->Process()->GetChildTask();
|
||||
#else
|
||||
child = t->OtherProcess();
|
||||
if (!base::OpenPrivilegedProcessHandle(t->OtherPid(), &child.rwget())) {
|
||||
NS_WARNING("Failed to open child process handle.");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
nsCOMPtr<nsIFile> childDump;
|
||||
if (CrashReporter::CreatePairedMinidumps(child,
|
||||
|
@ -69,7 +69,7 @@ class HangMonitorChild
|
||||
explicit HangMonitorChild(ProcessHangMonitor* aMonitor);
|
||||
virtual ~HangMonitorChild();
|
||||
|
||||
void Open(Transport* aTransport, ProcessHandle aHandle,
|
||||
void Open(Transport* aTransport, ProcessId aOtherPid,
|
||||
MessageLoop* aIOLoop);
|
||||
|
||||
typedef ProcessHangMonitor::SlowScriptAction SlowScriptAction;
|
||||
@ -171,8 +171,7 @@ public:
|
||||
explicit HangMonitorParent(ProcessHangMonitor* aMonitor);
|
||||
virtual ~HangMonitorParent();
|
||||
|
||||
void Open(Transport* aTransport, ProcessHandle aHandle,
|
||||
MessageLoop* aIOLoop);
|
||||
void Open(Transport* aTransport, ProcessId aPid, MessageLoop* aIOLoop);
|
||||
|
||||
virtual bool RecvHangEvidence(const HangData& aHangData) override;
|
||||
|
||||
@ -312,7 +311,7 @@ HangMonitorChild::RecvEndStartingDebugger()
|
||||
}
|
||||
|
||||
void
|
||||
HangMonitorChild::Open(Transport* aTransport, ProcessHandle aHandle,
|
||||
HangMonitorChild::Open(Transport* aTransport, ProcessId aPid,
|
||||
MessageLoop* aIOLoop)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop());
|
||||
@ -320,7 +319,7 @@ HangMonitorChild::Open(Transport* aTransport, ProcessHandle aHandle,
|
||||
MOZ_ASSERT(!sInstance);
|
||||
sInstance = this;
|
||||
|
||||
DebugOnly<bool> ok = PProcessHangMonitorChild::Open(aTransport, aHandle, aIOLoop);
|
||||
DebugOnly<bool> ok = PProcessHangMonitorChild::Open(aTransport, aPid, aIOLoop);
|
||||
MOZ_ASSERT(ok);
|
||||
}
|
||||
|
||||
@ -489,12 +488,12 @@ HangMonitorParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
}
|
||||
|
||||
void
|
||||
HangMonitorParent::Open(Transport* aTransport, ProcessHandle aHandle,
|
||||
HangMonitorParent::Open(Transport* aTransport, ProcessId aPid,
|
||||
MessageLoop* aIOLoop)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop());
|
||||
|
||||
DebugOnly<bool> ok = PProcessHangMonitorParent::Open(aTransport, aHandle, aIOLoop);
|
||||
DebugOnly<bool> ok = PProcessHangMonitorParent::Open(aTransport, aPid, aIOLoop);
|
||||
MOZ_ASSERT(ok);
|
||||
}
|
||||
|
||||
@ -883,7 +882,7 @@ ProcessHangMonitor::NotifyPluginHang(uint32_t aPluginId)
|
||||
PProcessHangMonitorParent*
|
||||
mozilla::CreateHangMonitorParent(ContentParent* aContentParent,
|
||||
mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -893,39 +892,27 @@ mozilla::CreateHangMonitorParent(ContentParent* aContentParent,
|
||||
HangMonitoredProcess* process = new HangMonitoredProcess(parent, aContentParent);
|
||||
parent->SetProcess(process);
|
||||
|
||||
base::ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// XXX need to kill |aOtherProcess|, it's boned
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
monitor->MonitorLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(parent, &HangMonitorParent::Open,
|
||||
aTransport, handle, XRE_GetIOMessageLoop()));
|
||||
aTransport, aOtherPid, XRE_GetIOMessageLoop()));
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
PProcessHangMonitorChild*
|
||||
mozilla::CreateHangMonitorChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
||||
ProcessHangMonitor* monitor = ProcessHangMonitor::GetOrCreate();
|
||||
HangMonitorChild* child = new HangMonitorChild(monitor);
|
||||
|
||||
base::ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// XXX need to kill |aOtherProcess|, it's boned
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
monitor->MonitorLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(child, &HangMonitorChild::Open,
|
||||
aTransport, handle, XRE_GetIOMessageLoop()));
|
||||
aTransport, aOtherPid, XRE_GetIOMessageLoop()));
|
||||
|
||||
return child;
|
||||
}
|
||||
|
@ -265,13 +265,13 @@ GMPChild::CheckThread()
|
||||
bool
|
||||
GMPChild::Init(const std::string& aPluginPath,
|
||||
const std::string& aVoucherPath,
|
||||
base::ProcessHandle aParentProcessHandle,
|
||||
base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel)
|
||||
{
|
||||
LOGD("%s pluginPath=%s", __FUNCTION__, aPluginPath.c_str());
|
||||
|
||||
if (NS_WARN_IF(!Open(aChannel, aParentProcessHandle, aIOLoop))) {
|
||||
if (NS_WARN_IF(!Open(aChannel, aParentPid, aIOLoop))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
|
||||
bool Init(const std::string& aPluginPath,
|
||||
const std::string& aVoucherPath,
|
||||
base::ProcessHandle aParentProcessHandle,
|
||||
base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel);
|
||||
#ifdef XP_WIN
|
||||
|
@ -149,7 +149,8 @@ GMPParent::LoadProcess()
|
||||
mChildPid = base::GetProcId(mProcess->GetChildProcessHandle());
|
||||
#endif
|
||||
|
||||
bool opened = Open(mProcess->GetChannel(), mProcess->GetChildProcessHandle());
|
||||
bool opened = Open(mProcess->GetChannel(),
|
||||
base::GetProcId(mProcess->GetChildProcessHandle()));
|
||||
if (!opened) {
|
||||
LOGD("%s: Failed to create new child process", __FUNCTION__);
|
||||
mProcess->Delete();
|
||||
|
@ -16,8 +16,8 @@ using mozilla::ipc::IOThreadChild;
|
||||
namespace mozilla {
|
||||
namespace gmp {
|
||||
|
||||
GMPProcessChild::GMPProcessChild(ProcessHandle parentHandle)
|
||||
: ProcessChild(parentHandle)
|
||||
GMPProcessChild::GMPProcessChild(ProcessId aParentPid)
|
||||
: ProcessChild(aParentPid)
|
||||
{
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ GMPProcessChild::Init()
|
||||
|
||||
return mPlugin.Init(pluginFilename,
|
||||
voucherFilename,
|
||||
ParentHandle(),
|
||||
ParentPid(),
|
||||
IOThreadChild::message_loop(),
|
||||
IOThreadChild::channel());
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ protected:
|
||||
typedef mozilla::ipc::ProcessChild ProcessChild;
|
||||
|
||||
public:
|
||||
explicit GMPProcessChild(ProcessHandle parentHandle);
|
||||
explicit GMPProcessChild(ProcessId aParentPid);
|
||||
~GMPProcessChild();
|
||||
|
||||
virtual bool Init() override;
|
||||
|
@ -3393,7 +3393,7 @@ PluginInstanceChild::ShowPluginFrame()
|
||||
SharedDIBSurface* s = static_cast<SharedDIBSurface*>(mCurrentSurface.get());
|
||||
if (!mCurrentSurfaceActor) {
|
||||
base::SharedMemoryHandle handle = nullptr;
|
||||
s->ShareToProcess(OtherProcess(), &handle);
|
||||
s->ShareToProcess(OtherPid(), &handle);
|
||||
|
||||
mCurrentSurfaceActor =
|
||||
SendPPluginSurfaceConstructor(handle,
|
||||
|
@ -1940,8 +1940,9 @@ PluginInstanceParent::SharedSurfaceSetWindow(const NPWindow* aWindow,
|
||||
mSharedSize = newPort;
|
||||
|
||||
base::SharedMemoryHandle handle;
|
||||
if (NS_FAILED(mSharedSurfaceDib.ShareToProcess(OtherProcess(), &handle)))
|
||||
if (NS_FAILED(mSharedSurfaceDib.ShareToProcess(OtherPid(), &handle))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aRemoteWindow.surfaceHandle = handle;
|
||||
|
||||
|
@ -110,16 +110,11 @@ struct RunnableMethodTraits<PluginModuleChild>
|
||||
/* static */
|
||||
PluginModuleChild*
|
||||
PluginModuleChild::CreateForContentProcess(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
PluginModuleChild* child = new PluginModuleChild(false);
|
||||
ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// XXX need to kill |aOtherProcess|, it's boned
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!child->InitForContent(handle, XRE_GetIOMessageLoop(), aTransport)) {
|
||||
if (!child->InitForContent(aOtherPid, XRE_GetIOMessageLoop(), aTransport)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -206,7 +201,7 @@ PluginModuleChild::GetChrome()
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleChild::CommonInit(base::ProcessHandle aParentProcessHandle,
|
||||
PluginModuleChild::CommonInit(base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel)
|
||||
{
|
||||
@ -218,8 +213,9 @@ PluginModuleChild::CommonInit(base::ProcessHandle aParentProcessHandle,
|
||||
// Bug 1090573 - Don't do this for connections to content processes.
|
||||
GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
|
||||
|
||||
if (!Open(aChannel, aParentProcessHandle, aIOLoop))
|
||||
if (!Open(aChannel, aParentPid, aIOLoop)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memset((void*) &mFunctions, 0, sizeof(mFunctions));
|
||||
mFunctions.size = sizeof(mFunctions);
|
||||
@ -229,11 +225,11 @@ PluginModuleChild::CommonInit(base::ProcessHandle aParentProcessHandle,
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleChild::InitForContent(base::ProcessHandle aParentProcessHandle,
|
||||
PluginModuleChild::InitForContent(base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel)
|
||||
{
|
||||
if (!CommonInit(aParentProcessHandle, aIOLoop, aChannel)) {
|
||||
if (!CommonInit(aParentPid, aIOLoop, aChannel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -259,7 +255,7 @@ PluginModuleChild::RecvDisableFlashProtectedMode()
|
||||
|
||||
bool
|
||||
PluginModuleChild::InitForChrome(const std::string& aPluginFilename,
|
||||
base::ProcessHandle aParentProcessHandle,
|
||||
base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel)
|
||||
{
|
||||
@ -312,7 +308,7 @@ PluginModuleChild::InitForChrome(const std::string& aPluginFilename,
|
||||
}
|
||||
NS_ASSERTION(mLibrary, "couldn't open shared object");
|
||||
|
||||
if (!CommonInit(aParentProcessHandle, aIOLoop, aChannel)) {
|
||||
if (!CommonInit(aParentPid, aIOLoop, aChannel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -791,9 +787,9 @@ PluginModuleChild::QuickExit()
|
||||
|
||||
PPluginModuleChild*
|
||||
PluginModuleChild::AllocPPluginModuleChild(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
return PluginModuleChild::CreateForContentProcess(aTransport, aOtherProcess);
|
||||
return PluginModuleChild::CreateForContentProcess(aTransport, aOtherPid);
|
||||
}
|
||||
|
||||
PCrashReporterChild*
|
||||
|
@ -158,17 +158,17 @@ public:
|
||||
explicit PluginModuleChild(bool aIsChrome);
|
||||
virtual ~PluginModuleChild();
|
||||
|
||||
bool CommonInit(base::ProcessHandle aParentProcessHandle,
|
||||
bool CommonInit(base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel);
|
||||
|
||||
// aPluginFilename is UTF8, not native-charset!
|
||||
bool InitForChrome(const std::string& aPluginFilename,
|
||||
base::ProcessHandle aParentProcessHandle,
|
||||
base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel);
|
||||
|
||||
bool InitForContent(base::ProcessHandle aParentProcessHandle,
|
||||
bool InitForContent(base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
IPC::Channel* aChannel);
|
||||
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ PluginProcessChild::Init()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool retval = mPlugin.InitForChrome(pluginFilename, ParentHandle(),
|
||||
bool retval = mPlugin.InitForChrome(pluginFilename, ParentPid(),
|
||||
IOThreadChild::message_loop(),
|
||||
IOThreadChild::channel());
|
||||
#if defined(XP_MACOSX)
|
||||
|
@ -19,8 +19,8 @@ protected:
|
||||
typedef mozilla::ipc::ProcessChild ProcessChild;
|
||||
|
||||
public:
|
||||
explicit PluginProcessChild(ProcessHandle aParentHandle)
|
||||
: ProcessChild(aParentHandle), mPlugin(true)
|
||||
explicit PluginProcessChild(ProcessId aParentPid)
|
||||
: ProcessChild(aParentPid), mPlugin(true)
|
||||
{ }
|
||||
|
||||
virtual ~PluginProcessChild()
|
||||
|
@ -62,12 +62,12 @@ SharedDIB::Attach(Handle aHandle, uint32_t aSize)
|
||||
}
|
||||
|
||||
nsresult
|
||||
SharedDIB::ShareToProcess(base::ProcessHandle aChildProcess, Handle *aChildHandle)
|
||||
SharedDIB::ShareToProcess(base::ProcessId aTargetPid, Handle *aNewHandle)
|
||||
{
|
||||
if (!mShMem)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (!mShMem->ShareToProcess(aChildProcess, aChildHandle))
|
||||
if (!mShMem->ShareToProcess(aTargetPid, aNewHandle))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
nsresult Attach(Handle aHandle, uint32_t aSize);
|
||||
|
||||
// Returns a SharedMemoryHandle suitable for sharing with another process.
|
||||
nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle *aChildHandle);
|
||||
nsresult ShareToProcess(base::ProcessId aTargetPid, Handle *aNewHandle);
|
||||
|
||||
protected:
|
||||
base::SharedMemory *mShMem;
|
||||
|
@ -44,8 +44,8 @@ public:
|
||||
|
||||
HDC GetHDC() { return mSharedDIB.GetHDC(); }
|
||||
|
||||
nsresult ShareToProcess(base::ProcessHandle aChildProcess, Handle* aChildHandle) {
|
||||
return mSharedDIB.ShareToProcess(aChildProcess, aChildHandle);
|
||||
nsresult ShareToProcess(base::ProcessId aTargetPid, Handle* aNewHandle) {
|
||||
return mSharedDIB.ShareToProcess(aTargetPid, aNewHandle);
|
||||
}
|
||||
|
||||
static bool IsSharedDIBSurface(gfxASurface* aSurface);
|
||||
|
@ -3226,15 +3226,15 @@ void AsyncPanZoomController::ShareCompositorFrameMetrics() {
|
||||
}
|
||||
|
||||
// Get the process id of the content process
|
||||
base::ProcessHandle processHandle = compositor->OtherProcess();
|
||||
base::ProcessId otherPid = compositor->OtherPid();
|
||||
ipc::SharedMemoryBasic::Handle mem = ipc::SharedMemoryBasic::NULLHandle();
|
||||
|
||||
// Get the shared memory handle to share with the content process
|
||||
mSharedFrameMetricsBuffer->ShareToProcess(processHandle, &mem);
|
||||
mSharedFrameMetricsBuffer->ShareToProcess(otherPid, &mem);
|
||||
|
||||
// Get the cross process mutex handle to share with the content process
|
||||
mSharedLock = new CrossProcessMutex("AsyncPanZoomControlLock");
|
||||
CrossProcessMutexHandle handle = mSharedLock->ShareToProcess(processHandle);
|
||||
CrossProcessMutexHandle handle = mSharedLock->ShareToProcess(otherPid);
|
||||
|
||||
// Send the shared memory handle and cross process handle to the content
|
||||
// process by an asynchronous ipc call. Include the APZC unique ID
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <stddef.h> // for size_t
|
||||
#include "ClientLayerManager.h" // for ClientLayerManager
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/process_util.h" // for OpenProcessHandle
|
||||
#include "base/task.h" // for NewRunnableMethod, etc
|
||||
#include "base/tracked.h" // for FROM_HERE
|
||||
#include "mozilla/layers/LayerTransactionChild.h"
|
||||
@ -77,19 +76,13 @@ CompositorChild::LookupCompositorFrameMetrics(const FrameMetrics::ViewID aId,
|
||||
}
|
||||
|
||||
/*static*/ PCompositorChild*
|
||||
CompositorChild::Create(Transport* aTransport, ProcessId aOtherProcess)
|
||||
CompositorChild::Create(Transport* aTransport, ProcessId aOtherPid)
|
||||
{
|
||||
// There's only one compositor per child process.
|
||||
MOZ_ASSERT(!sCompositor);
|
||||
|
||||
nsRefPtr<CompositorChild> child(new CompositorChild(nullptr));
|
||||
ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// We can't go on without a compositor.
|
||||
NS_RUNTIMEABORT("Couldn't OpenProcessHandle() to parent process.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!child->Open(aTransport, handle, XRE_GetIOMessageLoop(), ipc::ChildSide)) {
|
||||
if (!child->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ChildSide)) {
|
||||
NS_RUNTIMEABORT("Couldn't Open() Compositor channel.");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -12,8 +12,7 @@
|
||||
#include "LayerTransactionParent.h" // for LayerTransactionParent
|
||||
#include "RenderTrace.h" // for RenderTraceLayers
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/process.h" // for ProcessHandle
|
||||
#include "base/process_util.h" // for OpenProcessHandle
|
||||
#include "base/process.h" // for ProcessId
|
||||
#include "base/task.h" // for CancelableTask, etc
|
||||
#include "base/thread.h" // for Thread
|
||||
#include "base/tracked.h" // for FROM_HERE
|
||||
@ -78,7 +77,7 @@ using namespace mozilla::ipc;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace std;
|
||||
|
||||
using base::ProcessHandle;
|
||||
using base::ProcessId;
|
||||
using base::Thread;
|
||||
|
||||
CompositorParent::LayerTreeState::LayerTreeState()
|
||||
@ -1301,9 +1300,7 @@ CompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aB
|
||||
if (!mLayerManager) {
|
||||
NS_WARNING("Failed to initialise Compositor");
|
||||
*aSuccess = false;
|
||||
LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, 0,
|
||||
// child side's process id is current process Id
|
||||
base::GetProcId(base::GetCurrentProcessHandle()));
|
||||
LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, 0);
|
||||
p->AddIPDLReference();
|
||||
return p;
|
||||
}
|
||||
@ -1312,9 +1309,7 @@ CompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aB
|
||||
*aSuccess = true;
|
||||
|
||||
*aTextureFactoryIdentifier = mCompositor->GetTextureFactoryIdentifier();
|
||||
LayerTransactionParent* p = new LayerTransactionParent(mLayerManager, this, 0,
|
||||
// child side's process id is current process Id
|
||||
base::GetProcId(base::GetCurrentProcessHandle()));
|
||||
LayerTransactionParent* p = new LayerTransactionParent(mLayerManager, this, 0);
|
||||
p->AddIPDLReference();
|
||||
return p;
|
||||
}
|
||||
@ -1520,9 +1515,8 @@ class CrossProcessCompositorParent final : public PCompositorParent,
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CrossProcessCompositorParent)
|
||||
public:
|
||||
CrossProcessCompositorParent(Transport* aTransport, ProcessId aOtherProcess)
|
||||
explicit CrossProcessCompositorParent(Transport* aTransport)
|
||||
: mTransport(aTransport)
|
||||
, mChildProcessId(aOtherProcess)
|
||||
, mCompositorThreadHolder(sCompositorThreadHolder)
|
||||
, mNotifyAfterRemotePaint(false)
|
||||
{
|
||||
@ -1605,8 +1599,6 @@ private:
|
||||
// ourself. This is released (deferred) in ActorDestroy().
|
||||
nsRefPtr<CrossProcessCompositorParent> mSelfRef;
|
||||
Transport* mTransport;
|
||||
// Child side's process Id.
|
||||
base::ProcessId mChildProcessId;
|
||||
|
||||
nsRefPtr<CompositorThreadHolder> mCompositorThreadHolder;
|
||||
// If true, we should send a RemotePaintIsReady message when the layer transaction
|
||||
@ -1634,31 +1626,26 @@ CompositorParent::DidComposite()
|
||||
|
||||
static void
|
||||
OpenCompositor(CrossProcessCompositorParent* aCompositor,
|
||||
Transport* aTransport, ProcessHandle aHandle,
|
||||
Transport* aTransport, ProcessId aOtherPid,
|
||||
MessageLoop* aIOLoop)
|
||||
{
|
||||
DebugOnly<bool> ok = aCompositor->Open(aTransport, aHandle, aIOLoop);
|
||||
DebugOnly<bool> ok = aCompositor->Open(aTransport, aOtherPid, aIOLoop);
|
||||
MOZ_ASSERT(ok);
|
||||
}
|
||||
|
||||
/*static*/ PCompositorParent*
|
||||
CompositorParent::Create(Transport* aTransport, ProcessId aOtherProcess)
|
||||
CompositorParent::Create(Transport* aTransport, ProcessId aOtherPid)
|
||||
{
|
||||
gfxPlatform::InitLayersIPC();
|
||||
|
||||
nsRefPtr<CrossProcessCompositorParent> cpcp =
|
||||
new CrossProcessCompositorParent(aTransport, aOtherProcess);
|
||||
ProcessHandle handle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
|
||||
// XXX need to kill |aOtherProcess|, it's boned
|
||||
return nullptr;
|
||||
}
|
||||
new CrossProcessCompositorParent(aTransport);
|
||||
|
||||
cpcp->mSelfRef = cpcp;
|
||||
CompositorLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(OpenCompositor, cpcp.get(),
|
||||
aTransport, handle, XRE_GetIOMessageLoop()));
|
||||
aTransport, aOtherPid, XRE_GetIOMessageLoop()));
|
||||
// The return value is just compared to null for success checking,
|
||||
// we're not sharing a ref.
|
||||
return cpcp.get();
|
||||
@ -1737,7 +1724,7 @@ CrossProcessCompositorParent::AllocPLayerTransactionParent(const nsTArray<Layers
|
||||
LayerManagerComposite* lm = state->mLayerManager;
|
||||
*aTextureFactoryIdentifier = lm->GetCompositor()->GetTextureFactoryIdentifier();
|
||||
*aSuccess = true;
|
||||
LayerTransactionParent* p = new LayerTransactionParent(lm, this, aId, mChildProcessId);
|
||||
LayerTransactionParent* p = new LayerTransactionParent(lm, this, aId);
|
||||
p->AddIPDLReference();
|
||||
sIndirectLayerTrees[aId].mLayerTree = p;
|
||||
return p;
|
||||
@ -1747,7 +1734,7 @@ CrossProcessCompositorParent::AllocPLayerTransactionParent(const nsTArray<Layers
|
||||
// XXX: should be false, but that causes us to fail some tests on Mac w/ OMTC.
|
||||
// Bug 900745. change *aSuccess to false to see test failures.
|
||||
*aSuccess = true;
|
||||
LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, aId, mChildProcessId);
|
||||
LayerTransactionParent* p = new LayerTransactionParent(nullptr, this, aId);
|
||||
p->AddIPDLReference();
|
||||
return p;
|
||||
}
|
||||
|
@ -11,8 +11,7 @@
|
||||
#include "ShadowLayers.h" // for ShadowLayerForwarder
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/platform_thread.h" // for PlatformThread
|
||||
#include "base/process.h" // for ProcessHandle
|
||||
#include "base/process_util.h" // for OpenProcessHandle
|
||||
#include "base/process.h" // for ProcessId
|
||||
#include "base/task.h" // for NewRunnableFunction, etc
|
||||
#include "base/thread.h" // for Thread
|
||||
#include "base/tracked.h" // for FROM_HERE
|
||||
@ -49,7 +48,7 @@ class Shmem;
|
||||
namespace layers {
|
||||
|
||||
using base::Thread;
|
||||
using base::ProcessHandle;
|
||||
using base::ProcessId;
|
||||
using namespace mozilla::ipc;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
@ -322,10 +321,10 @@ void ImageBridgeChild::StartUp()
|
||||
|
||||
static void
|
||||
ConnectImageBridgeInChildProcess(Transport* aTransport,
|
||||
ProcessHandle aOtherProcess)
|
||||
ProcessId aOtherPid)
|
||||
{
|
||||
// Bind the IPC channel to the image bridge thread.
|
||||
sImageBridgeChildSingleton->Open(aTransport, aOtherProcess,
|
||||
sImageBridgeChildSingleton->Open(aTransport, aOtherPid,
|
||||
XRE_GetIOMessageLoop(),
|
||||
ipc::ChildSide);
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
@ -549,17 +548,12 @@ ImageBridgeChild::EndTransaction()
|
||||
|
||||
PImageBridgeChild*
|
||||
ImageBridgeChild::StartUpInChildProcess(Transport* aTransport,
|
||||
ProcessId aOtherProcess)
|
||||
ProcessId aOtherPid)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
gfxPlatform::GetPlatform();
|
||||
|
||||
ProcessHandle processHandle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &processHandle)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sImageBridgeChildThread = new Thread("ImageBridgeChild");
|
||||
if (!sImageBridgeChildThread->Start()) {
|
||||
return nullptr;
|
||||
@ -569,7 +563,7 @@ ImageBridgeChild::StartUpInChildProcess(Transport* aTransport,
|
||||
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(ConnectImageBridgeInChildProcess,
|
||||
aTransport, processHandle));
|
||||
aTransport, aOtherPid));
|
||||
|
||||
return sImageBridgeChildSingleton;
|
||||
}
|
||||
@ -621,7 +615,7 @@ bool ImageBridgeChild::StartUpOnThread(Thread* aThread)
|
||||
}
|
||||
sImageBridgeChildSingleton = new ImageBridgeChild();
|
||||
sImageBridgeParentSingleton = new ImageBridgeParent(
|
||||
CompositorParent::CompositorLoop(), nullptr, base::GetProcId(base::GetCurrentProcessHandle()));
|
||||
CompositorParent::CompositorLoop(), nullptr, ipc::kCurrentProcessId);
|
||||
sImageBridgeChildSingleton->ConnectAsync(sImageBridgeParentSingleton);
|
||||
return true;
|
||||
} else {
|
||||
@ -949,7 +943,7 @@ void ImageBridgeChild::RemoveTexture(TextureClient* aTexture)
|
||||
|
||||
bool ImageBridgeChild::IsSameProcess() const
|
||||
{
|
||||
return OtherProcess() == ipc::kInvalidProcessHandle;
|
||||
return OtherPid() == ipc::kCurrentProcessId;
|
||||
}
|
||||
|
||||
void ImageBridgeChild::SendPendingAsyncMessges()
|
||||
|
@ -8,8 +8,7 @@
|
||||
#include <stdint.h> // for uint64_t, uint32_t
|
||||
#include "CompositableHost.h" // for CompositableParent, Create
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/process.h" // for ProcessHandle
|
||||
#include "base/process_util.h" // for OpenProcessHandle
|
||||
#include "base/process.h" // for ProcessId
|
||||
#include "base/task.h" // for CancelableTask, DeleteTask, etc
|
||||
#include "base/tracked.h" // for FROM_HERE
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
@ -54,7 +53,6 @@ ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
|
||||
ProcessId aChildProcessId)
|
||||
: mMessageLoop(aLoop)
|
||||
, mTransport(aTransport)
|
||||
, mChildProcessId(aChildProcessId)
|
||||
, mCompositorThreadHolder(GetCompositorThreadHolder())
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -67,6 +65,7 @@ ImageBridgeParent::ImageBridgeParent(MessageLoop* aLoop,
|
||||
// with several bridges
|
||||
CompositableMap::Create();
|
||||
sImageBridges[aChildProcessId] = this;
|
||||
SetOtherProcessId(aChildProcessId);
|
||||
}
|
||||
|
||||
ImageBridgeParent::~ImageBridgeParent()
|
||||
@ -79,7 +78,7 @@ ImageBridgeParent::~ImageBridgeParent()
|
||||
new DeleteTask<Transport>(mTransport));
|
||||
}
|
||||
|
||||
sImageBridges.erase(mChildProcessId);
|
||||
sImageBridges.erase(OtherPid());
|
||||
}
|
||||
|
||||
LayersBackend
|
||||
@ -155,25 +154,20 @@ ImageBridgeParent::RecvUpdateNoSwap(EditArray&& aEdits)
|
||||
static void
|
||||
ConnectImageBridgeInParentProcess(ImageBridgeParent* aBridge,
|
||||
Transport* aTransport,
|
||||
base::ProcessHandle aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
aBridge->Open(aTransport, aOtherProcess, XRE_GetIOMessageLoop(), ipc::ParentSide);
|
||||
aBridge->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ParentSide);
|
||||
}
|
||||
|
||||
/*static*/ PImageBridgeParent*
|
||||
ImageBridgeParent::Create(Transport* aTransport, ProcessId aChildProcessId)
|
||||
{
|
||||
base::ProcessHandle processHandle;
|
||||
if (!base::OpenProcessHandle(aChildProcessId, &processHandle)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MessageLoop* loop = CompositorParent::CompositorLoop();
|
||||
nsRefPtr<ImageBridgeParent> bridge = new ImageBridgeParent(loop, aTransport, aChildProcessId);
|
||||
bridge->mSelfRef = bridge;
|
||||
loop->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(ConnectImageBridgeInParentProcess,
|
||||
bridge.get(), aTransport, processHandle));
|
||||
bridge.get(), aTransport, aChildProcessId));
|
||||
return bridge.get();
|
||||
}
|
||||
|
||||
@ -346,7 +340,7 @@ ImageBridgeParent::CloneToplevel(const InfallibleTArray<ProtocolFdMapping>& aFds
|
||||
|
||||
bool ImageBridgeParent::IsSameProcess() const
|
||||
{
|
||||
return OtherProcess() == ipc::kInvalidProcessHandle;
|
||||
return OtherPid() == ipc::kCurrentProcessId;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
|
||||
virtual base::ProcessId GetChildProcessId() override
|
||||
{
|
||||
return mChildProcessId;
|
||||
return OtherPid();
|
||||
}
|
||||
|
||||
// PImageBridge
|
||||
@ -150,8 +150,6 @@ private:
|
||||
|
||||
MessageLoop* mMessageLoop;
|
||||
Transport* mTransport;
|
||||
// Child side's process id.
|
||||
base::ProcessId mChildProcessId;
|
||||
// This keeps us alive until ActorDestroy(), at which point we do a
|
||||
// deferred destruction of ourselves.
|
||||
nsRefPtr<ImageBridgeParent> mSelfRef;
|
||||
|
@ -147,13 +147,11 @@ ShadowChild(const OpRaiseToTopChild& op)
|
||||
// LayerTransactionParent
|
||||
LayerTransactionParent::LayerTransactionParent(LayerManagerComposite* aManager,
|
||||
ShadowLayersManager* aLayersManager,
|
||||
uint64_t aId,
|
||||
ProcessId aOtherProcess)
|
||||
uint64_t aId)
|
||||
: mLayerManager(aManager)
|
||||
, mShadowLayersManager(aLayersManager)
|
||||
, mId(aId)
|
||||
, mPendingTransaction(0)
|
||||
, mChildProcessId(aOtherProcess)
|
||||
, mDestroyed(false)
|
||||
, mIPCOpen(false)
|
||||
{
|
||||
@ -629,7 +627,7 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray<Edit>&& cset,
|
||||
mLayerManager->VisualFrameWarning(severity);
|
||||
#ifdef PR_LOGGING
|
||||
PR_LogPrint("LayerTransactionParent::RecvUpdate transaction from process %d took %f ms",
|
||||
mChildProcessId,
|
||||
OtherPid(),
|
||||
latency.ToMilliseconds());
|
||||
#endif
|
||||
}
|
||||
@ -978,7 +976,7 @@ LayerTransactionParent::ActorDestroy(ActorDestroyReason why)
|
||||
|
||||
bool LayerTransactionParent::IsSameProcess() const
|
||||
{
|
||||
return OtherProcess() == ipc::kInvalidProcessHandle;
|
||||
return OtherPid() == ipc::kCurrentProcessId;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -47,8 +47,7 @@ class LayerTransactionParent final : public PLayerTransactionParent,
|
||||
public:
|
||||
LayerTransactionParent(LayerManagerComposite* aManager,
|
||||
ShadowLayersManager* aLayersManager,
|
||||
uint64_t aId,
|
||||
ProcessId aOtherProcess);
|
||||
uint64_t aId);
|
||||
|
||||
protected:
|
||||
~LayerTransactionParent();
|
||||
@ -98,7 +97,7 @@ public:
|
||||
|
||||
virtual base::ProcessId GetChildProcessId() override
|
||||
{
|
||||
return mChildProcessId;
|
||||
return OtherPid();
|
||||
}
|
||||
|
||||
virtual void ReplyRemoveTexture(const OpReplyRemoveTexture& aReply) override;
|
||||
@ -201,9 +200,6 @@ private:
|
||||
// vice versa. In both cases though, we want to ignore shadow-layer
|
||||
// transactions posted by the child.
|
||||
|
||||
// Child side's process id.
|
||||
base::ProcessId mChildProcessId;
|
||||
|
||||
bool mDestroyed;
|
||||
|
||||
bool mIPCOpen;
|
||||
|
@ -738,7 +738,7 @@ ShadowLayerForwarder::IsSameProcess() const
|
||||
if (!HasShadowManager() || !mShadowManager->IPCOpen()) {
|
||||
return false;
|
||||
}
|
||||
return mShadowManager->OtherProcess() == kInvalidProcessHandle;
|
||||
return mShadowManager->OtherPid() == kCurrentProcessId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,10 +96,11 @@ SharedBufferManagerChild::StartUp()
|
||||
|
||||
static void
|
||||
ConnectSharedBufferManagerInChildProcess(mozilla::ipc::Transport* aTransport,
|
||||
base::ProcessHandle aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
// Bind the IPC channel to the shared buffer manager thread.
|
||||
SharedBufferManagerChild::sSharedBufferManagerChildSingleton->Open(aTransport, aOtherProcess,
|
||||
SharedBufferManagerChild::sSharedBufferManagerChildSingleton->Open(aTransport,
|
||||
aOtherPid,
|
||||
XRE_GetIOMessageLoop(),
|
||||
ipc::ChildSide);
|
||||
|
||||
@ -116,15 +117,10 @@ ConnectSharedBufferManagerInChildProcess(mozilla::ipc::Transport* aTransport,
|
||||
|
||||
PSharedBufferManagerChild*
|
||||
SharedBufferManagerChild::StartUpInChildProcess(Transport* aTransport,
|
||||
base::ProcessId aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on the main Thread!");
|
||||
|
||||
ProcessHandle processHandle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &processHandle)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sSharedBufferManagerChildThread = new base::Thread("BufferMgrChild");
|
||||
if (!sSharedBufferManagerChildThread->Start()) {
|
||||
return nullptr;
|
||||
@ -134,7 +130,7 @@ SharedBufferManagerChild::StartUpInChildProcess(Transport* aTransport,
|
||||
sSharedBufferManagerChildSingleton->GetMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(ConnectSharedBufferManagerInChildProcess,
|
||||
aTransport, processHandle));
|
||||
aTransport, aOtherPid));
|
||||
|
||||
return sSharedBufferManagerChildSingleton;
|
||||
}
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
#include "mozilla/layers/SharedBufferManagerParent.h"
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "base/process.h" // for ProcessHandle
|
||||
#include "base/process_util.h" // for OpenProcessHandle
|
||||
#include "base/process.h" // for ProcessId
|
||||
#include "base/task.h" // for CancelableTask, DeleteTask, etc
|
||||
#include "base/tracked.h" // for FROM_HERE
|
||||
#include "base/thread.h"
|
||||
@ -179,29 +178,26 @@ SharedBufferManagerParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
static void
|
||||
ConnectSharedBufferManagerInParentProcess(SharedBufferManagerParent* aManager,
|
||||
Transport* aTransport,
|
||||
base::ProcessHandle aOtherProcess)
|
||||
base::ProcessId aOtherPid)
|
||||
{
|
||||
aManager->Open(aTransport, aOtherProcess, XRE_GetIOMessageLoop(), ipc::ParentSide);
|
||||
aManager->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop(), ipc::ParentSide);
|
||||
}
|
||||
|
||||
PSharedBufferManagerParent* SharedBufferManagerParent::Create(Transport* aTransport, ProcessId aOtherProcess)
|
||||
PSharedBufferManagerParent* SharedBufferManagerParent::Create(Transport* aTransport,
|
||||
ProcessId aOtherPid)
|
||||
{
|
||||
ProcessHandle processHandle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &processHandle)) {
|
||||
return nullptr;
|
||||
}
|
||||
base::Thread* thread = nullptr;
|
||||
char thrname[128];
|
||||
base::snprintf(thrname, 128, "BufMgrParent#%d", aOtherProcess);
|
||||
base::snprintf(thrname, 128, "BufMgrParent#%d", aOtherPid);
|
||||
thread = new base::Thread(thrname);
|
||||
|
||||
SharedBufferManagerParent* manager = new SharedBufferManagerParent(aTransport, aOtherProcess, thread);
|
||||
SharedBufferManagerParent* manager = new SharedBufferManagerParent(aTransport, aOtherPid, thread);
|
||||
if (!thread->IsRunning()) {
|
||||
thread->Start();
|
||||
}
|
||||
thread->message_loop()->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(ConnectSharedBufferManagerInParentProcess,
|
||||
manager, aTransport, processHandle));
|
||||
manager, aTransport, aOtherPid));
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,9 @@ bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
|
||||
SYNCHRONIZE,
|
||||
FALSE, pid);
|
||||
|
||||
if (result == INVALID_HANDLE_VALUE)
|
||||
if (result == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*handle = result;
|
||||
return true;
|
||||
@ -89,8 +90,9 @@ bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) {
|
||||
SYNCHRONIZE,
|
||||
FALSE, pid);
|
||||
|
||||
if (result == INVALID_HANDLE_VALUE)
|
||||
if (result == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*handle = result;
|
||||
return true;
|
||||
|
@ -124,9 +124,9 @@ class SharedMemory {
|
||||
// file. new_handle is an ouput parameter to receive
|
||||
// the handle for use in the remote process.
|
||||
// Returns true on success, false otherwise.
|
||||
bool ShareToProcess(base::ProcessHandle process,
|
||||
bool ShareToProcess(base::ProcessId target_pid,
|
||||
SharedMemoryHandle* new_handle) {
|
||||
return ShareToProcessCommon(process, new_handle, false);
|
||||
return ShareToProcessCommon(target_pid, new_handle, false);
|
||||
}
|
||||
|
||||
// Logically equivalent to:
|
||||
@ -135,9 +135,9 @@ class SharedMemory {
|
||||
// return ok;
|
||||
// Note that the memory is unmapped by calling this method, regardless of the
|
||||
// return value.
|
||||
bool GiveToProcess(ProcessHandle process,
|
||||
bool GiveToProcess(ProcessId target_pid,
|
||||
SharedMemoryHandle* new_handle) {
|
||||
return ShareToProcessCommon(process, new_handle, true);
|
||||
return ShareToProcessCommon(target_pid, new_handle, true);
|
||||
}
|
||||
|
||||
// Lock the shared memory.
|
||||
@ -162,7 +162,7 @@ class SharedMemory {
|
||||
void LockOrUnlockCommon(int function);
|
||||
|
||||
#endif
|
||||
bool ShareToProcessCommon(ProcessHandle process,
|
||||
bool ShareToProcessCommon(ProcessId target_pid,
|
||||
SharedMemoryHandle* new_handle,
|
||||
bool close_self);
|
||||
|
||||
|
@ -253,7 +253,7 @@ bool SharedMemory::Unmap() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
|
||||
bool SharedMemory::ShareToProcessCommon(ProcessId processId,
|
||||
SharedMemoryHandle *new_handle,
|
||||
bool close_self) {
|
||||
const int new_fd = dup(mapped_file_);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/win_util.h"
|
||||
#include "base/string_util.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
@ -118,7 +119,7 @@ bool SharedMemory::Unmap() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
|
||||
bool SharedMemory::ShareToProcessCommon(ProcessId processId,
|
||||
SharedMemoryHandle *new_handle,
|
||||
bool close_self) {
|
||||
*new_handle = 0;
|
||||
@ -135,14 +136,16 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
|
||||
Unmap();
|
||||
}
|
||||
|
||||
if (process == GetCurrentProcess() && close_self) {
|
||||
if (processId == GetCurrentProcId() && close_self) {
|
||||
*new_handle = mapped_file;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!DuplicateHandle(GetCurrentProcess(), mapped_file, process,
|
||||
&result, access, FALSE, options))
|
||||
if (!mozilla::ipc::DuplicateHandle(mapped_file, processId, &result, access,
|
||||
options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*new_handle = result;
|
||||
return true;
|
||||
}
|
||||
|
@ -137,9 +137,6 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
// A handle that is invalid on any platform.
|
||||
static const ProcessHandle kInvalidProcessHandle;
|
||||
|
||||
// The length of time we will wait at shutdown for all actors to clean
|
||||
// themselves up before forcing them to be destroyed.
|
||||
static const uint32_t kShutdownTimerDelayMS = 10000;
|
||||
@ -239,7 +236,7 @@ private:
|
||||
static PBackgroundParent*
|
||||
Alloc(ContentParent* aContent,
|
||||
Transport* aTransport,
|
||||
ProcessId aOtherProcess);
|
||||
ProcessId aOtherPid);
|
||||
|
||||
static bool
|
||||
CreateBackgroundThread();
|
||||
@ -257,8 +254,6 @@ private:
|
||||
{
|
||||
AssertIsInMainProcess();
|
||||
AssertIsOnMainThread();
|
||||
|
||||
SetOtherProcess(kInvalidProcessHandle);
|
||||
}
|
||||
|
||||
// For other-process actors.
|
||||
@ -409,7 +404,7 @@ private:
|
||||
|
||||
// Forwarded from BackgroundChild.
|
||||
static PBackgroundChild*
|
||||
Alloc(Transport* aTransport, ProcessId aOtherProcess);
|
||||
Alloc(Transport* aTransport, ProcessId aOtherPid);
|
||||
|
||||
// Forwarded from BackgroundChild.
|
||||
static PBackgroundChild*
|
||||
@ -595,15 +590,15 @@ class ParentImpl::ConnectActorRunnable final : public nsRunnable
|
||||
{
|
||||
nsRefPtr<ParentImpl> mActor;
|
||||
Transport* mTransport;
|
||||
ProcessHandle mProcessHandle;
|
||||
ProcessId mOtherPid;
|
||||
nsTArray<ParentImpl*>* mLiveActorArray;
|
||||
|
||||
public:
|
||||
ConnectActorRunnable(ParentImpl* aActor,
|
||||
Transport* aTransport,
|
||||
ProcessHandle aProcessHandle,
|
||||
ProcessId aOtherPid,
|
||||
nsTArray<ParentImpl*>* aLiveActorArray)
|
||||
: mActor(aActor), mTransport(aTransport), mProcessHandle(aProcessHandle),
|
||||
: mActor(aActor), mTransport(aTransport), mOtherPid(aOtherPid),
|
||||
mLiveActorArray(aLiveActorArray)
|
||||
{
|
||||
AssertIsInMainProcess();
|
||||
@ -749,14 +744,14 @@ class ChildImpl::OpenChildProcessActorRunnable final : public nsRunnable
|
||||
{
|
||||
nsRefPtr<ChildImpl> mActor;
|
||||
nsAutoPtr<Transport> mTransport;
|
||||
ProcessHandle mProcessHandle;
|
||||
ProcessId mOtherPid;
|
||||
|
||||
public:
|
||||
OpenChildProcessActorRunnable(already_AddRefed<ChildImpl>&& aActor,
|
||||
Transport* aTransport,
|
||||
ProcessHandle aProcessHandle)
|
||||
ProcessId aOtherPid)
|
||||
: mActor(aActor), mTransport(aTransport),
|
||||
mProcessHandle(aProcessHandle)
|
||||
mOtherPid(aOtherPid)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(mActor);
|
||||
@ -876,9 +871,9 @@ BackgroundParent::GetRawContentParentForComparison(
|
||||
PBackgroundParent*
|
||||
BackgroundParent::Alloc(ContentParent* aContent,
|
||||
Transport* aTransport,
|
||||
ProcessId aOtherProcess)
|
||||
ProcessId aOtherPid)
|
||||
{
|
||||
return ParentImpl::Alloc(aContent, aTransport, aOtherProcess);
|
||||
return ParentImpl::Alloc(aContent, aTransport, aOtherPid);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -894,9 +889,9 @@ BackgroundChild::Startup()
|
||||
|
||||
// static
|
||||
PBackgroundChild*
|
||||
BackgroundChild::Alloc(Transport* aTransport, ProcessId aOtherProcess)
|
||||
BackgroundChild::Alloc(Transport* aTransport, ProcessId aOtherPid)
|
||||
{
|
||||
return ChildImpl::Alloc(aTransport, aOtherProcess);
|
||||
return ChildImpl::Alloc(aTransport, aOtherPid);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -959,13 +954,6 @@ BackgroundChildImpl::GetThreadLocalForCurrentThread()
|
||||
// ParentImpl Static Members
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const ParentImpl::ProcessHandle ParentImpl::kInvalidProcessHandle =
|
||||
#ifdef XP_WIN
|
||||
ProcessHandle(INVALID_HANDLE_VALUE);
|
||||
#else
|
||||
ProcessHandle(-1);
|
||||
#endif
|
||||
|
||||
StaticRefPtr<nsIThread> ParentImpl::sBackgroundThread;
|
||||
|
||||
nsTArray<ParentImpl*>* ParentImpl::sLiveActorsForBackgroundThread;
|
||||
@ -1062,18 +1050,12 @@ ParentImpl::GetRawContentParentForComparison(
|
||||
PBackgroundParent*
|
||||
ParentImpl::Alloc(ContentParent* aContent,
|
||||
Transport* aTransport,
|
||||
ProcessId aOtherProcess)
|
||||
ProcessId aOtherPid)
|
||||
{
|
||||
AssertIsInMainProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aTransport);
|
||||
|
||||
ProcessHandle processHandle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &processHandle)) {
|
||||
// Process has already died?
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!sBackgroundThread && !CreateBackgroundThread()) {
|
||||
NS_WARNING("Failed to create background thread!");
|
||||
return nullptr;
|
||||
@ -1086,7 +1068,7 @@ ParentImpl::Alloc(ContentParent* aContent,
|
||||
nsRefPtr<ParentImpl> actor = new ParentImpl(aContent, aTransport);
|
||||
|
||||
nsCOMPtr<nsIRunnable> connectRunnable =
|
||||
new ConnectActorRunnable(actor, aTransport, processHandle,
|
||||
new ConnectActorRunnable(actor, aTransport, aOtherPid,
|
||||
sLiveActorsForBackgroundThread);
|
||||
|
||||
if (NS_FAILED(sBackgroundThread->Dispatch(connectRunnable,
|
||||
@ -1327,14 +1309,6 @@ ParentImpl::MainThreadActorDestroy()
|
||||
mTransport = nullptr;
|
||||
}
|
||||
|
||||
ProcessHandle otherProcess = OtherProcess();
|
||||
if (otherProcess != kInvalidProcessHandle) {
|
||||
base::CloseProcessHandle(otherProcess);
|
||||
#ifdef DEBUG
|
||||
SetOtherProcess(kInvalidProcessHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
mContent = nullptr;
|
||||
|
||||
MOZ_ASSERT(sLiveActorCount);
|
||||
@ -1585,8 +1559,7 @@ ParentImpl::ConnectActorRunnable::Run()
|
||||
ParentImpl* actor;
|
||||
mActor.forget(&actor);
|
||||
|
||||
if (!actor->Open(mTransport, mProcessHandle, XRE_GetIOMessageLoop(),
|
||||
ParentSide)) {
|
||||
if (!actor->Open(mTransport, mOtherPid, XRE_GetIOMessageLoop(), ParentSide)) {
|
||||
actor->Destroy();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1658,7 +1631,7 @@ ChildImpl::Shutdown()
|
||||
|
||||
// static
|
||||
PBackgroundChild*
|
||||
ChildImpl::Alloc(Transport* aTransport, ProcessId aOtherProcess)
|
||||
ChildImpl::Alloc(Transport* aTransport, ProcessId aOtherPid)
|
||||
{
|
||||
AssertIsInChildProcess();
|
||||
AssertIsOnMainThread();
|
||||
@ -1671,18 +1644,13 @@ ChildImpl::Alloc(Transport* aTransport, ProcessId aOtherProcess)
|
||||
|
||||
sPendingTargets->RemoveElementAt(0);
|
||||
|
||||
ProcessHandle processHandle;
|
||||
if (!base::OpenProcessHandle(aOtherProcess, &processHandle)) {
|
||||
MOZ_CRASH("Failed to open process handle!");
|
||||
}
|
||||
|
||||
nsRefPtr<ChildImpl> actor = new ChildImpl();
|
||||
|
||||
ChildImpl* weakActor = actor;
|
||||
|
||||
nsCOMPtr<nsIRunnable> openRunnable =
|
||||
new OpenChildProcessActorRunnable(actor.forget(), aTransport,
|
||||
processHandle);
|
||||
aOtherPid);
|
||||
if (NS_FAILED(eventTarget->Dispatch(openRunnable, NS_DISPATCH_NORMAL))) {
|
||||
MOZ_CRASH("Failed to dispatch OpenActorRunnable!");
|
||||
}
|
||||
@ -1915,7 +1883,7 @@ ChildImpl::OpenChildProcessActorRunnable::Run()
|
||||
nsRefPtr<ChildImpl> strongActor;
|
||||
mActor.swap(strongActor);
|
||||
|
||||
if (!strongActor->Open(mTransport.forget(), mProcessHandle,
|
||||
if (!strongActor->Open(mTransport.forget(), mOtherPid,
|
||||
XRE_GetIOMessageLoop(), ChildSide)) {
|
||||
CRASH_IN_CHILD_PROCESS("Failed to open ChildImpl!");
|
||||
|
||||
@ -1988,6 +1956,9 @@ ChildImpl::OpenMainProcessActorRunnable::Run()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Make sure the parent knows it is same process.
|
||||
parentActor->SetOtherProcessId(kCurrentProcessId);
|
||||
|
||||
// Now that Open() has succeeded transfer the ownership of the actors to IPDL.
|
||||
unused << parentActor.forget();
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
*
|
||||
* @returns A handle that can be shared to another process
|
||||
*/
|
||||
CrossProcessMutexHandle ShareToProcess(base::ProcessHandle aTarget);
|
||||
CrossProcessMutexHandle ShareToProcess(base::ProcessId aTargetPid);
|
||||
|
||||
private:
|
||||
friend struct IPC::ParamTraits<CrossProcessMutex>;
|
||||
|
@ -138,11 +138,11 @@ CrossProcessMutex::Unlock()
|
||||
}
|
||||
|
||||
CrossProcessMutexHandle
|
||||
CrossProcessMutex::ShareToProcess(base::ProcessHandle aHandle)
|
||||
CrossProcessMutex::ShareToProcess(base::ProcessId aTargetPid)
|
||||
{
|
||||
CrossProcessMutexHandle result = ipc::SharedMemoryBasic::NULLHandle();
|
||||
|
||||
if (mSharedBuffer && !mSharedBuffer->ShareToProcess(aHandle, &result)) {
|
||||
if (mSharedBuffer && !mSharedBuffer->ShareToProcess(aTargetPid, &result)) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ CrossProcessMutex::Unlock()
|
||||
}
|
||||
|
||||
CrossProcessMutexHandle
|
||||
CrossProcessMutex::ShareToProcess(base::ProcessHandle aHandle)
|
||||
CrossProcessMutex::ShareToProcess(base::ProcessId aTargetPid)
|
||||
{
|
||||
NS_RUNTIMEABORT("Cross-process mutices not allowed on this platform - woah! We should've aborted by now!");
|
||||
return 0;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "CrossProcessMutex.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "ProtocolUtils.h"
|
||||
|
||||
using base::GetCurrentProcessHandle;
|
||||
using base::ProcessHandle;
|
||||
@ -59,12 +60,11 @@ CrossProcessMutex::Unlock()
|
||||
}
|
||||
|
||||
CrossProcessMutexHandle
|
||||
CrossProcessMutex::ShareToProcess(ProcessHandle aHandle)
|
||||
CrossProcessMutex::ShareToProcess(base::ProcessId aTargetPid)
|
||||
{
|
||||
HANDLE newHandle;
|
||||
bool succeeded = ::DuplicateHandle(GetCurrentProcessHandle(),
|
||||
mMutex, aHandle, &newHandle,
|
||||
0, FALSE, DUPLICATE_SAME_ACCESS);
|
||||
bool succeeded = ipc::DuplicateHandle(mMutex, aTargetPid, &newHandle,
|
||||
0, DUPLICATE_SAME_ACCESS);
|
||||
|
||||
if (!succeeded) {
|
||||
return nullptr;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifdef XP_WIN
|
||||
|
||||
#include <windows.h>
|
||||
#include "ProtocolUtils.h"
|
||||
#define INVALID_HANDLE INVALID_HANDLE_VALUE
|
||||
|
||||
#else // XP_WIN
|
||||
@ -48,8 +49,8 @@ FileDescriptor::DuplicateInCurrentProcess(PlatformHandleType aHandle)
|
||||
if (IsValid(aHandle)) {
|
||||
PlatformHandleType newHandle;
|
||||
#ifdef XP_WIN
|
||||
if (DuplicateHandle(GetCurrentProcess(), aHandle, GetCurrentProcess(),
|
||||
&newHandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
||||
if (::DuplicateHandle(GetCurrentProcess(), aHandle, GetCurrentProcess(),
|
||||
&newHandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
||||
#else // XP_WIN
|
||||
if ((newHandle = dup(aHandle)) != INVALID_HANDLE) {
|
||||
#endif
|
||||
@ -87,13 +88,13 @@ FileDescriptor::CloseCurrentProcessHandle()
|
||||
|
||||
FileDescriptor::PickleType
|
||||
FileDescriptor::ShareTo(const FileDescriptor::IPDLPrivate&,
|
||||
FileDescriptor::ProcessHandle aOtherProcess) const
|
||||
FileDescriptor::ProcessId aTargetPid) const
|
||||
{
|
||||
PlatformHandleType newHandle;
|
||||
#ifdef XP_WIN
|
||||
if (IsValid()) {
|
||||
if (DuplicateHandle(GetCurrentProcess(), mHandle, aOtherProcess,
|
||||
&newHandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
||||
if (mozilla::ipc::DuplicateHandle(mHandle, aTargetPid, &newHandle, 0,
|
||||
DUPLICATE_SAME_ACCESS)) {
|
||||
return newHandle;
|
||||
}
|
||||
NS_WARNING("Failed to duplicate file handle for other process!");
|
||||
|
@ -35,7 +35,7 @@ namespace ipc {
|
||||
class FileDescriptor
|
||||
{
|
||||
public:
|
||||
typedef base::ProcessHandle ProcessHandle;
|
||||
typedef base::ProcessId ProcessId;
|
||||
|
||||
#ifdef XP_WIN
|
||||
typedef HANDLE PlatformHandleType;
|
||||
@ -89,7 +89,7 @@ public:
|
||||
// process (e.g. dup() on POSIX, DuplicateHandle() on Windows). Returns a
|
||||
// pickled value that can be passed to the other process via IPC.
|
||||
PickleType
|
||||
ShareTo(const IPDLPrivate&, ProcessHandle aOtherProcess) const;
|
||||
ShareTo(const IPDLPrivate&, ProcessId aTargetPid) const;
|
||||
|
||||
// Tests mHandle against a well-known invalid platform-specific file handle
|
||||
// (e.g. -1 on POSIX, INVALID_HANDLE_VALUE on Windows).
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/ipc/BrowserProcessSubThread.h"
|
||||
#include "mozilla/Omnijar.h"
|
||||
#include "ProtocolUtils.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef XP_WIN
|
||||
@ -428,6 +429,11 @@ GeckoChildProcessHost::Join()
|
||||
void
|
||||
GeckoChildProcessHost::SetAlreadyDead()
|
||||
{
|
||||
if (mChildProcessHandle &&
|
||||
mChildProcessHandle != kInvalidProcessHandle) {
|
||||
base::CloseProcessHandle(mChildProcessHandle);
|
||||
}
|
||||
|
||||
mChildProcessHandle = 0;
|
||||
}
|
||||
|
||||
|
@ -106,18 +106,6 @@ public:
|
||||
return mChildProcessHandle;
|
||||
}
|
||||
|
||||
// Returns an "owned" handle to the child process - the handle returned
|
||||
// by this function must be closed by the caller.
|
||||
ProcessHandle GetOwnedChildProcessHandle() {
|
||||
ProcessHandle handle;
|
||||
// We use OpenPrivilegedProcessHandle as that is where our
|
||||
// mChildProcessHandle initially came from.
|
||||
bool ok = base::OpenPrivilegedProcessHandle(base::GetProcId(mChildProcessHandle),
|
||||
&handle);
|
||||
NS_ASSERTION(ok, "Failed to get owned process handle");
|
||||
return ok ? handle : 0;
|
||||
}
|
||||
|
||||
GeckoProcessType GetProcessType() {
|
||||
return mProcessType;
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ namespace ipc {
|
||||
|
||||
ProcessChild* ProcessChild::gProcessChild;
|
||||
|
||||
ProcessChild::ProcessChild(ProcessHandle parentHandle)
|
||||
ProcessChild::ProcessChild(ProcessId aParentPid)
|
||||
: ChildProcess(new IOThreadChild())
|
||||
, mUILoop(MessageLoop::current())
|
||||
, mParentHandle(parentHandle)
|
||||
, mParentPid(aParentPid)
|
||||
{
|
||||
MOZ_ASSERT(mUILoop, "UILoop should be created by now");
|
||||
MOZ_ASSERT(!gProcessChild, "should only be one ProcessChild");
|
||||
|
@ -22,10 +22,10 @@ namespace ipc {
|
||||
|
||||
class ProcessChild : public ChildProcess {
|
||||
protected:
|
||||
typedef base::ProcessHandle ProcessHandle;
|
||||
typedef base::ProcessId ProcessId;
|
||||
|
||||
public:
|
||||
explicit ProcessChild(ProcessHandle parentHandle);
|
||||
explicit ProcessChild(ProcessId aParentPid);
|
||||
virtual ~ProcessChild();
|
||||
|
||||
virtual bool Init() = 0;
|
||||
@ -41,15 +41,15 @@ protected:
|
||||
return gProcessChild;
|
||||
}
|
||||
|
||||
ProcessHandle ParentHandle() {
|
||||
return mParentHandle;
|
||||
ProcessId ParentPid() {
|
||||
return mParentPid;
|
||||
}
|
||||
|
||||
private:
|
||||
static ProcessChild* gProcessChild;
|
||||
|
||||
MessageLoop* mUILoop;
|
||||
ProcessHandle mParentHandle;
|
||||
ProcessId mParentPid;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(ProcessChild);
|
||||
};
|
||||
|
@ -11,10 +11,14 @@
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
|
||||
#if defined(MOZ_SANDBOX) && defined(XP_WIN)
|
||||
#define TARGET_SANDBOX_EXPORTS
|
||||
#include "mozilla/sandboxTarget.h"
|
||||
#endif
|
||||
|
||||
using namespace IPC;
|
||||
|
||||
using base::GetCurrentProcessHandle;
|
||||
using base::GetProcId;
|
||||
using base::GetCurrentProcId;
|
||||
using base::ProcessHandle;
|
||||
using base::ProcessId;
|
||||
|
||||
@ -184,28 +188,25 @@ public:
|
||||
|
||||
bool
|
||||
Bridge(const PrivateIPDLInterface&,
|
||||
MessageChannel* aParentChannel, ProcessHandle aParentProcess,
|
||||
MessageChannel* aChildChannel, ProcessHandle aChildProcess,
|
||||
MessageChannel* aParentChannel, ProcessId aParentPid,
|
||||
MessageChannel* aChildChannel, ProcessId aChildPid,
|
||||
ProtocolId aProtocol, ProtocolId aChildProtocol)
|
||||
{
|
||||
ProcessId parentId = GetProcId(aParentProcess);
|
||||
ProcessId childId = GetProcId(aChildProcess);
|
||||
if (!parentId || !childId) {
|
||||
if (!aParentPid || !aChildPid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TransportDescriptor parentSide, childSide;
|
||||
if (!CreateTransport(aParentProcess, aChildProcess,
|
||||
&parentSide, &childSide)) {
|
||||
if (!CreateTransport(aParentPid, &parentSide, &childSide)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aParentChannel->Send(new ChannelOpened(parentSide,
|
||||
childId,
|
||||
aChildPid,
|
||||
aProtocol,
|
||||
IPC::Message::PRIORITY_URGENT)) ||
|
||||
!aChildChannel->Send(new ChannelOpened(childSide,
|
||||
parentId,
|
||||
aParentPid,
|
||||
aChildProtocol,
|
||||
IPC::Message::PRIORITY_URGENT))) {
|
||||
CloseDescriptor(parentSide);
|
||||
@ -217,23 +218,20 @@ Bridge(const PrivateIPDLInterface&,
|
||||
|
||||
bool
|
||||
Open(const PrivateIPDLInterface&,
|
||||
MessageChannel* aOpenerChannel, ProcessHandle aOtherProcess,
|
||||
MessageChannel* aOpenerChannel, ProcessId aOtherProcessId,
|
||||
Transport::Mode aOpenerMode,
|
||||
ProtocolId aProtocol, ProtocolId aChildProtocol)
|
||||
{
|
||||
bool isParent = (Transport::MODE_SERVER == aOpenerMode);
|
||||
ProcessHandle thisHandle = GetCurrentProcessHandle();
|
||||
ProcessHandle parentHandle = isParent ? thisHandle : aOtherProcess;
|
||||
ProcessHandle childHandle = !isParent ? thisHandle : aOtherProcess;
|
||||
ProcessId parentId = GetProcId(parentHandle);
|
||||
ProcessId childId = GetProcId(childHandle);
|
||||
ProcessId thisPid = GetCurrentProcId();
|
||||
ProcessId parentId = isParent ? thisPid : aOtherProcessId;
|
||||
ProcessId childId = !isParent ? thisPid : aOtherProcessId;
|
||||
if (!parentId || !childId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TransportDescriptor parentSide, childSide;
|
||||
if (!CreateTransport(parentHandle, childHandle,
|
||||
&parentSide, &childSide)) {
|
||||
if (!CreateTransport(parentId, &parentSide, &childSide)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -260,6 +258,43 @@ UnpackChannelOpened(const PrivateIPDLInterface&,
|
||||
return ChannelOpened::Read(aMsg, aTransport, aOtherProcess, aProtocol);
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
bool DuplicateHandle(HANDLE aSourceHandle,
|
||||
DWORD aTargetProcessId,
|
||||
HANDLE* aTargetHandle,
|
||||
DWORD aDesiredAccess,
|
||||
DWORD aOptions) {
|
||||
// If our process is the target just duplicate the handle.
|
||||
if (aTargetProcessId == kCurrentProcessId) {
|
||||
return !!::DuplicateHandle(::GetCurrentProcess(), aSourceHandle,
|
||||
::GetCurrentProcess(), aTargetHandle,
|
||||
aDesiredAccess, false, aOptions);
|
||||
|
||||
}
|
||||
|
||||
#if defined(MOZ_SANDBOX)
|
||||
// Try the broker next (will fail if not sandboxed).
|
||||
if (SandboxTarget::Instance()->BrokerDuplicateHandle(aSourceHandle,
|
||||
aTargetProcessId,
|
||||
aTargetHandle,
|
||||
aDesiredAccess,
|
||||
aOptions)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Finally, see if we already have access to the process.
|
||||
ScopedProcessHandle targetProcess;
|
||||
if (!base::OpenProcessHandle(aTargetProcessId, &targetProcess.rwget())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!::DuplicateHandle(::GetCurrentProcess(), aSourceHandle,
|
||||
targetProcess, aTargetHandle,
|
||||
aDesiredAccess, FALSE, aOptions);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ProtocolErrorBreakpoint(const char* aMsg)
|
||||
{
|
||||
@ -271,7 +306,7 @@ ProtocolErrorBreakpoint(const char* aMsg)
|
||||
|
||||
void
|
||||
FatalError(const char* aProtocolName, const char* aMsg,
|
||||
ProcessHandle aHandle, bool aIsParent)
|
||||
ProcessId aOtherPid, bool aIsParent)
|
||||
{
|
||||
ProtocolErrorBreakpoint(aMsg);
|
||||
|
||||
@ -283,9 +318,16 @@ FatalError(const char* aProtocolName, const char* aMsg,
|
||||
formattedMessage.AppendLiteral("\". Killing child side as a result.");
|
||||
NS_ERROR(formattedMessage.get());
|
||||
|
||||
if (aHandle != kInvalidProcessHandle &&
|
||||
!base::KillProcess(aHandle, base::PROCESS_END_KILLED_BY_USER, false)) {
|
||||
NS_ERROR("May have failed to kill child!");
|
||||
if (aOtherPid != kInvalidProcessId && aOtherPid != kCurrentProcessId) {
|
||||
ScopedProcessHandle otherProcessHandle;
|
||||
if (base::OpenProcessHandle(aOtherPid, &otherProcessHandle.rwget())) {
|
||||
if (!base::KillProcess(otherProcessHandle,
|
||||
base::PROCESS_END_KILLED_BY_USER, false)) {
|
||||
NS_ERROR("May have failed to kill child!");
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("Failed to open child process when attempting kill.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
formattedMessage.AppendLiteral("\". abort()ing as a result.");
|
||||
|
@ -60,9 +60,38 @@ namespace ipc {
|
||||
|
||||
#ifdef XP_WIN
|
||||
const base::ProcessHandle kInvalidProcessHandle = INVALID_HANDLE_VALUE;
|
||||
|
||||
// In theory, on Windows, this is a valid process ID, but in practice they are
|
||||
// currently divisible by four. Process IDs share the kernel handle allocation
|
||||
// code and they are guaranteed to be divisible by four.
|
||||
// As this could change for process IDs we shouldn't generally rely on this
|
||||
// property, however even if that were to change, it seems safe to rely on this
|
||||
// particular value never being used.
|
||||
const base::ProcessId kInvalidProcessId = kuint32max;
|
||||
#else
|
||||
const base::ProcessHandle kInvalidProcessHandle = -1;
|
||||
const base::ProcessId kInvalidProcessId = -1;
|
||||
#endif
|
||||
const base::ProcessId kCurrentProcessId = base::GetCurrentProcId();
|
||||
|
||||
// Scoped base::ProcessHandle to ensure base::CloseProcessHandle is called.
|
||||
struct ScopedProcessHandleTraits
|
||||
{
|
||||
typedef base::ProcessHandle type;
|
||||
|
||||
static type empty()
|
||||
{
|
||||
return kInvalidProcessHandle;
|
||||
}
|
||||
|
||||
static void release(type aProcessHandle)
|
||||
{
|
||||
if (aProcessHandle && aProcessHandle != kInvalidProcessHandle) {
|
||||
base::CloseProcessHandle(aProcessHandle);
|
||||
}
|
||||
}
|
||||
};
|
||||
typedef mozilla::Scoped<ScopedProcessHandleTraits> ScopedProcessHandle;
|
||||
|
||||
class ProtocolFdMapping;
|
||||
class ProtocolCloneContext;
|
||||
@ -134,7 +163,7 @@ public:
|
||||
AbnormalShutdown
|
||||
};
|
||||
|
||||
typedef base::ProcessHandle ProcessHandle;
|
||||
typedef base::ProcessId ProcessId;
|
||||
|
||||
virtual int32_t Register(ListenerT*) = 0;
|
||||
virtual int32_t RegisterID(ListenerT*, int32_t) = 0;
|
||||
@ -150,7 +179,7 @@ public:
|
||||
virtual bool DestroySharedMemory(Shmem&) = 0;
|
||||
|
||||
// XXX odd ducks, acknowledged
|
||||
virtual ProcessHandle OtherProcess() const = 0;
|
||||
virtual ProcessId OtherPid() const = 0;
|
||||
virtual MessageChannel* GetIPCChannel() = 0;
|
||||
|
||||
// The implementation of function is generated by code generator.
|
||||
@ -266,18 +295,18 @@ ProtocolErrorBreakpoint(const char* aMsg);
|
||||
|
||||
MOZ_NEVER_INLINE void
|
||||
FatalError(const char* aProtocolName, const char* aMsg,
|
||||
base::ProcessHandle aHandle, bool aIsParent);
|
||||
base::ProcessId aOtherPid, bool aIsParent);
|
||||
|
||||
struct PrivateIPDLInterface {};
|
||||
|
||||
bool
|
||||
Bridge(const PrivateIPDLInterface&,
|
||||
MessageChannel*, base::ProcessHandle, MessageChannel*, base::ProcessHandle,
|
||||
MessageChannel*, base::ProcessId, MessageChannel*, base::ProcessId,
|
||||
ProtocolId, ProtocolId);
|
||||
|
||||
bool
|
||||
Open(const PrivateIPDLInterface&,
|
||||
MessageChannel*, base::ProcessHandle, Transport::Mode,
|
||||
MessageChannel*, base::ProcessId, Transport::Mode,
|
||||
ProtocolId, ProtocolId);
|
||||
|
||||
bool
|
||||
@ -285,6 +314,19 @@ UnpackChannelOpened(const PrivateIPDLInterface&,
|
||||
const IPC::Message&,
|
||||
TransportDescriptor*, base::ProcessId*, ProtocolId*);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// This is a restricted version of Windows' DuplicateHandle() function
|
||||
// that works inside the sandbox and can send handles but not retrieve
|
||||
// them. Unlike DuplicateHandle(), it takes a process ID rather than
|
||||
// a process handle. It returns true on success, false otherwise.
|
||||
bool
|
||||
DuplicateHandle(HANDLE aSourceHandle,
|
||||
DWORD aTargetProcessId,
|
||||
HANDLE* aTargetHandle,
|
||||
DWORD aDesiredAccess,
|
||||
DWORD aOptions);
|
||||
#endif
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -95,7 +95,7 @@ SharedMemoryBasic::Map(size_t nBytes)
|
||||
}
|
||||
|
||||
bool
|
||||
SharedMemoryBasic::ShareToProcess(base::ProcessHandle/*unused*/,
|
||||
SharedMemoryBasic::ShareToProcess(base::ProcessId/*unused*/,
|
||||
Handle* aNewHandle)
|
||||
{
|
||||
MOZ_ASSERT(mShmFd >= 0, "Should have been Create()d by now");
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
return aHandle.fd >= 0;
|
||||
}
|
||||
|
||||
bool ShareToProcess(base::ProcessHandle aProcess,
|
||||
bool ShareToProcess(base::ProcessId aProcessId,
|
||||
Handle* aNewHandle);
|
||||
|
||||
private:
|
||||
|
@ -73,11 +73,11 @@ public:
|
||||
return base::SharedMemory::IsHandleValid(aHandle);
|
||||
}
|
||||
|
||||
bool ShareToProcess(base::ProcessHandle process,
|
||||
bool ShareToProcess(base::ProcessId aProcessId,
|
||||
Handle* new_handle)
|
||||
{
|
||||
base::SharedMemoryHandle handle;
|
||||
bool ret = mSharedMemory.ShareToProcess(process, &handle);
|
||||
bool ret = mSharedMemory.ShareToProcess(aProcessId, &handle);
|
||||
if (ret)
|
||||
*new_handle = handle;
|
||||
return ret;
|
||||
|
@ -613,20 +613,15 @@ Shmem::GetSysVID() const
|
||||
|
||||
IPC::Message*
|
||||
Shmem::ShareTo(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
|
||||
base::ProcessHandle aProcess,
|
||||
base::ProcessId aTargetPid,
|
||||
int32_t routingId)
|
||||
{
|
||||
AssertInvariants();
|
||||
|
||||
// kInvalidProcessHandle is used to indicate that it's the same process.
|
||||
if (aProcess == kInvalidProcessHandle) {
|
||||
aProcess = base::GetCurrentProcessHandle();
|
||||
}
|
||||
|
||||
if (SharedMemory::TYPE_BASIC == mSegment->Type()) {
|
||||
SharedMemoryBasic* seg = static_cast<SharedMemoryBasic*>(mSegment);
|
||||
SharedMemoryBasic::Handle handle;
|
||||
if (!seg->ShareToProcess(aProcess, &handle))
|
||||
if (!seg->ShareToProcess(aTargetPid, &handle))
|
||||
return nullptr;
|
||||
|
||||
return new ShmemCreated(routingId, mId, mSize, handle);
|
||||
@ -647,7 +642,7 @@ Shmem::ShareTo(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
|
||||
|
||||
IPC::Message*
|
||||
Shmem::UnshareFrom(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
|
||||
base::ProcessHandle aProcess,
|
||||
base::ProcessId aTargetPid,
|
||||
int32_t routingId)
|
||||
{
|
||||
AssertInvariants();
|
||||
|
@ -215,16 +215,16 @@ public:
|
||||
// successful (owned by the caller), nullptr if not.
|
||||
IPC::Message*
|
||||
ShareTo(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
|
||||
base::ProcessHandle aProcess,
|
||||
base::ProcessId aTargetPid,
|
||||
int32_t routingId);
|
||||
|
||||
// Stop sharing this with |aProcess|. Return an IPC message that
|
||||
// Stop sharing this with |aTargetPid|. Return an IPC message that
|
||||
// contains enough information for the other process to unmap this
|
||||
// segment. Return a new message if successful (owned by the
|
||||
// caller), nullptr if not.
|
||||
IPC::Message*
|
||||
UnshareFrom(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
|
||||
base::ProcessHandle aProcess,
|
||||
base::ProcessId aTargetPid,
|
||||
int32_t routingId);
|
||||
|
||||
// Return a SharedMemory instance in this process using the
|
||||
|
@ -24,7 +24,7 @@ class FileDescriptor;
|
||||
|
||||
typedef IPC::Channel Transport;
|
||||
|
||||
bool CreateTransport(base::ProcessHandle aProcOne, base::ProcessHandle aProcTwo,
|
||||
bool CreateTransport(base::ProcessId aProcIdOne,
|
||||
TransportDescriptor* aOne, TransportDescriptor* aTwo);
|
||||
|
||||
Transport* OpenDescriptor(const TransportDescriptor& aTd,
|
||||
|
@ -22,7 +22,7 @@ namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
bool
|
||||
CreateTransport(ProcessHandle /*unused*/, ProcessHandle /*unused*/,
|
||||
CreateTransport(base::ProcessId /*unused*/,
|
||||
TransportDescriptor* aOne, TransportDescriptor* aTwo)
|
||||
{
|
||||
// Gecko doesn't care about this random ID, and the argument to this
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "chrome/common/child_process_info.h"
|
||||
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -18,7 +19,7 @@ namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
bool
|
||||
CreateTransport(ProcessHandle aProcOne, ProcessHandle /*unused*/,
|
||||
CreateTransport(base::ProcessId aProcIdOne,
|
||||
TransportDescriptor* aOne, TransportDescriptor* aTwo)
|
||||
{
|
||||
// This id is used to name the IPC pipe. The pointer passed to this
|
||||
@ -39,11 +40,7 @@ CreateTransport(ProcessHandle aProcOne, ProcessHandle /*unused*/,
|
||||
HANDLE serverDup;
|
||||
DWORD access = 0;
|
||||
DWORD options = DUPLICATE_SAME_ACCESS;
|
||||
if (!DuplicateHandle(GetCurrentProcess(), serverPipe, aProcOne,
|
||||
&serverDup,
|
||||
access,
|
||||
FALSE/*not inheritable*/,
|
||||
options)) {
|
||||
if (!DuplicateHandle(serverPipe, aProcIdOne, &serverDup, access, options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -164,8 +164,10 @@ LOCAL_INCLUDES += [
|
||||
'/toolkit/crashreporter',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
|
||||
LOCAL_INCLUDES += [
|
||||
'/security/sandbox/chromium',
|
||||
'/security/sandbox/chromium-shim',
|
||||
'/security/sandbox/win/src/sandboxbroker',
|
||||
]
|
||||
|
||||
|
@ -397,13 +397,13 @@ def _protocolErrorBreakpoint(msg):
|
||||
return StmtExpr(ExprCall(ExprVar('mozilla::ipc::ProtocolErrorBreakpoint'),
|
||||
args=[ msg ]))
|
||||
|
||||
def _ipcFatalError(name, msg, otherprocess, isparent):
|
||||
def _ipcFatalError(name, msg, otherpid, isparent):
|
||||
if isinstance(name, str):
|
||||
name = ExprLiteral.String(name)
|
||||
if isinstance(msg, str):
|
||||
msg = ExprLiteral.String(msg)
|
||||
return StmtExpr(ExprCall(ExprVar('mozilla::ipc::FatalError'),
|
||||
args=[ name, msg, otherprocess, isparent ]))
|
||||
args=[ name, msg, otherpid, isparent ]))
|
||||
|
||||
def _printWarningMessage(msg):
|
||||
if isinstance(msg, str):
|
||||
@ -1127,11 +1127,11 @@ class Protocol(ipdl.ast.Protocol):
|
||||
def destroySharedMemory(self):
|
||||
return ExprVar('DestroySharedMemory')
|
||||
|
||||
def otherProcessMethod(self):
|
||||
return ExprVar('OtherProcess')
|
||||
def otherPidMethod(self):
|
||||
return ExprVar('OtherPid')
|
||||
|
||||
def callOtherProcess(self, actorThis=None):
|
||||
fn = self.otherProcessMethod()
|
||||
def callOtherPid(self, actorThis=None):
|
||||
fn = self.otherPidMethod()
|
||||
if actorThis is not None:
|
||||
fn = ExprSelect(actorThis, '->', fn.name)
|
||||
return ExprCall(fn)
|
||||
@ -1248,9 +1248,9 @@ class Protocol(ipdl.ast.Protocol):
|
||||
mvar = ExprSelect(thisexpr, '->', mvar.name)
|
||||
return mvar
|
||||
|
||||
def otherProcessVar(self):
|
||||
def otherPidVar(self):
|
||||
assert self.decl.type.isToplevel()
|
||||
return ExprVar('mOtherProcess')
|
||||
return ExprVar('mOtherPid')
|
||||
|
||||
def managedCxxType(self, actortype, side):
|
||||
assert self.decl.type.isManagerOf(actortype)
|
||||
@ -1684,8 +1684,8 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
bridgefunc.addstmt(StmtReturn(ExprCall(
|
||||
ExprVar('mozilla::ipc::Bridge'),
|
||||
args=[ _backstagePass(),
|
||||
p.callGetChannel(parentvar), p.callOtherProcess(parentvar),
|
||||
p.callGetChannel(childvar), p.callOtherProcess(childvar),
|
||||
p.callGetChannel(parentvar), p.callOtherPid(parentvar),
|
||||
p.callGetChannel(childvar), p.callOtherPid(childvar),
|
||||
_protocolId(p.decl.type),
|
||||
ExprVar(_messageStartName(p.decl.type) + 'Child')
|
||||
])))
|
||||
@ -1705,7 +1705,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
openfunc.addstmt(StmtReturn(ExprCall(
|
||||
ExprVar('mozilla::ipc::Open'),
|
||||
args=[ _backstagePass(),
|
||||
p.callGetChannel(openervar), p.callOtherProcess(openervar),
|
||||
p.callGetChannel(openervar), p.callOtherPid(openervar),
|
||||
_sideToTransportMode(localside),
|
||||
_protocolId(p.decl.type),
|
||||
ExprVar(_messageStartName(p.decl.type) + 'Child')
|
||||
@ -1882,12 +1882,12 @@ def _generateMessageClass(clsname, msgid, priority, prettyName, compress):
|
||||
# generate a logging function
|
||||
# 'pfx' will be something like "[FooParent] sent"
|
||||
pfxvar = ExprVar('__pfx')
|
||||
otherprocess = ExprVar('__otherProcess')
|
||||
otherpid = ExprVar('__otherPid')
|
||||
receiving = ExprVar('__receiving')
|
||||
logger = MethodDefn(MethodDecl(
|
||||
'Log',
|
||||
params=([ Decl(Type('std::string', const=1, ref=1), pfxvar.name),
|
||||
Decl(Type('base::ProcessHandle'), otherprocess.name),
|
||||
Decl(Type('base::ProcessId'), otherpid.name),
|
||||
Decl(Type('bool'), receiving.name) ]),
|
||||
const=1))
|
||||
# TODO/cjones: allow selecting what information is printed to
|
||||
@ -1907,7 +1907,7 @@ def _generateMessageClass(clsname, msgid, priority, prettyName, compress):
|
||||
ExprCall(ExprVar('base::GetCurrentProcId')),
|
||||
ExprConditional(receiving, ExprLiteral.String('<-'),
|
||||
ExprLiteral.String('->')),
|
||||
otherprocess ])),
|
||||
otherpid ])),
|
||||
appendToMsg(pfxvar),
|
||||
appendToMsg(ExprLiteral.String(clsname +'(')),
|
||||
Whitespace.NL
|
||||
@ -2868,7 +2868,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
self.cls.addstmt(StmtDecl(MethodDecl(
|
||||
_allocMethod(actor.ptype, actor.side).name,
|
||||
params=[ Decl(Type('Transport', ptr=1), 'aTransport'),
|
||||
Decl(Type('ProcessId'), 'aOtherProcess') ],
|
||||
Decl(Type('ProcessId'), 'aOtherPid') ],
|
||||
ret=actortype,
|
||||
virtual=1, pure=1)))
|
||||
|
||||
@ -2929,8 +2929,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
[ ExprVar.THIS ]) ]),
|
||||
ExprMemberInit(p.lastActorIdVar(),
|
||||
[ p.actorIdInit(self.side) ]),
|
||||
ExprMemberInit(p.otherProcessVar(),
|
||||
[ ExprVar('ipc::kInvalidProcessHandle') ]),
|
||||
ExprMemberInit(p.otherPidVar(),
|
||||
[ ExprVar('ipc::kInvalidProcessId') ]),
|
||||
ExprMemberInit(p.lastShmemIdVar(),
|
||||
[ p.shmemIdInit(self.side) ]),
|
||||
ExprMemberInit(p.stateVar(),
|
||||
@ -2960,17 +2960,17 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
self.cls.addstmts([ dtor, Whitespace.NL ])
|
||||
|
||||
if ptype.isToplevel():
|
||||
# Open(Transport*, ProcessHandle, MessageLoop*, Side)
|
||||
# Open(Transport*, ProcessId, MessageLoop*, Side)
|
||||
aTransportVar = ExprVar('aTransport')
|
||||
aThreadVar = ExprVar('aThread')
|
||||
processvar = ExprVar('aOtherProcess')
|
||||
otherPidVar = ExprVar('aOtherPid')
|
||||
sidevar = ExprVar('aSide')
|
||||
openmeth = MethodDefn(
|
||||
MethodDecl(
|
||||
'Open',
|
||||
params=[ Decl(Type('Channel::Transport', ptr=True),
|
||||
aTransportVar.name),
|
||||
Decl(Type('ProcessHandle'), processvar.name),
|
||||
Decl(Type('base::ProcessId'), otherPidVar.name),
|
||||
Param(Type('MessageLoop', ptr=True),
|
||||
aThreadVar.name,
|
||||
default=ExprLiteral.NULL),
|
||||
@ -2980,7 +2980,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
ret=Type.BOOL))
|
||||
|
||||
openmeth.addstmts([
|
||||
StmtExpr(ExprAssn(p.otherProcessVar(), processvar)),
|
||||
StmtExpr(ExprAssn(p.otherPidVar(), otherPidVar)),
|
||||
StmtReturn(ExprCall(ExprSelect(p.channelVar(), '.', 'Open'),
|
||||
[ aTransportVar, aThreadVar, sidevar ]))
|
||||
])
|
||||
@ -3005,7 +3005,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
ret=Type.BOOL))
|
||||
|
||||
openmeth.addstmts([
|
||||
StmtExpr(ExprAssn(p.otherProcessVar(), ExprVar('ipc::kInvalidProcessHandle'))),
|
||||
StmtExpr(ExprAssn(p.otherPidVar(), ExprVar('ipc::kCurrentProcessId'))),
|
||||
StmtReturn(ExprCall(ExprSelect(p.channelVar(), '.', 'Open'),
|
||||
[ aChannel, aMessageLoop, sidevar ]))
|
||||
])
|
||||
@ -3331,30 +3331,21 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
self.cls.addstmts([ processnative, Whitespace.NL ])
|
||||
|
||||
if ptype.isToplevel() and self.side is 'parent':
|
||||
## void SetOtherProcess(ProcessHandle pid)
|
||||
otherprocessvar = ExprVar('aOtherProcess')
|
||||
setotherprocess = MethodDefn(MethodDecl(
|
||||
'SetOtherProcess',
|
||||
params=[ Decl(Type('ProcessHandle'), otherprocessvar.name)]))
|
||||
setotherprocess.addstmt(StmtExpr(ExprAssn(p.otherProcessVar(), otherprocessvar)))
|
||||
## void SetOtherProcessId(ProcessId aOtherPid)
|
||||
otherpidvar = ExprVar('aOtherPid')
|
||||
setotherprocessid = MethodDefn(MethodDecl(
|
||||
'SetOtherProcessId',
|
||||
params=[ Decl(Type('base::ProcessId'), otherpidvar.name)]))
|
||||
setotherprocessid.addstmts([
|
||||
StmtExpr(ExprAssn(p.otherPidVar(), otherpidvar)),
|
||||
])
|
||||
self.cls.addstmts([
|
||||
setotherprocess,
|
||||
setotherprocessid,
|
||||
Whitespace.NL])
|
||||
|
||||
## bool GetMinidump(nsIFile** dump)
|
||||
self.cls.addstmt(Label.PROTECTED)
|
||||
|
||||
otherpidvar = ExprVar('OtherSidePID')
|
||||
otherpid = MethodDefn(MethodDecl(
|
||||
otherpidvar.name, params=[ ],
|
||||
ret=Type('base::ProcessId'),
|
||||
const=1))
|
||||
otherpid.addstmts([
|
||||
StmtReturn(ExprCall(
|
||||
ExprVar('base::GetProcId'),
|
||||
args=[ p.otherProcessVar() ])),
|
||||
])
|
||||
|
||||
dumpvar = ExprVar('aDump')
|
||||
seqvar = ExprVar('aSequence')
|
||||
getdump = MethodDefn(MethodDecl(
|
||||
@ -3367,13 +3358,12 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
CppDirective('ifdef', 'MOZ_CRASHREPORTER'),
|
||||
StmtReturn(ExprCall(
|
||||
ExprVar('XRE_TakeMinidumpForChild'),
|
||||
args=[ ExprCall(otherpidvar), dumpvar, seqvar ])),
|
||||
args=[ ExprCall(p.otherPidMethod()), dumpvar, seqvar ])),
|
||||
CppDirective('else'),
|
||||
StmtReturn.FALSE,
|
||||
CppDirective('endif')
|
||||
])
|
||||
self.cls.addstmts([ otherpid, Whitespace.NL,
|
||||
getdump, Whitespace.NL ])
|
||||
self.cls.addstmts([ getdump, Whitespace.NL ])
|
||||
|
||||
## private methods
|
||||
self.cls.addstmt(Label.PRIVATE)
|
||||
@ -3387,13 +3377,13 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
params=[ Decl(Type('char', const=1, ptrconst=1), msgparam.name) ],
|
||||
const=1, never_inline=1))
|
||||
if self.side is 'parent':
|
||||
otherprocess = p.callOtherProcess()
|
||||
otherpid = p.callOtherPid()
|
||||
isparent = ExprLiteral.TRUE
|
||||
else:
|
||||
otherprocess = ExprLiteral.ZERO
|
||||
otherpid = ExprLiteral.ZERO
|
||||
isparent = ExprLiteral.FALSE
|
||||
fatalerror.addstmts([
|
||||
_ipcFatalError(actorname, msgparam, otherprocess, isparent)
|
||||
_ipcFatalError(actorname, msgparam, otherpid, isparent)
|
||||
])
|
||||
self.cls.addstmts([ fatalerror, Whitespace.NL ])
|
||||
|
||||
@ -3535,8 +3525,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
StmtDecl(Decl(Type('IDMap', T=Type('ProtocolBase')),
|
||||
p.actorMapVar().name)),
|
||||
StmtDecl(Decl(_actorIdType(), p.lastActorIdVar().name)),
|
||||
StmtDecl(Decl(Type('ProcessHandle'),
|
||||
p.otherProcessVar().name))
|
||||
StmtDecl(Decl(Type('base::ProcessId'),
|
||||
p.otherPidVar().name))
|
||||
])
|
||||
elif ptype.isManaged():
|
||||
self.cls.addstmts([
|
||||
@ -3625,11 +3615,12 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
params=[ Decl(_rawShmemType(ptr=1), rawvar.name) ],
|
||||
virtual=1))
|
||||
|
||||
otherprocess = MethodDefn(MethodDecl(
|
||||
p.otherProcessMethod().name,
|
||||
ret=Type('ProcessHandle'),
|
||||
otherpid = MethodDefn(MethodDecl(
|
||||
p.otherPidMethod().name,
|
||||
ret=Type('base::ProcessId'),
|
||||
const=1,
|
||||
virtual=1))
|
||||
|
||||
getchannel = MethodDefn(MethodDecl(
|
||||
p.getChannelMethod().name,
|
||||
ret=Type('MessageChannel', ptr=1),
|
||||
@ -3701,7 +3692,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
p.nextShmemIdExpr(self.side) ]),
|
||||
StmtDecl(Decl(Type('Message', ptr=1), descriptorvar.name),
|
||||
init=_shmemShareTo(shmemvar,
|
||||
p.callOtherProcess(),
|
||||
p.callOtherPid(),
|
||||
p.routingId()))
|
||||
])
|
||||
failif = StmtIf(ExprNot(descriptorvar))
|
||||
@ -3745,7 +3736,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
p.nextShmemIdExpr(self.side) ]),
|
||||
StmtDecl(Decl(Type('Message', ptr=1), descriptorvar.name),
|
||||
init=_shmemShareTo(shmemvar,
|
||||
p.callOtherProcess(),
|
||||
p.callOtherPid(),
|
||||
p.routingId()))
|
||||
])
|
||||
failif = StmtIf(ExprNot(descriptorvar))
|
||||
@ -3809,7 +3800,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
StmtDecl(Decl(Type('Message', ptr=1), descriptorvar.name),
|
||||
init=_shmemUnshareFrom(
|
||||
shmemvar,
|
||||
p.callOtherProcess(),
|
||||
p.callOtherPid(),
|
||||
p.routingId())),
|
||||
Whitespace.NL,
|
||||
StmtExpr(p.removeShmemId(idvar)),
|
||||
@ -3845,7 +3836,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
self.asyncSwitch.addcase(
|
||||
CaseLabel('SHMEM_DESTROYED_MESSAGE_TYPE'), abort)
|
||||
|
||||
otherprocess.addstmt(StmtReturn(p.otherProcessVar()))
|
||||
otherpid.addstmt(StmtReturn(p.otherPidVar()))
|
||||
getchannel.addstmt(StmtReturn(ExprAddrOf(p.channelVar())))
|
||||
else:
|
||||
# delegate registration to manager
|
||||
@ -3877,8 +3868,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
destroyshmem.addstmt(StmtReturn(ExprCall(
|
||||
ExprSelect(p.managerVar(), '->', p.destroySharedMemory().name),
|
||||
[ shmemvar ])))
|
||||
otherprocess.addstmt(StmtReturn(
|
||||
p.callOtherProcess(p.managerVar())))
|
||||
otherpid.addstmt(StmtReturn(
|
||||
p.callOtherPid(p.managerVar())))
|
||||
getchannel.addstmt(StmtReturn(p.channelVar()))
|
||||
|
||||
cloneprotocol.addstmts([
|
||||
@ -4024,7 +4015,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
lookupshmem,
|
||||
istracking,
|
||||
destroyshmem,
|
||||
otherprocess,
|
||||
otherpid,
|
||||
getchannel,
|
||||
clonemanagees,
|
||||
cloneprotocol,
|
||||
@ -4627,7 +4618,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
StmtDecl(Decl(_fdPickleType(), picklevar.name),
|
||||
init=ExprCall(ExprSelect(var, '.', 'ShareTo'),
|
||||
args=[ _fdBackstagePass(),
|
||||
self.protocol.callOtherProcess() ])),
|
||||
self.protocol.callOtherPid() ])),
|
||||
StmtExpr(ExprCall(ExprVar('IPC::WriteParam'),
|
||||
args=[ msgvar, picklevar ])),
|
||||
])
|
||||
@ -5404,7 +5395,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
return _ifLogging(ExprLiteral.String(topLevel), [ StmtExpr(ExprCall(
|
||||
ExprSelect(msgptr, '->', 'Log'),
|
||||
args=[ ExprLiteral.String('['+ actorname +'] '+ pfx),
|
||||
self.protocol.callOtherProcess(actor),
|
||||
self.protocol.callOtherPid(actor),
|
||||
ExprLiteral.TRUE if receiving else ExprLiteral.FALSE ])) ])
|
||||
|
||||
def profilerLabel(self, tag, msgname):
|
||||
|
@ -19,7 +19,7 @@ bool
|
||||
IPDLUnitTestProcessChild::Init()
|
||||
{
|
||||
IPDLUnitTestChildInit(IOThreadChild::channel(),
|
||||
ParentHandle(),
|
||||
ParentId(),
|
||||
IOThreadChild::message_loop());
|
||||
|
||||
if (NS_FAILED(nsRegion::InitStatic()))
|
||||
|
@ -16,8 +16,8 @@ class IPDLUnitTestProcessChild : public mozilla::ipc::ProcessChild
|
||||
typedef mozilla::ipc::ProcessChild ProcessChild;
|
||||
|
||||
public:
|
||||
IPDLUnitTestProcessChild(ProcessHandle aParentHandle) :
|
||||
ProcessChild(aParentHandle)
|
||||
IPDLUnitTestProcessChild(ProcessId aParentPid) :
|
||||
ProcessChild(aParentPid)
|
||||
{ }
|
||||
|
||||
~IPDLUnitTestProcessChild()
|
||||
|
@ -81,7 +81,7 @@ void QuitParent();
|
||||
extern void* gChildActor;
|
||||
|
||||
void IPDLUnitTestChildInit(IPC::Channel* transport,
|
||||
base::ProcessHandle parent,
|
||||
base::ProcessId parentPid,
|
||||
MessageLoop* worker);
|
||||
|
||||
void QuitChild();
|
||||
|
@ -371,7 +371,7 @@ ${CHILD_DELETE_CASES}
|
||||
|
||||
void
|
||||
IPDLUnitTestChildInit(IPC::Channel* transport,
|
||||
base::ProcessHandle parent,
|
||||
base::ProcessId parentPid,
|
||||
MessageLoop* worker)
|
||||
{
|
||||
switch (IPDLUnitTest()) {
|
||||
|
@ -132,6 +132,20 @@ SandboxBroker::SetSecurityLevelForContentProcess(int32_t aSandboxLevel)
|
||||
L"\\??\\pipe\\chrome.*");
|
||||
ret = ret && (sandbox::SBOX_ALL_OK == result);
|
||||
|
||||
// The content process needs to be able to duplicate named pipes back to the
|
||||
// broker process, which are File type handles.
|
||||
result = mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
|
||||
sandbox::TargetPolicy::HANDLES_DUP_BROKER,
|
||||
L"File");
|
||||
ret = ret && (sandbox::SBOX_ALL_OK == result);
|
||||
|
||||
// The content process needs to be able to duplicate shared memory to the
|
||||
// broker process, which are Section type handles.
|
||||
result = mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
|
||||
sandbox::TargetPolicy::HANDLES_DUP_BROKER,
|
||||
L"Section");
|
||||
ret = ret && (sandbox::SBOX_ALL_OK == result);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@ -204,6 +218,13 @@ SandboxBroker::SetSecurityLevelForPluginProcess(int32_t aSandboxLevel)
|
||||
L"\\??\\pipe\\chrome.*");
|
||||
ret = ret && (sandbox::SBOX_ALL_OK == result);
|
||||
|
||||
// The NPAPI process needs to be able to duplicate shared memory to the
|
||||
// content process, which are Section type handles.
|
||||
result = mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
|
||||
sandbox::TargetPolicy::HANDLES_DUP_ANY,
|
||||
L"Section");
|
||||
ret = ret && (sandbox::SBOX_ALL_OK == result);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -461,14 +461,6 @@ XRE_InitChildProcess(int aArgc,
|
||||
base::ProcessId parentPID = strtol(parentPIDString, &end, 10);
|
||||
MOZ_ASSERT(!*end, "invalid parent PID");
|
||||
|
||||
// Retrieve the parent process handle. We need this for shared memory use and
|
||||
// for creating new transports in the child.
|
||||
base::ProcessHandle parentHandle = 0;
|
||||
if (XRE_GetProcessType() != GeckoProcessType_GMPlugin) {
|
||||
mozilla::DebugOnly<bool> ok = base::OpenProcessHandle(parentPID, &parentHandle);
|
||||
MOZ_ASSERT(ok, "can't open handle to parent");
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
// On Win7+, register the application user model id passed in by
|
||||
// parent. This insures windows created by the container properly
|
||||
@ -534,11 +526,11 @@ XRE_InitChildProcess(int aArgc,
|
||||
break;
|
||||
|
||||
case GeckoProcessType_Plugin:
|
||||
process = new PluginProcessChild(parentHandle);
|
||||
process = new PluginProcessChild(parentPID);
|
||||
break;
|
||||
|
||||
case GeckoProcessType_Content: {
|
||||
process = new ContentProcess(parentHandle);
|
||||
process = new ContentProcess(parentPID);
|
||||
// If passed in grab the application path for xpcom init
|
||||
nsCString appDir;
|
||||
for (int idx = aArgc; idx > 0; idx--) {
|
||||
@ -553,14 +545,14 @@ XRE_InitChildProcess(int aArgc,
|
||||
|
||||
case GeckoProcessType_IPDLUnitTest:
|
||||
#ifdef MOZ_IPDL_TESTS
|
||||
process = new IPDLUnitTestProcessChild(parentHandle);
|
||||
process = new IPDLUnitTestProcessChild(parentPID);
|
||||
#else
|
||||
NS_RUNTIMEABORT("rebuild with --enable-ipdl-tests");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GeckoProcessType_GMPlugin:
|
||||
process = new gmp::GMPProcessChild(parentHandle);
|
||||
process = new gmp::GMPProcessChild(parentPID);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1147,6 +1147,9 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
|
||||
mCompositorChild = new CompositorChild(lm);
|
||||
mCompositorChild->Open(parentChannel, childMessageLoop, ipc::ChildSide);
|
||||
|
||||
// Make sure the parent knows it is same process.
|
||||
mCompositorParent->SetOtherProcessId(kCurrentProcessId);
|
||||
|
||||
if (gfxPrefs::AsyncPanZoomEnabled() &&
|
||||
(WindowType() == eWindowType_toplevel || WindowType() == eWindowType_child)) {
|
||||
ConfigureAPZCTreeManager();
|
||||
|
Loading…
Reference in New Issue
Block a user