Bug 1598787 - Rename XRE_ChildProcessTypeToString to XRE_GeckoProcessTypeToString. r=froydnj draft
authorAndrew McCreight <continuation@gmail.com>
Fri, 22 Nov 2019 14:35:33 -0800
changeset 2496065 93519b2a071cc49d26c34fc51fa36b3cdd833fa8
parent 2496064 cd53a79a4c21e355a9d8c8fb984161e709c43583
child 2496066 23cc28364da191e3faad6fac0f878b508578f3f6
push id455279
push useramccreight@mozilla.com
push dateMon, 25 Nov 2019 19:56:04 +0000
treeherdertry@59b13b57567a [default view] [failures only]
reviewersfroydnj
bugs1598787
milestone72.0a1
Bug 1598787 - Rename XRE_ChildProcessTypeToString to XRE_GeckoProcessTypeToString. r=froydnj This function works on all GeckoProcessTypes, not just those for child processes. Differential Revision: https://phabricator.services.mozilla.com/D54375
dom/ipc/MMPrinter.cpp
gfx/ipc/GPUChild.cpp
gfx/vr/ipc/VRChild.cpp
ipc/glue/GeckoChildProcessHost.cpp
security/sandbox/win/src/remotesandboxbroker/RemoteSandboxBrokerParent.cpp
security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp
toolkit/components/telemetry/other/UntrustedModules.cpp
toolkit/components/terminator/nsTerminator.cpp
toolkit/xre/nsEmbedFunctions.cpp
tools/profiler/core/ProfiledThreadData.cpp
xpcom/base/nsDebugImpl.cpp
xpcom/base/nsTraceRefcnt.cpp
xpcom/build/nsXULAppAPI.h
--- a/dom/ipc/MMPrinter.cpp
+++ b/dom/ipc/MMPrinter.cpp
@@ -38,17 +38,17 @@ void MMPrinter::PrintImpl(char const* aL
   char* mmSkipLog = PR_GetEnv("MOZ_LOG_MESSAGEMANAGER_SKIP");
 
   if (mmSkipLog && strstr(mmSkipLog, charMsg.get())) {
     return;
   }
 
   MOZ_LOG(MMPrinter::sMMLog, LogLevel::Debug,
           ("%s Message: %s in process type: %s", aLocation, charMsg.get(),
-           XRE_ChildProcessTypeToString(XRE_GetProcessType())));
+           XRE_GeckoProcessTypeToString(XRE_GetProcessType())));
 
   if (!MOZ_LOG_TEST(sMMLog, LogLevel::Verbose)) {
     return;
   }
 
   ErrorResult rv;
 
   AutoJSAPI jsapi;
@@ -71,9 +71,9 @@ void MMPrinter::PrintImpl(char const* aL
   if (!srcString.init(cx, unevalObj)) return;
 
   MOZ_LOG(MMPrinter::sMMLog, LogLevel::Verbose,
           ("   %s", NS_ConvertUTF16toUTF8(srcString).get()));
   return;
 }
 
 }  // namespace dom
-}  // namespace mozilla
\ No newline at end of file
+}  // namespace mozilla
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -228,17 +228,17 @@ mozilla::ipc::IPCResult GPUChild::RecvFi
 }
 
 void GPUChild::ActorDestroy(ActorDestroyReason aWhy) {
   if (aWhy == AbnormalShutdown) {
     GenerateCrashReport(OtherPid());
 
     Telemetry::Accumulate(
         Telemetry::SUBPROCESS_ABNORMAL_ABORT,
-        nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_GPU)),
+        nsDependentCString(XRE_GeckoProcessTypeToString(GeckoProcessType_GPU)),
         1);
 
     // Notify the Telemetry environment so that we can refresh and do a
     // subsession split
     if (nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService()) {
       obsvc->NotifyObservers(nullptr, "compositor:process-aborted", nullptr);
     }
   }
