Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: chrome/browser/metrics/metrics_log.cc

Issue 291163006: Create GPUMetricsProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/metrics/metrics_log.h" 5 #include "chrome/browser/metrics/metrics_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/metrics/extension_metrics.h" 28 #include "chrome/browser/metrics/extension_metrics.h"
29 #include "chrome/browser/plugins/plugin_prefs.h" 29 #include "chrome/browser/plugins/plugin_prefs.h"
30 #include "chrome/browser/profiles/profile_manager.h" 30 #include "chrome/browser/profiles/profile_manager.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "components/metrics/metrics_provider.h" 32 #include "components/metrics/metrics_provider.h"
33 #include "components/metrics/metrics_service_client.h" 33 #include "components/metrics/metrics_service_client.h"
34 #include "components/metrics/proto/profiler_event.pb.h" 34 #include "components/metrics/proto/profiler_event.pb.h"
35 #include "components/metrics/proto/system_profile.pb.h" 35 #include "components/metrics/proto/system_profile.pb.h"
36 #include "components/nacl/common/nacl_process_type.h" 36 #include "components/nacl/common/nacl_process_type.h"
37 #include "components/variations/active_field_trials.h" 37 #include "components/variations/active_field_trials.h"
38 #include "content/public/browser/gpu_data_manager.h"
39 #include "content/public/common/content_client.h" 38 #include "content/public/common/content_client.h"
40 #include "content/public/common/webplugininfo.h" 39 #include "content/public/common/webplugininfo.h"
41 #include "gpu/config/gpu_info.h"
42 #include "ui/gfx/screen.h"
43 #include "url/gurl.h" 40 #include "url/gurl.h"
44 41
45 #if defined(OS_ANDROID) 42 #if defined(OS_ANDROID)
46 #include "base/android/build_info.h" 43 #include "base/android/build_info.h"
47 #endif 44 #endif
48 45
49 #if defined(OS_WIN) 46 #if defined(OS_WIN)
50 #include "base/win/metro.h" 47 #include "base/win/metro.h"
51 48
52 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 49 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
53 extern "C" IMAGE_DOS_HEADER __ImageBase; 50 extern "C" IMAGE_DOS_HEADER __ImageBase;
54 #endif 51 #endif
55 52
56 #if defined(OS_CHROMEOS) 53 #if defined(OS_CHROMEOS)
57 #include "chrome/browser/metrics/metrics_log_chromeos.h" 54 #include "chrome/browser/metrics/metrics_log_chromeos.h"
58 #endif // OS_CHROMEOS 55 #endif // OS_CHROMEOS
59 56
60 using content::GpuDataManager;
61 using metrics::MetricsLogBase; 57 using metrics::MetricsLogBase;
62 using metrics::ProfilerEventProto; 58 using metrics::ProfilerEventProto;
63 using metrics::SystemProfileProto; 59 using metrics::SystemProfileProto;
64 using tracked_objects::ProcessDataSnapshot; 60 using tracked_objects::ProcessDataSnapshot;
65 typedef variations::ActiveGroupId ActiveGroupId; 61 typedef variations::ActiveGroupId ActiveGroupId;
66 62
67 namespace { 63 namespace {
68 64
69 // Returns the date at which the current metrics client ID was created as 65 // Returns the date at which the current metrics client ID was created as
70 // a string containing seconds since the epoch, or "0" if none was found. 66 // a string containing seconds since the epoch, or "0" if none was found.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 tracked_object->set_exec_count(death_data.count); 202 tracked_object->set_exec_count(death_data.count);
207 tracked_object->set_exec_time_total(death_data.run_duration_sum); 203 tracked_object->set_exec_time_total(death_data.run_duration_sum);
208 tracked_object->set_exec_time_sampled(death_data.run_duration_sample); 204 tracked_object->set_exec_time_sampled(death_data.run_duration_sample);
209 tracked_object->set_queue_time_total(death_data.queue_duration_sum); 205 tracked_object->set_queue_time_total(death_data.queue_duration_sum);
210 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample); 206 tracked_object->set_queue_time_sampled(death_data.queue_duration_sample);
211 tracked_object->set_process_type(AsProtobufProcessType(process_type)); 207 tracked_object->set_process_type(AsProtobufProcessType(process_type));
212 tracked_object->set_process_id(profiler_data.process_id); 208 tracked_object->set_process_id(profiler_data.process_id);
213 } 209 }
214 } 210 }
215 211
216 #if defined(OS_WIN)
217 struct ScreenDPIInformation {
218 double max_dpi_x;
219 double max_dpi_y;
220 };
221
222 // Called once for each connected monitor.
223 BOOL CALLBACK GetMonitorDPICallback(HMONITOR, HDC hdc, LPRECT, LPARAM dwData) {
224 const double kMillimetersPerInch = 25.4;
225 ScreenDPIInformation* screen_info =
226 reinterpret_cast<ScreenDPIInformation*>(dwData);
227 // Size of screen, in mm.
228 DWORD size_x = GetDeviceCaps(hdc, HORZSIZE);
229 DWORD size_y = GetDeviceCaps(hdc, VERTSIZE);
230 double dpi_x = (size_x > 0) ?
231 GetDeviceCaps(hdc, HORZRES) / (size_x / kMillimetersPerInch) : 0;
232 double dpi_y = (size_y > 0) ?
233 GetDeviceCaps(hdc, VERTRES) / (size_y / kMillimetersPerInch) : 0;
234 screen_info->max_dpi_x = std::max(dpi_x, screen_info->max_dpi_x);
235 screen_info->max_dpi_y = std::max(dpi_y, screen_info->max_dpi_y);
236 return TRUE;
237 }
238
239 void WriteScreenDPIInformationProto(SystemProfileProto::Hardware* hardware) {
240 HDC desktop_dc = GetDC(NULL);
241 if (desktop_dc) {
242 ScreenDPIInformation si = {0, 0};
243 if (EnumDisplayMonitors(desktop_dc, NULL, GetMonitorDPICallback,
244 reinterpret_cast<LPARAM>(&si))) {
245 hardware->set_max_dpi_x(si.max_dpi_x);
246 hardware->set_max_dpi_y(si.max_dpi_y);
247 }
248 ReleaseDC(GetDesktopWindow(), desktop_dc);
249 }
250 }
251
252 #endif // defined(OS_WIN)
253
254 // Round a timestamp measured in seconds since epoch to one with a granularity 212 // Round a timestamp measured in seconds since epoch to one with a granularity
255 // of an hour. This can be used before uploaded potentially sensitive 213 // of an hour. This can be used before uploaded potentially sensitive
256 // timestamps. 214 // timestamps.
257 int64 RoundSecondsToHour(int64 time_in_seconds) { 215 int64 RoundSecondsToHour(int64 time_in_seconds) {
258 return 3600 * (time_in_seconds / 3600); 216 return 3600 * (time_in_seconds / 3600);
259 } 217 }
260 218
261 } // namespace 219 } // namespace
262 220
263 MetricsLog::MetricsLog(const std::string& client_id, 221 MetricsLog::MetricsLog(const std::string& client_id,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 void MetricsLog::RecordGeneralMetrics( 306 void MetricsLog::RecordGeneralMetrics(
349 const std::vector<metrics::MetricsProvider*>& metrics_providers) { 307 const std::vector<metrics::MetricsProvider*>& metrics_providers) {
350 for (size_t i = 0; i < metrics_providers.size(); ++i) 308 for (size_t i = 0; i < metrics_providers.size(); ++i)
351 metrics_providers[i]->ProvideGeneralMetrics(uma_proto()); 309 metrics_providers[i]->ProvideGeneralMetrics(uma_proto());
352 } 310 }
353 311
354 PrefService* MetricsLog::GetPrefService() { 312 PrefService* MetricsLog::GetPrefService() {
355 return g_browser_process->local_state(); 313 return g_browser_process->local_state();
356 } 314 }
357 315
358 gfx::Size MetricsLog::GetScreenSize() const {
359 return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel();
360 }
361
362 float MetricsLog::GetScreenDeviceScaleFactor() const {
363 return gfx::Screen::GetNativeScreen()->
364 GetPrimaryDisplay().device_scale_factor();
365 }
366
367 int MetricsLog::GetScreenCount() const {
368 // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312
369 return gfx::Screen::GetNativeScreen()->GetNumDisplays();
370 }
371
372 void MetricsLog::GetFieldTrialIds( 316 void MetricsLog::GetFieldTrialIds(
373 std::vector<ActiveGroupId>* field_trial_ids) const { 317 std::vector<ActiveGroupId>* field_trial_ids) const {
374 variations::GetFieldTrialActiveGroupIds(field_trial_ids); 318 variations::GetFieldTrialActiveGroupIds(field_trial_ids);
375 } 319 }
376 320
377 bool MetricsLog::HasEnvironment() const { 321 bool MetricsLog::HasEnvironment() const {
378 return uma_proto()->system_profile().has_uma_enabled_date(); 322 return uma_proto()->system_profile().has_uma_enabled_date();
379 } 323 }
380 324
381 bool MetricsLog::HasStabilityMetrics() const { 325 bool MetricsLog::HasStabilityMetrics() const {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 #if defined(OS_ANDROID) 507 #if defined(OS_ANDROID)
564 os->set_fingerprint( 508 os->set_fingerprint(
565 base::android::BuildInfo::GetInstance()->android_build_fp()); 509 base::android::BuildInfo::GetInstance()->android_build_fp());
566 #endif 510 #endif
567 511
568 base::CPU cpu_info; 512 base::CPU cpu_info;
569 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu(); 513 SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu();
570 cpu->set_vendor_name(cpu_info.vendor_name()); 514 cpu->set_vendor_name(cpu_info.vendor_name());
571 cpu->set_signature(cpu_info.signature()); 515 cpu->set_signature(cpu_info.signature());
572 516
573 const gpu::GPUInfo& gpu_info =
574 GpuDataManager::GetInstance()->GetGPUInfo();
575 SystemProfileProto::Hardware::Graphics* gpu = hardware->mutable_gpu();
576 gpu->set_vendor_id(gpu_info.gpu.vendor_id);
577 gpu->set_device_id(gpu_info.gpu.device_id);
578 gpu->set_driver_version(gpu_info.driver_version);
579 gpu->set_driver_date(gpu_info.driver_date);
580 SystemProfileProto::Hardware::Graphics::PerformanceStatistics*
581 gpu_performance = gpu->mutable_performance_statistics();
582 gpu_performance->set_graphics_score(gpu_info.performance_stats.graphics);
583 gpu_performance->set_gaming_score(gpu_info.performance_stats.gaming);
584 gpu_performance->set_overall_score(gpu_info.performance_stats.overall);
585 gpu->set_gl_vendor(gpu_info.gl_vendor);
586 gpu->set_gl_renderer(gpu_info.gl_renderer);
587
588 const gfx::Size display_size = GetScreenSize();
589 hardware->set_primary_screen_width(display_size.width());
590 hardware->set_primary_screen_height(display_size.height());
591 hardware->set_primary_screen_scale_factor(GetScreenDeviceScaleFactor());
592 hardware->set_screen_count(GetScreenCount());
593
594 #if defined(OS_WIN)
595 WriteScreenDPIInformationProto(hardware);
596 #endif
597
598 WritePluginList(plugin_list); 517 WritePluginList(plugin_list);
599 extension_metrics_.WriteExtensionList(uma_proto()->mutable_system_profile()); 518 extension_metrics_.WriteExtensionList(uma_proto()->mutable_system_profile());
600 519
601 std::vector<ActiveGroupId> field_trial_ids; 520 std::vector<ActiveGroupId> field_trial_ids;
602 GetFieldTrialIds(&field_trial_ids); 521 GetFieldTrialIds(&field_trial_ids);
603 WriteFieldTrials(field_trial_ids, system_profile); 522 WriteFieldTrials(field_trial_ids, system_profile);
604 WriteFieldTrials(synthetic_trials, system_profile); 523 WriteFieldTrials(synthetic_trials, system_profile);
605 524
606 #if defined(OS_CHROMEOS) 525 #if defined(OS_CHROMEOS)
607 metrics_log_chromeos_->LogChromeOSMetrics(); 526 metrics_log_chromeos_->LogChromeOSMetrics();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 profile = uma_proto()->add_profiler_event(); 577 profile = uma_proto()->add_profiler_event();
659 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE); 578 profile->set_profile_type(ProfilerEventProto::STARTUP_PROFILE);
660 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); 579 profile->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME);
661 } else { 580 } else {
662 // For the remaining calls, re-use the existing field. 581 // For the remaining calls, re-use the existing field.
663 profile = uma_proto()->mutable_profiler_event(0); 582 profile = uma_proto()->mutable_profiler_event(0);
664 } 583 }
665 584
666 WriteProfilerData(process_data, process_type, profile); 585 WriteProfilerData(process_data, process_type, profile);
667 } 586 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698