Bug 1514044 - part 3 - update nsICrashService process constants and add checks for them; r=gsvelto
authorNathan Froyd <froydnj@mozilla.com>
Thu, 10 Jan 2019 10:52:51 -0500
changeset 510373 de7c04ff60015787b787416797252148902e4bfb
parent 510372 65f14286370124a5dd07b810c1bb967cf3b181f1
child 510374 7ad3eee7e6f0d37bdc9d08285de86e29d907c84e
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs1514044
milestone66.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 1514044 - part 3 - update nsICrashService process constants and add checks for them; r=gsvelto
ipc/glue/CrashReporterHost.cpp
toolkit/components/crashes/CrashService.js
toolkit/components/crashes/nsICrashService.idl
--- a/ipc/glue/CrashReporterHost.cpp
+++ b/ipc/glue/CrashReporterHost.cpp
@@ -8,16 +8,44 @@
 #include "CrashReporterMetadataShmem.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/recordreplay/ParentIPC.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/Telemetry.h"
 #include "nsIAsyncShutdown.h"
 #include "nsICrashService.h"
+#include "nsXULAppAPI.h"
+
+// Consistency checking for nsICrashService constants.  We depend on the
+// equivalence between nsICrashService values and GeckoProcessType values
+// in the code below.  Making them equal also ensures that if new process
+// types are added, people will know they may need to add crash reporting
+// support in various places because compilation errors will be triggered here.
+static_assert(nsICrashService::PROCESS_TYPE_MAIN == (int)GeckoProcessType_Default,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+static_assert(nsICrashService::PROCESS_TYPE_PLUGIN == (int)GeckoProcessType_Plugin,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+static_assert(nsICrashService::PROCESS_TYPE_CONTENT == (int)GeckoProcessType_Content,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+static_assert(nsICrashService::PROCESS_TYPE_IPDLUNITTEST == (int)GeckoProcessType_IPDLUnitTest,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+static_assert(nsICrashService::PROCESS_TYPE_GMPLUGIN == (int)GeckoProcessType_GMPlugin,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+static_assert(nsICrashService::PROCESS_TYPE_GPU == (int)GeckoProcessType_GPU,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+static_assert(nsICrashService::PROCESS_TYPE_VR == (int)GeckoProcessType_VR,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+static_assert(nsICrashService::PROCESS_TYPE_RDD == (int)GeckoProcessType_RDD,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+// Add new static asserts here if you add more process types.
+// Update this static assert as well.
+static_assert(nsICrashService::PROCESS_TYPE_RDD + 1 == (int)GeckoProcessType_End,
+              "GeckoProcessType enum is out of sync with nsICrashService!");
+
 
 namespace mozilla {
 namespace ipc {
 
 CrashReporterHost::CrashReporterHost(GeckoProcessType aProcessType,
                                      const Shmem& aShmem,
                                      CrashReporter::ThreadId aThreadId)
     : mProcessType(aProcessType),
@@ -138,34 +166,23 @@ bool CrashReporterHost::FinalizeCrashRep
   if (!crashService) {
     return;
   }
 
   int32_t processType;
   nsCString telemetryKey;
 
   switch (aProcessType) {
-    case GeckoProcessType_Content:
-      processType = nsICrashService::PROCESS_TYPE_CONTENT;
-      break;
-    case GeckoProcessType_Plugin:
-      processType = nsICrashService::PROCESS_TYPE_PLUGIN;
-      break;
-    case GeckoProcessType_GMPlugin:
-      processType = nsICrashService::PROCESS_TYPE_GMPLUGIN;
-      break;
-    case GeckoProcessType_GPU:
-      processType = nsICrashService::PROCESS_TYPE_GPU;
-      break;
-    case GeckoProcessType_RDD:
-      processType = nsICrashService::PROCESS_TYPE_RDD;
-      break;
-    default:
+    case GeckoProcessType_IPDLUnitTest:
+    case GeckoProcessType_Default:
       NS_ERROR("unknown process type");
       return;
+    default:
+      processType = (int)aProcessType;
+      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) \
--- a/toolkit/components/crashes/CrashService.js
+++ b/toolkit/components/crashes/CrashService.js
@@ -177,16 +177,19 @@ CrashService.prototype = Object.freeze({
       processType = Services.crashmanager.PROCESS_TYPE_GMPLUGIN;
       break;
     case Ci.nsICrashService.PROCESS_TYPE_GPU:
       processType = Services.crashmanager.PROCESS_TYPE_GPU;
       break;
     case Ci.nsICrashService.PROCESS_TYPE_RDD:
       processType = Services.crashmanager.PROCESS_TYPE_RDD;
       break;
+    case Ci.nsICrashService.PROCESS_TYPE_IPDLUNITTEST:
+      // We'll never send crash reports for this type of process.
+      return;
     default:
       throw new Error("Unrecognized PROCESS_TYPE: " + processType);
     }
 
     let allThreads = false;
 
     switch (crashType) {
     case Ci.nsICrashService.CRASH_TYPE_CRASH:
--- a/toolkit/components/crashes/nsICrashService.idl
+++ b/toolkit/components/crashes/nsICrashService.idl
@@ -17,17 +17,20 @@ interface nsICrashService : nsISupports
    * @param id
    *        Crash ID. Likely a UUID.
    *
    * @return A promise that resolves after the crash has been stored
    */
   Promise addCrash(in long processType, in long crashType, in AString id);
 
   const long PROCESS_TYPE_MAIN = 0;
-  const long PROCESS_TYPE_CONTENT = 1;
-  const long PROCESS_TYPE_PLUGIN = 2;
-  const long PROCESS_TYPE_GMPLUGIN = 3;
-  const long PROCESS_TYPE_GPU = 4;
-  const long PROCESS_TYPE_RDD = 5;
+  const long PROCESS_TYPE_PLUGIN = 1;
+  const long PROCESS_TYPE_CONTENT = 2;
+  const long PROCESS_TYPE_IPDLUNITTEST = 3;
+  const long PROCESS_TYPE_GMPLUGIN = 4;
+  const long PROCESS_TYPE_GPU = 5;
+  const long PROCESS_TYPE_VR = 6;
+  const long PROCESS_TYPE_RDD = 7;
+  // New process types should be added at the end of the above list.
 
   const long CRASH_TYPE_CRASH = 0;
   const long CRASH_TYPE_HANG = 1;
 };