• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "components/metrics/content/gpu_metrics_provider.h"
6 
7 #include "base/metrics/histogram_macros.h"
8 #include "build/build_config.h"
9 #include "content/public/browser/gpu_data_manager.h"
10 #include "gpu/config/gpu_info.h"
11 #include "third_party/metrics_proto/system_profile.pb.h"
12 
13 namespace metrics {
14 
15 GPUMetricsProvider::GPUMetricsProvider() = default;
16 
17 GPUMetricsProvider::~GPUMetricsProvider() = default;
18 
ProvideSystemProfileMetrics(SystemProfileProto * system_profile_proto)19 void GPUMetricsProvider::ProvideSystemProfileMetrics(
20     SystemProfileProto* system_profile_proto) {
21   SystemProfileProto::Hardware* hardware =
22       system_profile_proto->mutable_hardware();
23 
24   const gpu::GPUInfo& gpu_info =
25       content::GpuDataManager::GetInstance()->GetGPUInfo();
26   const gpu::GPUInfo::GPUDevice& active_gpu = gpu_info.active_gpu();
27   SystemProfileProto::Hardware::Graphics* gpu = hardware->mutable_gpu();
28   gpu->set_vendor_id(active_gpu.vendor_id);
29   gpu->set_device_id(active_gpu.device_id);
30   gpu->set_driver_version(active_gpu.driver_version);
31   gpu->set_gl_vendor(gpu_info.gl_vendor);
32   gpu->set_gl_renderer(gpu_info.gl_renderer);
33 }
34 
ProvideCurrentSessionData(ChromeUserMetricsExtension * uma_proto)35 void GPUMetricsProvider::ProvideCurrentSessionData(
36     ChromeUserMetricsExtension* uma_proto) {
37 #if BUILDFLAG(IS_ANDROID)
38   const gpu::GPUInfo& gpu_info =
39       content::GpuDataManager::GetInstance()->GetGPUInfo();
40 
41   // It's intentional that GPU.HardwareSupportsVulkan isn't logged for the
42   // previous session. The value is unlikely to change between sessions but
43   // previous session data is recorded before GPU service is launched and
44   // current session value is known.
45   if (gpu_info.IsInitialized()) {
46     UMA_HISTOGRAM_BOOLEAN("GPU.HardwareSupportsVulkan",
47                           gpu_info.hardware_supports_vulkan);
48   }
49 #endif
50 }
51 
52 }  // namespace metrics
53