Add a new histogram "GPU.DrDcEnabled"

Whether DrDC (Direct Rendering Display Compositor) is enabled or not.
Recorded when CompositorGpuThread is created in GpuServiceImpl.

Bug: 407874799
Change-Id: I93d4794b40624d66f79d22d1ec34878ae1cb7a71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6725842
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
Reviewed-by: Jonathan Ross <jonross@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1490434}
diff --git a/components/viz/service/gl/gpu_service_impl.cc b/components/viz/service/gl/gpu_service_impl.cc
index 1704ea58..232650d 100644
--- a/components/viz/service/gl/gpu_service_impl.cc
+++ b/components/viz/service/gl/gpu_service_impl.cc
@@ -526,6 +526,11 @@
 
   // Create and Initialize compositor gpu thread.
   if (features::IsDrDcEnabled(gpu_feature_info_)) {
+    // Add a crash key for DrDC.
+    static auto* drdc_crash_key = base::debug::AllocateCrashKeyString(
+        "is-drdc-enabled", base::debug::CrashKeySize::Size32);
+    base::debug::SetCrashKeyString(drdc_crash_key, "1");
+
     CompositorGpuThread::CreateParams params;
     params.gpu_channel_manager = gpu_channel_manager_.get();
     params.display =
@@ -555,6 +560,8 @@
     compositor_gpu_thread_ = CompositorGpuThread::Create(params);
   }
 
+  UMA_HISTOGRAM_BOOLEAN("GPU.DrDcEnabled", !!compositor_gpu_thread_);
+
 #if BUILDFLAG(IS_WIN)
   // Add GpuServiceImpl to DirectCompositionOverlayCapsMonitor observer list for
   // overlay and DXGI info update. This should be added after |gpu_host_| is
@@ -1341,13 +1348,6 @@
   const bool display_context_on_another_thread =
       features::IsDrDcEnabled(gpu_feature_info_);
 
-  // Record the crash key for DrDC.
-  if (display_context_on_another_thread) {
-    static auto* drdc_crash_key = base::debug::AllocateCrashKeyString(
-        "is-drdc-enabled", base::debug::CrashKeySize::Size32);
-    base::debug::SetCrashKeyString(drdc_crash_key, "1");
-  }
-
   // |display_context_on_another_thread|, features::IsUsingRawDraw(),
   // kAlwaysUseRealBufferTestingOnOzone, and kSharedBitmapToSharedImage
   // requires |thread_safe_manager| to be true.
diff --git a/tools/metrics/histograms/metadata/gpu/histograms.xml b/tools/metrics/histograms/metadata/gpu/histograms.xml
index f2b679b..630d11c 100644
--- a/tools/metrics/histograms/metadata/gpu/histograms.xml
+++ b/tools/metrics/histograms/metadata/gpu/histograms.xml
@@ -757,6 +757,15 @@
   </summary>
 </histogram>
 
+<histogram name="Gpu.DrDcEnabled" enum="Boolean" expires_after="2026-07-10">
+  <owner>magchen@chromium.org</owner>
+  <owner>chrome-gpu-metric-alerts@chromium.org</owner>
+  <summary>
+    Whether DrDC (Direct Rendering Display Compositor) is enabled or not.
+    Recorded when CompositorGpuThread is created in GpuServiceImpl.
+  </summary>
+</histogram>
+
 <histogram name="GPU.DriverBugTestResultsPerEntry"
     enum="GpuDriverBugWorkaroundEntry" expires_after="never">
 <!-- expires-never: For monitoring new driver bugs. -->