Bug 1541130: Add XRE_GetChildProcBinPathType to nsXULAppAPI.h; r=froydnj,jld on a CLOSED TREE
authorAaron Klotz <aklotz@mozilla.com>
Tue, 09 Apr 2019 00:45:24 +0300
changeset 468431 b34795658d239ba6415a9ad5e72fe10d7de38265
parent 468430 5da5b22bc3a74a98ec3cc23712199a0fd0f2ffdc
child 468432 a9c4558b49752b6d20fcbaf5203c8a2ce7132541
push id35837
push userrmaries@mozilla.com
push dateTue, 09 Apr 2019 03:43:40 +0000
treeherdermozilla-central@9eb55c9bf557 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, jld
bugs1541130
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1541130: Add XRE_GetChildProcBinPathType to nsXULAppAPI.h; r=froydnj,jld on a CLOSED TREE The binary path type of a particular content process is useful information outside of IPC. Given that `XRE_EnableSameExecutableForContentProc` already exists, and given that the binary path type is closely related to `GeckoProcessType`, I've added a new function, `XRE_GetContentProcBinPathType`. The mapping of process type to binary type has been moved to the `GeckoProcessTypes` definitions. This patch also modifies `ipc::GeckoChildProcessHost` to call into the new function. Differential Revision: https://phabricator.services.mozilla.com/D25816
ipc/glue/CrashReporterHost.cpp
xpcom/build/GeckoProcessTypes.h
xpcom/build/nsXULAppAPI.h
--- a/ipc/glue/CrashReporterHost.cpp
+++ b/ipc/glue/CrashReporterHost.cpp
@@ -121,19 +121,19 @@ bool CrashReporterHost::FinalizeCrashRep
   if (mProcessType == GeckoProcessType_GMPlugin) {
     type.AssignLiteral("plugin");
   } else if (mProcessType == GeckoProcessType_Content) {
     type.AssignLiteral("content");
   } else {
     // This check will pick up some cases that will never happen (e.g. IPDL
     // unit tests), but that's OK.
     switch (mProcessType) {
-#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name) \
-  case GeckoProcessType_##enum_name:                         \
-    type.AssignLiteral(string_name);                         \
+#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name, bin_type) \
+  case GeckoProcessType_##enum_name:                                   \
+    type.AssignLiteral(string_name);                                   \
     break;
 #include "mozilla/GeckoProcessTypes.h"
 #undef GECKO_PROCESS_TYPE
       default:
         NS_ERROR("unknown process type");
         break;
     }
   }
