From fc6d4621a161921aa344e6b215753b3a2196a227 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 22 Feb 2018 14:29:49 -0500 Subject: [PATCH] Bug 1348361 - Part 2 - Introduce a GeckoChildProcessHost subclass, ContentProcessHost, that will be used for async process launches; r=jld MozReview-Commit-ID: OgV5fcZM8m --HG-- extra : rebase_source : 717f37bdc004480ef1dc90cc565324766e5b7b09 --- dom/ipc/ContentParent.cpp | 2 +- dom/ipc/ContentParent.h | 8 +++---- dom/ipc/ContentProcessHost.cpp | 29 ++++++++++++++++++++++++ dom/ipc/ContentProcessHost.h | 41 ++++++++++++++++++++++++++++++++++ dom/ipc/moz.build | 2 ++ 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 dom/ipc/ContentProcessHost.cpp create mode 100644 dom/ipc/ContentProcessHost.h diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index e69664e46b62..9f82ddf7ec74 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2141,7 +2141,7 @@ ContentParent::ContentParent(ContentParent* aOpener, NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); bool isFile = mRemoteType.EqualsLiteral(FILE_REMOTE_TYPE); - mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, isFile); + mSubprocess = new ContentProcessHost(this, isFile); } ContentParent::~ContentParent() diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 5367571bc448..3ced4a4c3a66 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -11,7 +11,6 @@ #include "mozilla/dom/nsIContentParent.h" #include "mozilla/gfx/gfxVarReceiver.h" #include "mozilla/gfx/GPUProcessListener.h" -#include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/Attributes.h" #include "mozilla/FileUtils.h" #include "mozilla/HalTypes.h" @@ -21,6 +20,7 @@ #include "mozilla/TimeStamp.h" #include "mozilla/UniquePtr.h" +#include "ContentProcessHost.h" #include "nsDataHashtable.h" #include "nsPluginTags.h" #include "nsFrameMessageManager.h" @@ -114,7 +114,6 @@ class ContentParent final : public PContentParent , public gfx::GPUProcessListener , public mozilla::MemoryReportingProcess { - typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost; typedef mozilla::ipc::OptionalURIParams OptionalURIParams; typedef mozilla::ipc::PFileDescriptorSetParent PFileDescriptorSetParent; typedef mozilla::ipc::TestShellParent TestShellParent; @@ -122,6 +121,7 @@ class ContentParent final : public PContentParent typedef mozilla::ipc::PrincipalInfo PrincipalInfo; typedef mozilla::dom::ClonedMessageData ClonedMessageData; + friend class ContentProcessHost; friend class mozilla::PreallocatedProcessManagerImpl; public: @@ -375,7 +375,7 @@ public: return mJSPluginID != nsFakePluginTag::NOT_JSPLUGIN; } - GeckoChildProcessHost* Process() const + ContentProcessHost* Process() const { return mSubprocess; } @@ -1232,7 +1232,7 @@ private: // release these objects in ShutDownProcess. See the comment there for more // details. - GeckoChildProcessHost* mSubprocess; + ContentProcessHost* mSubprocess; const TimeStamp mLaunchTS; // used to calculate time to start content process TimeStamp mActivateTS; ContentParent* mOpener; diff --git a/dom/ipc/ContentProcessHost.cpp b/dom/ipc/ContentProcessHost.cpp new file mode 100644 index 000000000000..6eb5a8492cac --- /dev/null +++ b/dom/ipc/ContentProcessHost.cpp @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: sts=8 sw=2 ts=2 tw=99 et : + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "ContentProcessHost.h" + +namespace mozilla { +namespace dom { + +using namespace ipc; + +ContentProcessHost::ContentProcessHost(ContentParent* aContentParent, + bool aIsFileContent) + : GeckoChildProcessHost(GeckoProcessType_Content, aIsFileContent), + mHasLaunched(false), + mContentParent(aContentParent) +{ + MOZ_COUNT_CTOR(ContentProcessHost); +} + +ContentProcessHost::~ContentProcessHost() +{ + MOZ_COUNT_DTOR(ContentProcessHost); +} + +} // namespace dom +} // namespace mozilla diff --git a/dom/ipc/ContentProcessHost.h b/dom/ipc/ContentProcessHost.h new file mode 100644 index 000000000000..e5db803d31ed --- /dev/null +++ b/dom/ipc/ContentProcessHost.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: sts=8 sw=2 ts=2 tw=99 et : + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _include_mozilla_dom_ipc_ContentProcessHost_h_ +#define _include_mozilla_dom_ipc_ContentProcessHost_h_ + +#include "mozilla/ipc/GeckoChildProcessHost.h" + +namespace mozilla { +namespace dom { + +class ContentParent; + +// ContentProcessHost is the "parent process" container for a subprocess handle +// and IPC connection. It owns the parent process IPDL actor, which in this +// case, is a ContentParent. +class ContentProcessHost final : public ::mozilla::ipc::GeckoChildProcessHost +{ + friend class ContentParent; + +public: + explicit + ContentProcessHost(ContentParent* aContentParent, + bool aIsFileContent = false); + ~ContentProcessHost(); + +private: + DISALLOW_COPY_AND_ASSIGN(ContentProcessHost); + + bool mHasLaunched; + + ContentParent* mContentParent; // weak +}; + +} // namespace dom +} // namespace mozilla + +#endif // _include_mozilla_dom_ipc_ContentProcessHost_h_ diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index 6753681e7eea..3c5541c7791b 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -28,6 +28,7 @@ EXPORTS.mozilla.dom += [ 'ContentParent.h', 'ContentPrefs.h', 'ContentProcess.h', + 'ContentProcessHost.h', 'ContentProcessManager.h', 'CPOWManagerGetter.h', 'FilePickerParent.h', @@ -60,6 +61,7 @@ UNIFIED_SOURCES += [ 'ContentParent.cpp', 'ContentPrefs.cpp', 'ContentProcess.cpp', + 'ContentProcessHost.cpp', 'ContentProcessManager.cpp', 'FilePickerParent.cpp', 'MemoryReportRequest.cpp',