зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1706374 - Part 12b: Use NodeController for primary process channels, r=handyman
This extends on the changes in part 12a and consumes the new PortRef-based API in all existing process types other than the fork server. The IPDL C++ unit tests were already broken before this change, and were not updated. Differential Revision: https://phabricator.services.mozilla.com/D112777
This commit is contained in:
Родитель
68c606d1e5
Коммит
1d4aba6770
|
@ -643,9 +643,8 @@ class nsGtkNativeInitRunnable : public Runnable {
|
|||
}
|
||||
};
|
||||
|
||||
bool ContentChild::Init(MessageLoop* aIOLoop, base::ProcessId aParentPid,
|
||||
const char* aParentBuildID,
|
||||
UniquePtr<IPC::Channel> aChannel, uint64_t aChildID,
|
||||
bool ContentChild::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
mozilla::ipc::ScopedPort aPort, uint64_t aChildID,
|
||||
bool aIsForBrowser) {
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// When running X11 only build we need to pass a display down
|
||||
|
@ -699,7 +698,7 @@ bool ContentChild::Init(MessageLoop* aIOLoop, base::ProcessId aParentPid,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!Open(std::move(aChannel), aParentPid, aIOLoop)) {
|
||||
if (!Open(std::move(aPort), aParentPid)) {
|
||||
return false;
|
||||
}
|
||||
sSingleton = this;
|
||||
|
|
|
@ -119,9 +119,9 @@ class ContentChild final : public PContentChild,
|
|||
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
BrowsingContext** aReturn);
|
||||
|
||||
bool Init(MessageLoop* aIOLoop, base::ProcessId aParentPid,
|
||||
const char* aParentBuildID, UniquePtr<IPC::Channel> aChannel,
|
||||
uint64_t aChildID, bool aIsForBrowser);
|
||||
bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
mozilla::ipc::ScopedPort aPort, uint64_t aChildID,
|
||||
bool aIsForBrowser);
|
||||
|
||||
void InitXPCOM(XPCOMInitData&& aXPCOMInit,
|
||||
const mozilla::dom::ipc::StructuredCloneData& aInitialData);
|
||||
|
|
|
@ -2570,16 +2570,14 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync,
|
|||
ProcessPriority aPriority) {
|
||||
AUTO_PROFILER_LABEL("ContentParent::LaunchSubprocess::resolve", OTHER);
|
||||
|
||||
// Take the pending IPC channel. This channel will be used to open the raw IPC
|
||||
// connection between this process and the launched content process.
|
||||
UniquePtr<IPC::Channel> channel = mSubprocess->TakeChannel();
|
||||
if (!channel) {
|
||||
// We don't have a channel, so this method must've been called already.
|
||||
if (mLaunchResolved) {
|
||||
// We've already been called, return.
|
||||
MOZ_ASSERT(sCreatedFirstContentProcess);
|
||||
MOZ_ASSERT(!mPrefSerializer);
|
||||
MOZ_ASSERT(mLifecycleState != LifecycleState::LAUNCHING);
|
||||
return true;
|
||||
}
|
||||
mLaunchResolved = true;
|
||||
|
||||
// Now that communication with the child is complete, we can cleanup
|
||||
// the preference serializer.
|
||||
|
@ -2604,7 +2602,7 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync,
|
|||
|
||||
base::ProcessId procId =
|
||||
base::GetProcId(mSubprocess->GetChildProcessHandle());
|
||||
Open(std::move(channel), procId);
|
||||
Open(mSubprocess->TakeInitialPort(), procId);
|
||||
|
||||
ContentProcessManager::GetSingleton()->AddContentProcess(this);
|
||||
|
||||
|
@ -2732,6 +2730,7 @@ ContentParent::ContentParent(const nsACString& aRemoteType, int32_t aJSPluginID)
|
|||
mCalledKillHard(false),
|
||||
mCreatedPairedMinidumps(false),
|
||||
mShutdownPending(false),
|
||||
mLaunchResolved(false),
|
||||
mIsRemoteInputEventQueueEnabled(false),
|
||||
mIsInputPriorityEventEnabled(false),
|
||||
mIsInPool(false),
|
||||
|
|
|
@ -1543,6 +1543,7 @@ class ContentParent final
|
|||
uint8_t mCalledKillHard : 1;
|
||||
uint8_t mCreatedPairedMinidumps : 1;
|
||||
uint8_t mShutdownPending : 1;
|
||||
uint8_t mLaunchResolved : 1;
|
||||
|
||||
// True if the input event queue on the main thread of the content process is
|
||||
// enabled.
|
||||
|
|
|
@ -196,8 +196,8 @@ bool ContentProcess::Init(int aArgc, char* aArgv[]) {
|
|||
return false;
|
||||
}
|
||||
|
||||
mContent.Init(IOThreadChild::message_loop(), ParentPid(), *parentBuildID,
|
||||
IOThreadChild::TakeChannel(), *childID, *isForBrowser);
|
||||
mContent.Init(ParentPid(), *parentBuildID, IOThreadChild::TakeInitialPort(),
|
||||
*childID, *isForBrowser);
|
||||
|
||||
mXREEmbed.Start();
|
||||
#if (defined(XP_MACOSX)) && defined(MOZ_SANDBOX)
|
||||
|
|
|
@ -155,11 +155,11 @@ static bool GetPluginPaths(const nsAString& aPluginPath,
|
|||
#endif // XP_MACOSX
|
||||
|
||||
bool GMPChild::Init(const nsAString& aPluginPath, base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel) {
|
||||
mozilla::ipc::ScopedPort aPort) {
|
||||
GMP_CHILD_LOG_DEBUG("%s pluginPath=%s", __FUNCTION__,
|
||||
NS_ConvertUTF16toUTF8(aPluginPath).get());
|
||||
|
||||
if (NS_WARN_IF(!Open(std::move(aChannel), aParentPid, aIOLoop))) {
|
||||
if (NS_WARN_IF(!Open(std::move(aPort), aParentPid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class GMPChild : public PGMPChild {
|
|||
virtual ~GMPChild();
|
||||
|
||||
bool Init(const nsAString& aPluginPath, base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel);
|
||||
mozilla::ipc::ScopedPort aPort);
|
||||
MessageLoop* GMPMessageLoop();
|
||||
|
||||
// Main thread only.
|
||||
|
|
|
@ -280,7 +280,7 @@ nsresult GMPParent::LoadProcess() {
|
|||
mChildPid = base::GetProcId(mProcess->GetChildProcessHandle());
|
||||
GMP_PARENT_LOG_DEBUG("%s: Launched new child process", __FUNCTION__);
|
||||
|
||||
bool opened = Open(mProcess->TakeChannel(),
|
||||
bool opened = Open(mProcess->TakeInitialPort(),
|
||||
base::GetProcId(mProcess->GetChildProcessHandle()));
|
||||
if (!opened) {
|
||||
GMP_PARENT_LOG_DEBUG("%s: Failed to open channel to new child process",
|
||||
|
|
|
@ -41,8 +41,7 @@ bool GMPProcessChild::Init(int aArgc, char* aArgv[]) {
|
|||
BackgroundHangMonitor::Startup();
|
||||
|
||||
return mPlugin.Init(pluginFilename, ParentPid(),
|
||||
IOThreadChild::message_loop(),
|
||||
IOThreadChild::TakeChannel());
|
||||
IOThreadChild::TakeInitialPort());
|
||||
}
|
||||
|
||||
void GMPProcessChild::CleanUp() { BackgroundHangMonitor::Shutdown(); }
|
||||
|
|
|
@ -68,7 +68,7 @@ RDDParent* RDDParent::GetSingleton() {
|
|||
}
|
||||
|
||||
bool RDDParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel) {
|
||||
mozilla::ipc::ScopedPort aPort) {
|
||||
// Initialize the thread manager before starting IPC. Otherwise, messages
|
||||
// may be posted to the main thread and we won't be able to process them.
|
||||
if (NS_WARN_IF(NS_FAILED(nsThreadManager::get().Init()))) {
|
||||
|
@ -76,7 +76,7 @@ bool RDDParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
|||
}
|
||||
|
||||
// Now it's safe to start IPC.
|
||||
if (NS_WARN_IF(!Open(std::move(aChannel), aParentPid, aIOLoop))) {
|
||||
if (NS_WARN_IF(!Open(std::move(aPort), aParentPid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class RDDParent final : public PRDDParent {
|
|||
AsyncBlockers& AsyncShutdownService() { return mShutdownBlockers; }
|
||||
|
||||
bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel);
|
||||
mozilla::ipc::ScopedPort aPort);
|
||||
|
||||
mozilla::ipc::IPCResult RecvInit(nsTArray<GfxVarUpdate>&& vars,
|
||||
const Maybe<ipc::FileDescriptor>& aBrokerFd,
|
||||
|
|
|
@ -167,8 +167,8 @@ void RDDProcessHost::InitAfterConnect(bool aSucceeded) {
|
|||
}
|
||||
mProcessToken = ++sRDDProcessTokenCounter;
|
||||
mRDDChild = MakeUnique<RDDChild>(this);
|
||||
DebugOnly<bool> rv =
|
||||
mRDDChild->Open(TakeChannel(), base::GetProcId(GetChildProcessHandle()));
|
||||
DebugOnly<bool> rv = mRDDChild->Open(
|
||||
TakeInitialPort(), base::GetProcId(GetChildProcessHandle()));
|
||||
MOZ_ASSERT(rv);
|
||||
|
||||
// Only clear mPrefSerializer in the success case to avoid a
|
||||
|
|
|
@ -80,8 +80,8 @@ bool RDDProcessImpl::Init(int aArgc, char* aArgv[]) {
|
|||
return false;
|
||||
}
|
||||
|
||||
return mRDD.Init(ParentPid(), parentBuildID, IOThreadChild::message_loop(),
|
||||
IOThreadChild::TakeChannel());
|
||||
return mRDD.Init(ParentPid(), parentBuildID,
|
||||
IOThreadChild::TakeInitialPort());
|
||||
}
|
||||
|
||||
void RDDProcessImpl::CleanUp() { NS_ShutdownXPCOM(nullptr); }
|
||||
|
|
|
@ -140,7 +140,7 @@ GPUParent* GPUParent::GetSingleton() {
|
|||
}
|
||||
|
||||
bool GPUParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel) {
|
||||
mozilla::ipc::ScopedPort aPort) {
|
||||
// Initialize the thread manager before starting IPC. Otherwise, messages
|
||||
// may be posted to the main thread and we won't be able to process them.
|
||||
if (NS_WARN_IF(NS_FAILED(nsThreadManager::get().Init()))) {
|
||||
|
@ -148,7 +148,7 @@ bool GPUParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
|||
}
|
||||
|
||||
// Now it's safe to start IPC.
|
||||
if (NS_WARN_IF(!Open(std::move(aChannel), aParentPid, aIOLoop))) {
|
||||
if (NS_WARN_IF(!Open(std::move(aPort), aParentPid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class GPUParent final : public PGPUParent {
|
|||
static bool MaybeFlushMemory();
|
||||
|
||||
bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel);
|
||||
mozilla::ipc::ScopedPort aPort);
|
||||
void NotifyDeviceReset();
|
||||
|
||||
already_AddRefed<PAPZInputBridgeParent> AllocPAPZInputBridgeParent(
|
||||
|
|
|
@ -139,7 +139,7 @@ void GPUProcessHost::InitAfterConnect(bool aSucceeded) {
|
|||
mProcessToken = ++sProcessTokenCounter;
|
||||
mGPUChild = MakeUnique<GPUChild>(this);
|
||||
DebugOnly<bool> rv = mGPUChild->Open(
|
||||
TakeChannel(), base::GetProcId(GetChildProcessHandle()));
|
||||
TakeInitialPort(), base::GetProcId(GetChildProcessHandle()));
|
||||
MOZ_ASSERT(rv);
|
||||
|
||||
mGPUChild->Init();
|
||||
|
|
|
@ -73,8 +73,8 @@ bool GPUProcessImpl::Init(int aArgc, char* aArgv[]) {
|
|||
return false;
|
||||
}
|
||||
|
||||
return mGPU.Init(ParentPid(), parentBuildID, IOThreadChild::message_loop(),
|
||||
IOThreadChild::TakeChannel());
|
||||
return mGPU.Init(ParentPid(), parentBuildID,
|
||||
IOThreadChild::TakeInitialPort());
|
||||
}
|
||||
|
||||
void GPUProcessImpl::CleanUp() { NS_ShutdownXPCOM(nullptr); }
|
||||
|
|
|
@ -132,7 +132,7 @@ void VRParent::ActorDestroy(ActorDestroyReason aWhy) {
|
|||
}
|
||||
|
||||
bool VRParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel) {
|
||||
mozilla::ipc::ScopedPort aPort) {
|
||||
// Initialize the thread manager before starting IPC. Otherwise, messages
|
||||
// may be posted to the main thread and we won't be able to process them.
|
||||
if (NS_WARN_IF(NS_FAILED(nsThreadManager::get().Init()))) {
|
||||
|
@ -140,7 +140,7 @@ bool VRParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
|||
}
|
||||
|
||||
// Now it's safe to start IPC.
|
||||
if (NS_WARN_IF(!Open(std::move(aChannel), aParentPid, aIOLoop))) {
|
||||
if (NS_WARN_IF(!Open(std::move(aPort), aParentPid))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class VRParent final : public PVRParent {
|
|||
explicit VRParent();
|
||||
|
||||
bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel);
|
||||
mozilla::ipc::ScopedPort aPort);
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
bool GetOpenVRControllerActionPath(nsCString* aPath);
|
||||
bool GetOpenVRControllerManifestPath(VRControllerType aType,
|
||||
|
|
|
@ -72,8 +72,7 @@ bool VRProcessChild::Init(int aArgc, char* aArgv[]) {
|
|||
}
|
||||
|
||||
sVRParent = new VRParent();
|
||||
sVRParent->Init(ParentPid(), parentBuildID, IOThreadChild::message_loop(),
|
||||
IOThreadChild::TakeChannel());
|
||||
sVRParent->Init(ParentPid(), parentBuildID, IOThreadChild::TakeInitialPort());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -157,8 +157,8 @@ bool VRProcessParent::InitAfterConnect(bool aSucceeded) {
|
|||
|
||||
mVRChild = MakeUnique<VRChild>(this);
|
||||
|
||||
DebugOnly<bool> rv =
|
||||
mVRChild->Open(TakeChannel(), base::GetProcId(GetChildProcessHandle()));
|
||||
DebugOnly<bool> rv = mVRChild->Open(
|
||||
TakeInitialPort(), base::GetProcId(GetChildProcessHandle()));
|
||||
MOZ_ASSERT(rv);
|
||||
|
||||
mVRChild->Init();
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace mozilla {
|
|||
namespace _ipdltest {
|
||||
|
||||
bool IPDLUnitTestProcessChild::Init(int aArgc, char* aArgv[]) {
|
||||
// FIXME(nika): this is quite clearly broken and needs to be fixed.
|
||||
IPDLUnitTestChildInit(IOThreadChild::TakeChannel(), ParentPid(),
|
||||
IOThreadChild::message_loop());
|
||||
|
||||
|
|
|
@ -98,12 +98,12 @@ void CGSShutdownServerConnections();
|
|||
#endif
|
||||
|
||||
bool SocketProcessChild::Init(base::ProcessId aParentPid,
|
||||
const char* aParentBuildID, MessageLoop* aIOLoop,
|
||||
UniquePtr<IPC::Channel> aChannel) {
|
||||
const char* aParentBuildID,
|
||||
mozilla::ipc::ScopedPort aPort) {
|
||||
if (NS_WARN_IF(NS_FAILED(nsThreadManager::get().Init()))) {
|
||||
return false;
|
||||
}
|
||||
if (NS_WARN_IF(!Open(std::move(aChannel), aParentPid, aIOLoop))) {
|
||||
if (NS_WARN_IF(!Open(std::move(aPort), aParentPid))) {
|
||||
return false;
|
||||
}
|
||||
// This must be sent before any IPDL message, which may hit sentinel
|
||||
|
|
|
@ -35,7 +35,7 @@ class SocketProcessChild final
|
|||
static SocketProcessChild* GetSingleton();
|
||||
|
||||
bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
|
||||
MessageLoop* aIOLoop, UniquePtr<IPC::Channel> aChannel);
|
||||
mozilla::ipc::ScopedPort aPort);
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ void SocketProcessHost::InitAfterConnect(bool aSucceeded) {
|
|||
|
||||
mSocketProcessParent = MakeUnique<SocketProcessParent>(this);
|
||||
DebugOnly<bool> rv = mSocketProcessParent->Open(
|
||||
TakeChannel(), base::GetProcId(GetChildProcessHandle()));
|
||||
TakeInitialPort(), base::GetProcId(GetChildProcessHandle()));
|
||||
MOZ_ASSERT(rv);
|
||||
|
||||
SocketPorcessInitAttributes attributes;
|
||||
|
|
|
@ -105,8 +105,7 @@ bool SocketProcessImpl::Init(int aArgc, char* aArgv[]) {
|
|||
}
|
||||
|
||||
return mSocketProcessChild.Init(ParentPid(), parentBuildID,
|
||||
IOThreadChild::message_loop(),
|
||||
IOThreadChild::TakeChannel());
|
||||
IOThreadChild::TakeInitialPort());
|
||||
}
|
||||
|
||||
void SocketProcessImpl::CleanUp() { mSocketProcessChild.CleanUp(); }
|
||||
|
|
|
@ -22,9 +22,8 @@ RemoteSandboxBrokerChild::RemoteSandboxBrokerChild() {
|
|||
RemoteSandboxBrokerChild::~RemoteSandboxBrokerChild() {}
|
||||
|
||||
bool RemoteSandboxBrokerChild::Init(base::ProcessId aParentPid,
|
||||
MessageLoop* aIOLoop,
|
||||
UniquePtr<IPC::Channel> aChannel) {
|
||||
if (NS_WARN_IF(!Open(std::move(aChannel), aParentPid, aIOLoop))) {
|
||||
mozilla::ipc::ScopedPort aPort) {
|
||||
if (NS_WARN_IF(!Open(std::move(aPort), aParentPid))) {
|
||||
return false;
|
||||
}
|
||||
CrashReporterClient::InitSingleton(this);
|
||||
|
|
|
@ -18,8 +18,7 @@ class RemoteSandboxBrokerChild : public PRemoteSandboxBrokerChild {
|
|||
public:
|
||||
RemoteSandboxBrokerChild();
|
||||
virtual ~RemoteSandboxBrokerChild();
|
||||
bool Init(base::ProcessId aParentPid, MessageLoop* aIOLoop,
|
||||
UniquePtr<IPC::Channel> aChannel);
|
||||
bool Init(base::ProcessId aParentPid, mozilla::ipc::ScopedPort aPort);
|
||||
|
||||
private:
|
||||
mozilla::ipc::IPCResult AnswerLaunchApp(LaunchParameters&& aParams,
|
||||
|
|
|
@ -27,7 +27,7 @@ RefPtr<GenericPromise> RemoteSandboxBrokerParent::Launch(
|
|||
// Note: we rely on the caller to keep this instance alive while we launch
|
||||
// the process, so that these closures point to valid memory.
|
||||
auto resolve = [this](base::ProcessHandle handle) {
|
||||
mOpened = Open(mProcess->TakeChannel(), base::GetProcId(handle));
|
||||
mOpened = Open(mProcess->TakeInitialPort(), base::GetProcId(handle));
|
||||
if (!mOpened) {
|
||||
mProcess->Destroy();
|
||||
mProcess = nullptr;
|
||||
|
|
|
@ -21,8 +21,8 @@ RemoteSandboxBrokerProcessChild::~RemoteSandboxBrokerProcessChild() {}
|
|||
|
||||
bool RemoteSandboxBrokerProcessChild::Init(int aArgc, char* aArgv[]) {
|
||||
BackgroundHangMonitor::Startup();
|
||||
return mSandboxBrokerChild.Init(ParentPid(), IOThreadChild::message_loop(),
|
||||
IOThreadChild::TakeChannel());
|
||||
return mSandboxBrokerChild.Init(ParentPid(),
|
||||
IOThreadChild::TakeInitialPort());
|
||||
}
|
||||
|
||||
void RemoteSandboxBrokerProcessChild::CleanUp() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче