Bug 1457127 - Add an helper function for checking if the GPU process was used. r?janerik
MozReview-Commit-ID: 1xcrk1sCXHE
--- 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,