| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chrome_browser_main_extra_parts_metrics.h" | 5 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/cpu.h" | 11 #include "base/cpu.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/about_flags.h" | 17 #include "chrome/browser/about_flags.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chrome_browser_main.h" | 19 #include "chrome/browser/chrome_browser_main.h" |
| 20 #include "chrome/browser/mac/bluetooth_utility.h" | 20 #include "chrome/browser/mac/bluetooth_utility.h" |
| 21 #include "chrome/browser/shell_integration.h" | 21 #include "chrome/browser/shell_integration.h" |
| 22 #include "components/flags_ui/pref_service_flags_storage.h" | 22 #include "components/flags_ui/pref_service_flags_storage.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "ui/base/touch/touch_device.h" | 24 #include "ui/base/touch/touch_device.h" |
| 25 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
| 26 #include "ui/events/event_switches.h" | 26 #include "ui/events/event_switches.h" |
| 27 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
| 28 | 28 |
| 29 #if !defined(OS_ANDROID) |
| 30 #include "chrome/browser/metrics/first_web_contents_profiler.h" |
| 31 #endif // !defined(OS_ANDROID) |
| 32 |
| 29 #if defined(OS_ANDROID) && defined(__arm__) | 33 #if defined(OS_ANDROID) && defined(__arm__) |
| 30 #include <cpu-features.h> | 34 #include <cpu-features.h> |
| 31 #endif // defined(OS_ANDROID) && defined(__arm__) | 35 #endif // defined(OS_ANDROID) && defined(__arm__) |
| 32 | 36 |
| 33 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 37 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 34 #include <gnu/libc-version.h> | 38 #include <gnu/libc-version.h> |
| 35 | 39 |
| 36 #include "base/version.h" | 40 #include "base/version.h" |
| 37 #if defined(USE_X11) | 41 #if defined(USE_X11) |
| 38 #include "ui/base/x/x11_util.h" | 42 #include "ui/base/x/x11_util.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 FROM_HERE, | 340 FROM_HERE, |
| 337 base::Bind(&RecordStartupMetricsOnBlockingPool), | 341 base::Bind(&RecordStartupMetricsOnBlockingPool), |
| 338 base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); | 342 base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); |
| 339 | 343 |
| 340 display_count_ = gfx::Screen::GetNativeScreen()->GetNumDisplays(); | 344 display_count_ = gfx::Screen::GetNativeScreen()->GetNumDisplays(); |
| 341 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); | 345 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); |
| 342 gfx::Screen::GetNativeScreen()->AddObserver(this); | 346 gfx::Screen::GetNativeScreen()->AddObserver(this); |
| 343 is_screen_observer_ = true; | 347 is_screen_observer_ = true; |
| 344 | 348 |
| 345 #if !defined(OS_ANDROID) | 349 #if !defined(OS_ANDROID) |
| 346 first_web_contents_profiler_ = | 350 FirstWebContentsProfiler::Start(); |
| 347 FirstWebContentsProfiler::CreateProfilerForFirstWebContents(this).Pass(); | |
| 348 #endif // !defined(OS_ANDROID) | 351 #endif // !defined(OS_ANDROID) |
| 349 } | 352 } |
| 350 | 353 |
| 351 void ChromeBrowserMainExtraPartsMetrics::OnDisplayAdded( | 354 void ChromeBrowserMainExtraPartsMetrics::OnDisplayAdded( |
| 352 const gfx::Display& new_display) { | 355 const gfx::Display& new_display) { |
| 353 EmitDisplaysChangedMetric(); | 356 EmitDisplaysChangedMetric(); |
| 354 } | 357 } |
| 355 | 358 |
| 356 void ChromeBrowserMainExtraPartsMetrics::OnDisplayRemoved( | 359 void ChromeBrowserMainExtraPartsMetrics::OnDisplayRemoved( |
| 357 const gfx::Display& old_display) { | 360 const gfx::Display& old_display) { |
| 358 EmitDisplaysChangedMetric(); | 361 EmitDisplaysChangedMetric(); |
| 359 } | 362 } |
| 360 | 363 |
| 361 void ChromeBrowserMainExtraPartsMetrics::OnDisplayMetricsChanged( | 364 void ChromeBrowserMainExtraPartsMetrics::OnDisplayMetricsChanged( |
| 362 const gfx::Display& display, | 365 const gfx::Display& display, |
| 363 uint32_t changed_metrics) { | 366 uint32_t changed_metrics) { |
| 364 } | 367 } |
| 365 | 368 |
| 366 #if !defined(OS_ANDROID) | |
| 367 void ChromeBrowserMainExtraPartsMetrics::ProfilerFinishedCollectingMetrics() { | |
| 368 first_web_contents_profiler_.reset(); | |
| 369 } | |
| 370 #endif // !defined(OS_ANDROID) | |
| 371 | |
| 372 void ChromeBrowserMainExtraPartsMetrics::EmitDisplaysChangedMetric() { | 369 void ChromeBrowserMainExtraPartsMetrics::EmitDisplaysChangedMetric() { |
| 373 int display_count = gfx::Screen::GetNativeScreen()->GetNumDisplays(); | 370 int display_count = gfx::Screen::GetNativeScreen()->GetNumDisplays(); |
| 374 if (display_count != display_count_) { | 371 if (display_count != display_count_) { |
| 375 display_count_ = display_count; | 372 display_count_ = display_count; |
| 376 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnChange", display_count_); | 373 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnChange", display_count_); |
| 377 } | 374 } |
| 378 } | 375 } |
| 379 | 376 |
| 380 namespace chrome { | 377 namespace chrome { |
| 381 | 378 |
| 382 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 379 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
| 383 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 380 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
| 384 } | 381 } |
| 385 | 382 |
| 386 } // namespace chrome | 383 } // namespace chrome |
| OLD | NEW |