summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorgunsch <gunsch@chromium.org>2014-09-15 17:03:32 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-16 00:05:44 +0000
commit1afc65175c84ddf6087f65da818bbdbba6d28101 (patch)
tree1c4edefc4ee98a2ca85815bd545ba5fd9684aba0 /chrome
parent0b527c1ef9f0794742e8ea004fbaf7ecea2f4cef (diff)
downloadchromium_src-1afc65175c84ddf6087f65da818bbdbba6d28101.zip
chromium_src-1afc65175c84ddf6087f65da818bbdbba6d28101.tar.gz
chromium_src-1afc65175c84ddf6087f65da818bbdbba6d28101.tar.bz2
Moves GPUMetricsProvider to //components/metrics.
R=asvitkine@chromium.org,isherman@chromium.org BUG=404791 Review URL: https://codereview.chromium.org/523273003 Cr-Commit-Position: refs/heads/master@{#294935}
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/BUILD.gn1
-rw-r--r--chrome/browser/metrics/chrome_metrics_service_client.cc4
-rw-r--r--chrome/browser/metrics/gpu_metrics_provider.cc108
-rw-r--r--chrome/browser/metrics/gpu_metrics_provider.h38
-rw-r--r--chrome/browser/metrics/gpu_metrics_provider_unittest.cc64
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/chrome_tests_unit.gypi1
7 files changed, 4 insertions, 215 deletions
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index a10558b..d5f7f46 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -59,6 +59,7 @@ static_library("browser") {
"//components/history/core/common",
"//components/infobars/core",
"//components/invalidation",
+ "//components/metrics:gpu",
"//components/metrics:net",
"//components/metrics/proto:proto",
"//components/navigation_metrics",
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc
index b08564f..920363d 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/metrics/chrome_stability_metrics_provider.h"
-#include "chrome/browser/metrics/gpu_metrics_provider.h"
#include "chrome/browser/metrics/omnibox_metrics_provider.h"
#include "chrome/browser/metrics/profiler_metrics_provider.h"
#include "chrome/browser/metrics/tracking_synchronizer.h"
@@ -33,6 +32,7 @@
#include "chrome/common/crash_keys.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
+#include "components/metrics/gpu/gpu_metrics_provider.h"
#include "components/metrics/metrics_service.h"
#include "components/metrics/net/net_metrics_log_uploader.h"
#include "components/metrics/net/network_metrics_provider.h"
@@ -307,7 +307,7 @@ void ChromeMetricsServiceClient::Initialize() {
metrics_service_->RegisterMetricsProvider(
scoped_ptr<metrics::MetricsProvider>(new ChromeStabilityMetricsProvider));
metrics_service_->RegisterMetricsProvider(
- scoped_ptr<metrics::MetricsProvider>(new GPUMetricsProvider()));
+ scoped_ptr<metrics::MetricsProvider>(new metrics::GPUMetricsProvider()));
profiler_metrics_provider_ = new ProfilerMetricsProvider;
metrics_service_->RegisterMetricsProvider(
scoped_ptr<metrics::MetricsProvider>(profiler_metrics_provider_));
diff --git a/chrome/browser/metrics/gpu_metrics_provider.cc b/chrome/browser/metrics/gpu_metrics_provider.cc
deleted file mode 100644
index 34b8a39..0000000
--- a/chrome/browser/metrics/gpu_metrics_provider.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/metrics/gpu_metrics_provider.h"
-
-#include "components/metrics/proto/system_profile.pb.h"
-#include "content/public/browser/gpu_data_manager.h"
-#include "gpu/config/gpu_info.h"
-#include "ui/gfx/screen.h"
-
-#if defined(OS_WIN)
-
-#include <windows.h>
-
-namespace {
-
-struct ScreenDPIInformation {
- double max_dpi_x;
- double max_dpi_y;
-};
-
-// Called once for each connected monitor.
-BOOL CALLBACK GetMonitorDPICallback(HMONITOR, HDC hdc, LPRECT, LPARAM dwData) {
- const double kMillimetersPerInch = 25.4;
- ScreenDPIInformation* screen_info =
- reinterpret_cast<ScreenDPIInformation*>(dwData);
- // Size of screen, in mm.
- DWORD size_x = GetDeviceCaps(hdc, HORZSIZE);
- DWORD size_y = GetDeviceCaps(hdc, VERTSIZE);
- double dpi_x = (size_x > 0) ?
- GetDeviceCaps(hdc, HORZRES) / (size_x / kMillimetersPerInch) : 0;
- double dpi_y = (size_y > 0) ?
- GetDeviceCaps(hdc, VERTRES) / (size_y / kMillimetersPerInch) : 0;
- screen_info->max_dpi_x = std::max(dpi_x, screen_info->max_dpi_x);
- screen_info->max_dpi_y = std::max(dpi_y, screen_info->max_dpi_y);
- return TRUE;
-}
-
-void WriteScreenDPIInformationProto(
- metrics::SystemProfileProto::Hardware* hardware) {
- HDC desktop_dc = GetDC(NULL);
- if (desktop_dc) {
- ScreenDPIInformation si = {0, 0};
- if (EnumDisplayMonitors(desktop_dc, NULL, GetMonitorDPICallback,
- reinterpret_cast<LPARAM>(&si))) {
- hardware->set_max_dpi_x(si.max_dpi_x);
- hardware->set_max_dpi_y(si.max_dpi_y);
- }
- ReleaseDC(GetDesktopWindow(), desktop_dc);
- }
-}
-
-} // namespace
-
-#endif // defined(OS_WIN)
-
-GPUMetricsProvider::GPUMetricsProvider() {
-}
-
-GPUMetricsProvider::~GPUMetricsProvider() {
-}
-
-void GPUMetricsProvider::ProvideSystemProfileMetrics(
- metrics::SystemProfileProto* system_profile_proto) {
- metrics::SystemProfileProto::Hardware* hardware =
- system_profile_proto->mutable_hardware();
-
- const gpu::GPUInfo& gpu_info =
- content::GpuDataManager::GetInstance()->GetGPUInfo();
- metrics::SystemProfileProto::Hardware::Graphics* gpu =
- hardware->mutable_gpu();
- gpu->set_vendor_id(gpu_info.gpu.vendor_id);
- gpu->set_device_id(gpu_info.gpu.device_id);
- gpu->set_driver_version(gpu_info.driver_version);
- gpu->set_driver_date(gpu_info.driver_date);
- metrics::SystemProfileProto::Hardware::Graphics::PerformanceStatistics*
- gpu_performance = gpu->mutable_performance_statistics();
- gpu_performance->set_graphics_score(gpu_info.performance_stats.graphics);
- gpu_performance->set_gaming_score(gpu_info.performance_stats.gaming);
- gpu_performance->set_overall_score(gpu_info.performance_stats.overall);
- gpu->set_gl_vendor(gpu_info.gl_vendor);
- gpu->set_gl_renderer(gpu_info.gl_renderer);
-
- const gfx::Size display_size = GetScreenSize();
- hardware->set_primary_screen_width(display_size.width());
- hardware->set_primary_screen_height(display_size.height());
- hardware->set_primary_screen_scale_factor(GetScreenDeviceScaleFactor());
- hardware->set_screen_count(GetScreenCount());
-
-#if defined(OS_WIN)
- WriteScreenDPIInformationProto(hardware);
-#endif
-}
-
-gfx::Size GPUMetricsProvider::GetScreenSize() const {
- return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel();
-}
-
-float GPUMetricsProvider::GetScreenDeviceScaleFactor() const {
- return gfx::Screen::GetNativeScreen()->
- GetPrimaryDisplay().device_scale_factor();
-}
-
-int GPUMetricsProvider::GetScreenCount() const {
- // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312
- return gfx::Screen::GetNativeScreen()->GetNumDisplays();
-}
diff --git a/chrome/browser/metrics/gpu_metrics_provider.h b/chrome/browser/metrics/gpu_metrics_provider.h
deleted file mode 100644
index 2c3a3f0..0000000
--- a/chrome/browser/metrics/gpu_metrics_provider.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_METRICS_GPU_METRICS_PROVIDER_H_
-#define CHROME_BROWSER_METRICS_GPU_METRICS_PROVIDER_H_
-
-#include "base/basictypes.h"
-#include "components/metrics/metrics_provider.h"
-#include "ui/gfx/size.h"
-
-// GPUMetricsProvider provides GPU-related metrics.
-class GPUMetricsProvider : public metrics::MetricsProvider {
- public:
- GPUMetricsProvider();
- virtual ~GPUMetricsProvider();
-
- // metrics::MetricsProvider:
- virtual void ProvideSystemProfileMetrics(
- metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
-
- protected:
- // Exposed for the sake of mocking in test code.
-
- // Returns the screen size for the primary monitor.
- virtual gfx::Size GetScreenSize() const;
-
- // Returns the device scale factor for the primary monitor.
- virtual float GetScreenDeviceScaleFactor() const;
-
- // Returns the number of monitors the user is using.
- virtual int GetScreenCount() const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GPUMetricsProvider);
-};
-
-#endif // CHROME_BROWSER_METRICS_GPU_METRICS_PROVIDER_H_
diff --git a/chrome/browser/metrics/gpu_metrics_provider_unittest.cc b/chrome/browser/metrics/gpu_metrics_provider_unittest.cc
deleted file mode 100644
index 6c753ba..0000000
--- a/chrome/browser/metrics/gpu_metrics_provider_unittest.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/metrics/gpu_metrics_provider.h"
-
-#include "base/basictypes.h"
-#include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/size.h"
-
-namespace {
-
-const int kScreenWidth = 1024;
-const int kScreenHeight = 768;
-const int kScreenCount = 3;
-const float kScreenScaleFactor = 2;
-
-class TestGPUMetricsProvider : public GPUMetricsProvider {
- public:
- TestGPUMetricsProvider() {}
- virtual ~TestGPUMetricsProvider() {}
-
- private:
- virtual gfx::Size GetScreenSize() const OVERRIDE {
- return gfx::Size(kScreenWidth, kScreenHeight);
- }
-
- virtual float GetScreenDeviceScaleFactor() const OVERRIDE {
- return kScreenScaleFactor;
- }
-
- virtual int GetScreenCount() const OVERRIDE {
- return kScreenCount;
- }
-
- DISALLOW_COPY_AND_ASSIGN(TestGPUMetricsProvider);
-};
-
-} // namespace
-
-class GPUMetricsProviderTest : public testing::Test {
- public:
- GPUMetricsProviderTest() {}
- virtual ~GPUMetricsProviderTest() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GPUMetricsProviderTest);
-};
-
-TEST_F(GPUMetricsProviderTest, ProvideSystemProfileMetrics) {
- TestGPUMetricsProvider provider;
- metrics::ChromeUserMetricsExtension uma_proto;
-
- provider.ProvideSystemProfileMetrics(uma_proto.mutable_system_profile());
-
- // Check that the system profile has the correct values set.
- const metrics::SystemProfileProto::Hardware& hardware =
- uma_proto.system_profile().hardware();
- EXPECT_EQ(kScreenWidth, hardware.primary_screen_width());
- EXPECT_EQ(kScreenHeight, hardware.primary_screen_height());
- EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor());
- EXPECT_EQ(kScreenCount, hardware.screen_count());
-}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 92d0dc6..3f2e426 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -678,8 +678,6 @@
'browser/metrics/field_trial_synchronizer.h',
'browser/metrics/google_update_metrics_provider_win.cc',
'browser/metrics/google_update_metrics_provider_win.h',
- 'browser/metrics/gpu_metrics_provider.cc',
- 'browser/metrics/gpu_metrics_provider.h',
'browser/metrics/metric_event_duration_details.h',
'browser/metrics/metrics_reporting_state.cc',
'browser/metrics/metrics_reporting_state.h',
@@ -2796,6 +2794,7 @@
'../components/components.gyp:infobars_core',
'../components/components.gyp:invalidation',
'../components/components.gyp:metrics',
+ '../components/components.gyp:metrics_gpu',
'../components/components.gyp:metrics_net',
'../components/components.gyp:navigation_metrics',
'../components/components.gyp:network_time',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 9922379..c2da63f 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -529,7 +529,6 @@
'browser/metrics/chrome_metrics_service_accessor_unittest.cc',
'browser/metrics/cloned_install_detector_unittest.cc',
'browser/metrics/extensions_metrics_provider_unittest.cc',
- 'browser/metrics/gpu_metrics_provider_unittest.cc',
'browser/metrics/plugin_metrics_provider_unittest.cc',
'browser/metrics/profiler_metrics_provider_unittest.cc',
'browser/metrics/signin_status_metrics_provider_unittest.cc',