Bug 1457127 - Add an helper function for checking if the GPU process was used. r?janerik draft
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Thu, 17 May 2018 08:56:16 +0200
changeset 797016 be265eaa3de0d16c45ceca65b33c74dd21032a2f
parent 797015 8cb736b6f03d368bb0d413e524b362eef72f1792
child 797017 47ebe680b83fbf8611ca528f55f453ad4e2a3d7f
child 797040 a632289a8063be3949f48348269d917e4a01b39f
push id110396
push userbmo:alessio.placitelli@gmail.com
push dateFri, 18 May 2018 15:30:15 +0000
reviewersjanerik
bugs1457127
milestone62.0a1
Bug 1457127 - Add an helper function for checking if the GPU process was used. r?janerik MozReview-Commit-ID: 1xcrk1sCXHE
toolkit/components/telemetry/TelemetryHistogram.cpp
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -418,16 +418,26 @@ internal_CanRecordBase() {
   return gCanRecordBase;
 }
 
 bool
 internal_CanRecordExtended() {
   return gCanRecordExtended;
 }
 
+bool
+internal_AttemptedGPUProcess() {
+  // Check if it was tried to launch a process.
+  bool attemptedGPUProcess = false;
+  if (auto gpm = mozilla::gfx::GPUProcessManager::Get()) {
+    attemptedGPUProcess = gpm->AttemptedGPUProcess();
+  }
+  return attemptedGPUProcess;
+}
+
 // Note: this is completely unrelated to mozilla::IsEmpty.
 bool
 internal_IsEmpty(const Histogram *h)
 {
   return h->is_empty();
 }
 
 bool
@@ -2363,20 +2373,17 @@ TelemetryHistogram::CreateHistogramSnaps
   JS::Rooted<JSObject*> root_obj(aCx, JS_NewPlainObject(aCx));
   if (!root_obj) {
     return NS_ERROR_FAILURE;
   }
   aResult.setObject(*root_obj);
 
   // Include the GPU process in histogram snapshots only if we actually tried
   // to launch a process for it.
-  bool includeGPUProcess = false;
-  if (auto gpm = mozilla::gfx::GPUProcessManager::Get()) {
-    includeGPUProcess = gpm->AttemptedGPUProcess();
-  }
+  bool includeGPUProcess = internal_AttemptedGPUProcess();
 
   HistogramProcessSnapshotsArray processHistArray;
   {
     StaticMutexAutoLock locker(gTelemetryHistogramMutex);
     nsresult rv = internal_GetHistogramsSnapshot(locker,
                                                  aDataset,
                                                  aClearSubsession,
                                                  includeGPUProcess,
@@ -2432,20 +2439,17 @@ TelemetryHistogram::GetKeyedHistogramSna
   JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
   if (!obj) {
     return NS_ERROR_FAILURE;
   }
   aResult.setObject(*obj);
 
   // Include the GPU process in histogram snapshots only if we actually tried
   // to launch a process for it.
-  bool includeGPUProcess = false;
-  if (auto gpm = mozilla::gfx::GPUProcessManager::Get()) {
-    includeGPUProcess = gpm->AttemptedGPUProcess();
-  }
+  bool includeGPUProcess = internal_AttemptedGPUProcess();
 
   // Get a snapshot of all the data while holding the mutex.
   KeyedHistogramProcessSnapshotsArray processHistArray;
   {
     StaticMutexAutoLock locker(gTelemetryHistogramMutex);
     nsresult rv = internal_GetKeyedHistogramsSnapshot(locker,
                                                       aDataset,
                                                       aClearSubsession,