--- a/gfx/vr/ipc/VRChild.cpp
+++ b/gfx/vr/ipc/VRChild.cpp
@@ -89,17 +89,17 @@ mozilla::ipc::IPCResult VRChild::RecvFin
 }
 
 void VRChild::ActorDestroy(ActorDestroyReason aWhy) {
   if (aWhy == AbnormalShutdown) {
     GenerateCrashReport(OtherPid());
 
     Telemetry::Accumulate(
         Telemetry::SUBPROCESS_ABNORMAL_ABORT,
-        nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_VR)),
+        nsDependentCString(XRE_GeckoProcessTypeToString(GeckoProcessType_VR)),
         1);
   }
   gfxVars::RemoveReceiver(this);
   mHost->OnChannelClosed();
 }
 
 void VRChild::Init() {
   nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -174,17 +174,17 @@ class BaseProcessLauncher {
 
   void MapChildLogging();
 
   static BinPathType GetPathToBinary(FilePath&, GeckoProcessType);
 
   void GetChildLogName(const char* origLogName, nsACString& buffer);
 
   const char* ChildProcessType() {
-    return XRE_ChildProcessTypeToString(mProcessType);
+    return XRE_GeckoProcessTypeToString(mProcessType);
   }
 
   nsCOMPtr<nsISerialEventTarget> mLaunchThread;
   GeckoProcessType mProcessType;
   UniquePtr<base::LaunchOptions> mLaunchOptions;
   std::vector<std::string> mExtraOpts;
 #ifdef XP_WIN
   nsString mGroupId;
@@ -675,20 +675,20 @@ bool GeckoChildProcessHost::AsyncLaunch(
             }
             p->Resolve(aResults.mHandle, __func__);
           },
           [this, p](const LaunchError aError) {
             // WaitUntilConnected might be waiting for us to signal.
             // If something failed let's set the error state and notify.
             CHROMIUM_LOG(ERROR)
                 << "Failed to launch "
-                << XRE_ChildProcessTypeToString(mProcessType) << " subprocess";
+                << XRE_GeckoProcessTypeToString(mProcessType) << " subprocess";
             Telemetry::Accumulate(
                 Telemetry::SUBPROCESS_LAUNCH_FAILURE,
-                nsDependentCString(XRE_ChildProcessTypeToString(mProcessType)));
+                nsDependentCString(XRE_GeckoProcessTypeToString(mProcessType)));
             {
               MonitorAutoLock lock(mMonitor);
               mProcessState = PROCESS_ERROR;
               lock.Notify();
             }
             p->Reject(aError, __func__);
           });
   return true;
