Bug 1348361 - Part 2 - Introduce a GeckoChildProcessHost subclass, ContentProcessHost, that will be used for async process launches; r?jld
MozReview-Commit-ID: OgV5fcZM8m
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2136,17 +2136,17 @@ ContentParent::ContentParent(ContentPare
// Request Windows message deferral behavior on our side of the PContent
// channel. Generally only applies to the situation where we get caught in
// a deadlock with the plugin process when sending CPOWs.
GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
#endif
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()
{
if (mForceKillTimer) {
mForceKillTimer->Cancel();
}
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -6,26 +6,26 @@
#ifndef mozilla_dom_ContentParent_h
#define mozilla_dom_ContentParent_h
#include "mozilla/dom/PContentParent.h"
#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"
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReportingProcess.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtr.h"
+#include "ContentProcessHost.h"
#include "nsDataHashtable.h"
#include "nsPluginTags.h"
#include "nsFrameMessageManager.h"
#include "nsHashKeys.h"
#include "nsIInterfaceRequestor.h"
#include "nsIObserver.h"
#include "nsIThreadInternal.h"
#include "nsIDOMGeoPositionCallback.h"
@@ -109,24 +109,24 @@ class ContentParent final : public PCont
, public nsIDOMGeoPositionCallback
, public nsIDOMGeoPositionErrorCallback
, public nsIInterfaceRequestor
, public gfx::gfxVarReceiver
, public mozilla::LinkedListElement<ContentParent>
, 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;
typedef mozilla::ipc::URIParams URIParams;
typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
+ friend class ContentProcessHost;
friend class mozilla::PreallocatedProcessManagerImpl;
public:
virtual bool IsContentParent() const override { return true; }
/**
* Create a subprocess suitable for use later as a content process.
@@ -370,17 +370,17 @@ public:
{
return mIsForBrowser;
}
virtual bool IsForJSPlugin() const override
{
return mJSPluginID != nsFakePluginTag::NOT_JSPLUGIN;
}
- GeckoChildProcessHost* Process() const
+ ContentProcessHost* Process() const
{
return mSubprocess;
}
ContentParent* Opener() const
{
return mOpener;
}
@@ -1227,17 +1227,17 @@ public:
bool CanCommunicateWith(ContentParentId aOtherProcess);
private:
// If you add strong pointers to cycle collected objects here, be sure to
// 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;
nsString mRemoteType;
ContentParentId mChildID;
int32_t mGeolocationWatchID;
new file mode 100644
--- /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
new file mode 100644
--- /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_
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -23,16 +23,17 @@ EXPORTS.mozilla.dom += [
'CoalescedMouseData.h',
'CoalescedWheelData.h',
'ContentBridgeChild.h',
'ContentBridgeParent.h',
'ContentChild.h',
'ContentParent.h',
'ContentPrefs.h',
'ContentProcess.h',
+ 'ContentProcessHost.h',
'ContentProcessManager.h',
'CPOWManagerGetter.h',
'FilePickerParent.h',
'MemoryReportRequest.h',
'nsIContentChild.h',
'nsIContentParent.h',
'PermissionMessageUtils.h',
'TabChild.h',
@@ -55,16 +56,17 @@ UNIFIED_SOURCES += [
'CoalescedMouseData.cpp',
'CoalescedWheelData.cpp',
'ColorPickerParent.cpp',
'ContentBridgeChild.cpp',
'ContentBridgeParent.cpp',
'ContentParent.cpp',
'ContentPrefs.cpp',
'ContentProcess.cpp',
+ 'ContentProcessHost.cpp',
'ContentProcessManager.cpp',
'FilePickerParent.cpp',
'MemoryReportRequest.cpp',
'nsIContentChild.cpp',
'nsIContentParent.cpp',
'PermissionMessageUtils.cpp',
'PreallocatedProcessManager.cpp',
'ProcessPriorityManager.cpp',