Bug 1465924 - Add a new optional property called "processName" to profile.meta which contains "Main Process" in the parent process and a content process name like "WebExtensions" for special content processes, see ContentChild::RecvRemoteType. r?gregtatum draft
authorMarkus Stange <mstange@themasta.com>
Thu, 31 May 2018 14:51:37 -0400
changeset 802466 8bbafeafc797cec2e8ed28fd56928e6a5734ac7c
parent 802465 e838e307078e4a62f97ca39761228b6056fb62b5
child 802476 06433633679a3a49626d175bec9bdafc983bb38e
push id111880
push userbmo:mstange@themasta.com
push dateThu, 31 May 2018 20:02:05 +0000
reviewersgregtatum
bugs1465924
milestone62.0a1
Bug 1465924 - Add a new optional property called "processName" to profile.meta which contains "Main Process" in the parent process and a content process name like "WebExtensions" for special content processes, see ContentChild::RecvRemoteType. r?gregtatum This field is in addition to the two existing process type fields we already have: - profile.meta.processType contains the integer value of the GeckoProcessType enum for the process. - profile.threads[i].processType contains the string for that GeckoProcessType. MozReview-Commit-ID: 3Pg6M1D6uDf
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -47,16 +47,17 @@
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Scheduler.h"
 #include "mozilla/StackWalk.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/ThreadLocal.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Tuple.h"
+#include "mozilla/dom/ContentChild.h"
 #include "mozilla/extensions/WebExtensionPolicy.h"
 #include "ThreadInfo.h"
 #include "nsIHttpProtocolHandler.h"
 #include "nsIObserverService.h"
 #include "nsIXULAppInfo.h"
 #include "nsIXULRuntime.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
@@ -1679,16 +1680,28 @@ StreamMetaJSCustomObject(PSLockRef aLock
 
   aWriter.IntProperty("gcpoison", JS::IsGCPoisoning() ? 1 : 0);
 
   bool asyncStacks = Preferences::GetBool("javascript.options.asyncstack");
   aWriter.IntProperty("asyncstack", asyncStacks);
 
   aWriter.IntProperty("processType", XRE_GetProcessType());
 
+  nsAutoCString processName;
+  if (XRE_IsParentProcess()) {
+    // We're the main process.
+    processName.AssignLiteral("Main Process");
+  } else if (dom::ContentChild* cc = dom::ContentChild::GetSingleton()) {
+    // Try to get the process name from ContentChild.
+    cc->GetProcessName(processName);
+  }
+  if (!processName.IsEmpty()) {
+    aWriter.StringProperty("processName", processName.Data());
+  }
+
   nsresult res;
   nsCOMPtr<nsIHttpProtocolHandler> http =
     do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &res);
 
   if (!NS_FAILED(res)) {
     nsAutoCString string;
 
     res = http->GetPlatform(string);