--- a/security/sandbox/win/src/remotesandboxbroker/RemoteSandboxBrokerParent.cpp
+++ b/security/sandbox/win/src/remotesandboxbroker/RemoteSandboxBrokerParent.cpp
@@ -55,17 +55,17 @@ bool RemoteSandboxBrokerParent::Duplicat
   return ::DuplicateHandle(mProcess->GetChildProcessHandle(), aLauncherHandle,
                            ::GetCurrentProcess(), aOurHandle, 0, false,
                            DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
 }
 
 void RemoteSandboxBrokerParent::ActorDestroy(ActorDestroyReason aWhy) {
   if (AbnormalShutdown == aWhy) {
     Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
-                          nsDependentCString(XRE_ChildProcessTypeToString(
+                          nsDependentCString(XRE_GeckoProcessTypeToString(
                               GeckoProcessType_RemoteSandboxBroker)),
                           1);
     GenerateCrashReport(OtherPid());
   }
   Shutdown();
 }
 
 void RemoteSandboxBrokerParent::Shutdown() {
--- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
+++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
@@ -253,17 +253,17 @@ bool SandboxBroker::LaunchApp(const wcha
   PROCESS_INFORMATION targetInfo = {0};
   sandbox::ResultCode result;
   sandbox::ResultCode last_warning = sandbox::SBOX_ALL_OK;
   DWORD last_error = ERROR_SUCCESS;
   result = sBrokerService->SpawnTarget(aPath, aArguments, aEnvironment, mPolicy,
                                        &last_warning, &last_error, &targetInfo);
   if (sandbox::SBOX_ALL_OK != result) {
     nsAutoCString key;
-    key.AppendASCII(XRE_ChildProcessTypeToString(aProcessType));
+    key.AppendASCII(XRE_GeckoProcessTypeToString(aProcessType));
     key.AppendLiteral("/0x");
     key.AppendInt(static_cast<uint32_t>(last_error), 16);
 
     // Only accumulate for each combination once per session.
     if (sLaunchErrors) {
       if (!sLaunchErrors->Contains(key)) {
         Telemetry::Accumulate(Telemetry::SANDBOX_FAILED_LAUNCH_KEYED, key,
                               result);
--- a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp
+++ b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp
@@ -469,17 +469,17 @@ BackgroundHangThread::~BackgroundHangThr
 }
 
 void BackgroundHangThread::ReportHang(TimeDuration aHangTime) {
   // Recovered from a hang; called on the monitor thread
   // mManager->mLock IS locked
 
   HangDetails hangDetails(
       aHangTime,
-      nsDependentCString(XRE_ChildProcessTypeToString(XRE_GetProcessType())),
+      nsDependentCString(XRE_GeckoProcessTypeToString(XRE_GetProcessType())),
       VoidString(), mThreadName, mRunnableName, std::move(mHangStack),
       std::move(mAnnotations));
 
   // If the hang processing thread exists, we can process the native stack
   // on it. Otherwise, we are unable to report a native stack, so we just
   // report without one.
   if (mManager->mHangProcessingThread) {
     nsCOMPtr<nsIRunnable> processHangStackRunnable =
--- a/toolkit/components/telemetry/other/UntrustedModules.cpp
+++ b/toolkit/components/telemetry/other/UntrustedModules.cpp
@@ -297,17 +297,17 @@ static bool SerializeEvent(JSContext* aC
 
 static nsresult GetPerProcObject(JSContext* aCx, const IndexMap& aModuleIndices,
                                  const UntrustedModulesData& aData,
                                  JS::MutableHandleObject aObj) {
   nsDependentCString strProcType;
   if (aData.mProcessType == GeckoProcessType_Default) {
     strProcType.Rebind(NS_LITERAL_CSTRING("browser"), 0);
   } else {
-    strProcType.Rebind(XRE_ChildProcessTypeToString(aData.mProcessType));
+    strProcType.Rebind(XRE_GeckoProcessTypeToString(aData.mProcessType));
   }
 
   JS::RootedValue jsProcType(aCx);
   jsProcType.setString(Common::ToJSString(aCx, strProcType));
   if (!JS_DefineProperty(aCx, aObj, "processType", jsProcType,
                          JSPROP_ENUMERATE)) {
     return NS_ERROR_FAILURE;
   }
--- a/toolkit/components/terminator/nsTerminator.cpp
+++ b/toolkit/components/terminator/nsTerminator.cpp
@@ -174,17 +174,17 @@ void RunWatchdog(void* arg) {
 #else
     usleep(1000000 /* usec */);
 #endif
 
     if (gHeartbeat++ < timeToLive) {
       continue;
     }
 
-    NoteIntentionalCrash(XRE_ChildProcessTypeToString(XRE_GetProcessType()));
+    NoteIntentionalCrash(XRE_GeckoProcessTypeToString(XRE_GetProcessType()));
 
     // The shutdown steps are not completed yet. Let's report the last one.
     if (!sShutdownNotified) {
       const char* lastStep = nullptr;
       for (size_t i = 0; i < ArrayLength(sShutdownSteps); ++i) {
         if (sShutdownSteps[i].mTicks == -1) {
           break;
         }
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -219,34 +219,34 @@ void XRE_TermEmbedding() {
   NS_ASSERTION(gDirServiceProvider,
                "XRE_TermEmbedding without XRE_InitEmbedding");
 
   gDirServiceProvider->DoShutdown();
   NS_ShutdownXPCOM(nullptr);
   delete gDirServiceProvider;
 }
 
-const char* XRE_ChildProcessTypeToString(GeckoProcessType aProcessType) {
+const char* XRE_GeckoProcessTypeToString(GeckoProcessType aProcessType) {
   return (aProcessType < GeckoProcessType_End)
              ? kGeckoProcessTypeString[aProcessType]
              : "invalid";
 }
 
 const char* XRE_ChildProcessTypeToAnnotation(GeckoProcessType aProcessType) {
   switch (aProcessType) {
     case GeckoProcessType_GMPlugin:
       // The gecko media plugin and normal plugin processes are lumped together
       // as a historical artifact.
       return "plugin";
     case GeckoProcessType_Default:
       return "";
     case GeckoProcessType_Content:
       return "content";
     default:
-      return XRE_ChildProcessTypeToString(aProcessType);
+      return XRE_GeckoProcessTypeToString(aProcessType);
   }
 }
 
 namespace mozilla {
 namespace startup {
 GeckoProcessType sChildProcessType = GeckoProcessType_Default;
 }  // namespace startup
 }  // namespace mozilla
@@ -577,29 +577,29 @@ nsresult XRE_InitChildProcess(int aArgc,
       PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE")) {
 #  if defined(XP_LINUX) && defined(DEBUG)
     if (prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0) != 0) {
       printf_stderr("Could not allow ptrace from any process.\n");
     }
 #  endif
     printf_stderr(
         "\n\nCHILDCHILDCHILDCHILD (process type %s)\n  debug me @ %d\n\n",
-        XRE_ChildProcessTypeToString(XRE_GetProcessType()),
+        XRE_GeckoProcessTypeToString(XRE_GetProcessType()),
         base::GetCurrentProcId());
     sleep(GetDebugChildPauseTime());
   }
 #elif defined(OS_WIN)
   if (PR_GetEnv("MOZ_DEBUG_CHILD_PROCESS")) {
     NS_DebugBreak(NS_DEBUG_BREAK,
                   "Invoking NS_DebugBreak() to debug child process", nullptr,
                   __FILE__, __LINE__);
   } else if (PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE")) {
     printf_stderr(
         "\n\nCHILDCHILDCHILDCHILD (process type %s)\n  debug me @ %d\n\n",
-        XRE_ChildProcessTypeToString(XRE_GetProcessType()),
+        XRE_GeckoProcessTypeToString(XRE_GetProcessType()),
         base::GetCurrentProcId());
     ::Sleep(GetDebugChildPauseTime());
   }
 #endif
 
   // child processes launched by GeckoChildProcessHost get this magic
   // argument appended to their command lines
   const char* const parentPIDString = aArgv[aArgc - 1];
--- a/tools/profiler/core/ProfiledThreadData.cpp
+++ b/tools/profiler/core/ProfiledThreadData.cpp
@@ -202,17 +202,17 @@ void StreamSamplesAndMarkers(const char*
                              const ProfileBuffer& aBuffer,
                              SpliceableJSONWriter& aWriter,
                              const nsACString& aProcessName,
                              const mozilla::TimeStamp& aProcessStartTime,
                              const mozilla::TimeStamp& aRegisterTime,
                              const mozilla::TimeStamp& aUnregisterTime,
                              double aSinceTime, UniqueStacks& aUniqueStacks) {
   aWriter.StringProperty("processType",
-                         XRE_ChildProcessTypeToString(XRE_GetProcessType()));
+                         XRE_GeckoProcessTypeToString(XRE_GetProcessType()));
 
   aWriter.StringProperty("name", aName);
 
   // Use given process name (if any), unless we're the parent process.
   if (XRE_IsParentProcess()) {
     aWriter.StringProperty("processName", "Parent Process");
   } else if (!aProcessName.IsEmpty()) {
     aWriter.StringProperty("processName", aProcessName.Data());
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -433,17 +433,17 @@ NS_DebugBreak(uint32_t aSeverity, const 
     case NS_ASSERT_TRAP:
     case NS_ASSERT_UNINITIALIZED:  // Default to "trap" behavior
       Break(buf.buffer);
       return;
   }
 }
 
 static void Abort(const char* aMsg) {
-  NoteIntentionalCrash(XRE_ChildProcessTypeToString(XRE_GetProcessType()));
+  NoteIntentionalCrash(XRE_GeckoProcessTypeToString(XRE_GetProcessType()));
   mozalloc_abort(aMsg);
 }
 
 static void RealBreak() {
 #if defined(_WIN32)
   ::DebugBreak();
 #elif defined(XP_MACOSX)
   raise(SIGTRAP);
--- a/xpcom/base/nsTraceRefcnt.cpp
+++ b/xpcom/base/nsTraceRefcnt.cpp
@@ -244,17 +244,17 @@ class BloatEntry {
 
   void DumpTotal(FILE* aOut) {
     mClassSize /= mStats.mCreates;
     Dump(-1, aOut);
   }
 
   bool PrintDumpHeader(FILE* aOut, const char* aMsg) {
     fprintf(aOut, "\n== BloatView: %s, %s process %d\n", aMsg,
-            XRE_ChildProcessTypeToString(XRE_GetProcessType()), getpid());
+            XRE_GeckoProcessTypeToString(XRE_GetProcessType()), getpid());
     if (gLogLeaksOnly && !mStats.HaveLeaks()) {
       return false;
     }
 
     // clang-format off
     fprintf(aOut,
             "\n" \
             "     |<----------------Class--------------->|<-----Bytes------>|<----Objects---->|\n" \
@@ -502,17 +502,17 @@ static bool InitLog(const EnvCharType* a
       if (!XRE_IsParentProcess()) {
         bool hasLogExtension =
             fname.RFind(".log", true, -1, 4) == kNotFound ? false : true;
         if (hasLogExtension) {
           fname.Cut(fname.Length() - 4, 4);
         }
         fname.Append('_');
         const char* processType =
-            XRE_ChildProcessTypeToString(XRE_GetProcessType());
+            XRE_GeckoProcessTypeToString(XRE_GetProcessType());
         fname.AppendASCII(processType);
         fname.AppendLiteral("_pid");
         fname.AppendInt((uint32_t)getpid());
         if (hasLogExtension) {
           fname.AppendLiteral(".log");
         }
       }
 #ifdef XP_WIN
@@ -822,17 +822,17 @@ NS_LogTerm() { mozilla::LogTerm(); }
 // information about refcount logging entries.
 static void LogDMDFile() {
   const char* dmdFilePrefix = PR_GetEnv("MOZ_DMD_SHUTDOWN_LOG");
   if (!dmdFilePrefix) {
     return;
   }
 
   const char* logProcessEnv = PR_GetEnv("MOZ_DMD_LOG_PROCESS");
-  if (logProcessEnv && !!strcmp(logProcessEnv, XRE_ChildProcessTypeToString(
+  if (logProcessEnv && !!strcmp(logProcessEnv, XRE_GeckoProcessTypeToString(
                                                    XRE_GetProcessType()))) {
     return;
   }
 
   nsPrintfCString fileName("%sdmd-%d.log.gz", dmdFilePrefix,
                            base::GetCurrentProcId());
   FILE* logFile = fopen(fileName.get(), "w");
   if (NS_WARN_IF(!logFile)) {
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -375,17 +375,17 @@ static const char* const kGeckoProcessTy
   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,
+XRE_API(const char*, XRE_GeckoProcessTypeToString,
         (GeckoProcessType aProcessType))
 XRE_API(const char*, XRE_ChildProcessTypeToAnnotation,
         (GeckoProcessType aProcessType))
 
 #if defined(MOZ_WIDGET_ANDROID)
 struct XRE_AndroidChildFds {
   int mPrefsFd;
   int mPrefMapFd;