@@ -194,19 +194,19 @@ void CrashReporterHost::NotifyCrashServi
       break;
   }
 
   if (aProcessType == GeckoProcessType_Plugin &&
       aCrashType == nsICrashService::CRASH_TYPE_HANG) {
     telemetryKey.AssignLiteral("pluginhang");
   } else {
     switch (aProcessType) {
-#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name) \
-  case GeckoProcessType_##enum_name:                         \
-    telemetryKey.AssignLiteral(string_name);                 \
+#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name, bin_type) \
+  case GeckoProcessType_##enum_name:                                   \
+    telemetryKey.AssignLiteral(string_name);                           \
     break;
 #include "mozilla/GeckoProcessTypes.h"
 #undef GECKO_PROCESS_TYPE
       // We can't really hit this, thanks to the above switch, but having it
       // here will placate the compiler.
       default:
         NS_ERROR("unknown process type");
         return;
--- a/xpcom/build/GeckoProcessTypes.h
+++ b/xpcom/build/GeckoProcessTypes.h
@@ -1,31 +1,38 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
-// GECKO_PROCESS_TYPE(enum-name, string-name, XRE_Is${NAME}Process)
+// GECKO_PROCESS_TYPE(enum-name, string-name, XRE_Is${NAME}Process, process-bin-type)
 // Note that string-name is exposed to various things like telemetry
 // and the crash reporter, so it should not be changed casually.
 //
+// process-bin-type should be either Self or PluginContainer, and determines
+// whether the child process may be started using the same binary as the parent
+// process, or whether to use plugin-container (Note that whether or not this
+// value is actually obeyed depends on platform and build configuration. Do not
+// use this value directly, but rather use XRE_GetChildProcBinPathType to
+// resolve this).
+//
 // The values generated for the GeckoProcessType enum are dependent on
 // the ordering of the GECKO_PROCESS_TYPE invocations in this file, and
 // said values are exposed to things like telemetry as well, so please
 // do not reorder lines in this file.
 //
 // Please add new process types at the end of this list.
-GECKO_PROCESS_TYPE(Default, "default", Parent)
-GECKO_PROCESS_TYPE(Plugin, "plugin", Plugin)
-GECKO_PROCESS_TYPE(Content, "tab", Content)
-GECKO_PROCESS_TYPE(IPDLUnitTest, "ipdlunittest", IPDLUnitTest)
+GECKO_PROCESS_TYPE(Default, "default", Parent, Self)
+GECKO_PROCESS_TYPE(Plugin, "plugin", Plugin, PluginContainer)
+GECKO_PROCESS_TYPE(Content, "tab", Content, Self)
+GECKO_PROCESS_TYPE(IPDLUnitTest, "ipdlunittest", IPDLUnitTest, PluginContainer)
 // Gecko Media Plugin process.
-GECKO_PROCESS_TYPE(GMPlugin, "gmplugin", GMPlugin)
+GECKO_PROCESS_TYPE(GMPlugin, "gmplugin", GMPlugin, PluginContainer)
 // GPU and compositor process.
-GECKO_PROCESS_TYPE(GPU, "gpu", GPU)
+GECKO_PROCESS_TYPE(GPU, "gpu", GPU, Self)
 // VR process.
-GECKO_PROCESS_TYPE(VR, "vr", VR)
+GECKO_PROCESS_TYPE(VR, "vr", VR, Self)
 // Remote Data Decoder process.
-GECKO_PROCESS_TYPE(RDD, "rdd", RDD)
+GECKO_PROCESS_TYPE(RDD, "rdd", RDD, Self)
 // Socket process
-GECKO_PROCESS_TYPE(Socket, "socket", Socket)
-GECKO_PROCESS_TYPE(RemoteSandboxBroker, "sandbox", RemoteSandboxBroker)
+GECKO_PROCESS_TYPE(Socket, "socket", Socket, Self)
+GECKO_PROCESS_TYPE(RemoteSandboxBroker, "sandbox", RemoteSandboxBroker, PluginContainer)
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -360,26 +360,27 @@ XRE_API(void, XRE_TermEmbedding, ())
  *
  * @param aINIFile The INI file to parse
  * @param aAppData The nsXREAppData structure to fill.
  */
 XRE_API(nsresult, XRE_ParseAppData,
         (nsIFile * aINIFile, mozilla::XREAppData& aAppData))
 
 enum GeckoProcessType {
-#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name) \
+#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name, bin_type) \
   GeckoProcessType_##enum_name,
 #include "mozilla/GeckoProcessTypes.h"
 #undef GECKO_PROCESS_TYPE
   GeckoProcessType_End,
   GeckoProcessType_Invalid = GeckoProcessType_End
 };
 
 static const char* const kGeckoProcessTypeString[] = {
-#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name) string_name,
+#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name, bin_type) \
+  string_name,
 #include "mozilla/GeckoProcessTypes.h"
 #undef GECKO_PROCESS_TYPE
 };
 
 static_assert(MOZ_ARRAY_LENGTH(kGeckoProcessTypeString) == GeckoProcessType_End,
               "Array length mismatch");
 
 XRE_API(const char*, XRE_ChildProcessTypeToString,
@@ -433,17 +434,17 @@ XRE_API(bool, XRE_IsE10sParentProcess, (
 
 /**
  * Defines XRE_IsParentProcess, XRE_IsContentProcess, etc.
  *
  * XRE_IsParentProcess is unique in that it returns true when called in
  * the e10s parent process or called in the main process when e10s is
  * disabled.
  */
-#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name) \
+#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name, bin_type) \
   XRE_API(bool, XRE_Is##xre_name##Process, ())
 #include "mozilla/GeckoProcessTypes.h"
 #undef GECKO_PROCESS_TYPE
 
 XRE_API(bool, XRE_IsSocketProcess, ())
 
 /**
  * Returns true if the appshell should run its own native event loop. Returns
@@ -489,16 +490,22 @@ XRE_API(void, XRE_TelemetryAccumulate, (
 
 XRE_API(void, XRE_StartupTimelineRecord, (int aEvent, mozilla::TimeStamp aWhen))
 
 XRE_API(void, XRE_InitOmnijar, (nsIFile * aGreOmni, nsIFile* aAppOmni))
 XRE_API(void, XRE_StopLateWriteChecks, (void))
 
 XRE_API(void, XRE_EnableSameExecutableForContentProc, ())
 
+namespace mozilla {
+enum class BinPathType { Self, PluginContainer };
+}
+XRE_API(mozilla::BinPathType, XRE_GetChildProcBinPathType,
+        (GeckoProcessType aProcessType));
+
 XRE_API(int, XRE_XPCShellMain,
         (int argc, char** argv, char** envp, const XREShellData* aShellData))
 
 #ifdef LIBFUZZER
 #  include "FuzzerRegistry.h"
 
 XRE_API(void, XRE_LibFuzzerSetDriver, (LibFuzzerDriver))