Chromium Code Reviews| 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/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "base/task_scheduler/post_task.h" | |
| 17 #include "base/task_scheduler/task_traits.h" | |
| 16 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 18 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 19 #include "chrome/browser/about_flags.h" | 21 #include "chrome/browser/about_flags.h" |
| 20 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_browser_main.h" | 23 #include "chrome/browser/chrome_browser_main.h" |
| 22 #include "chrome/browser/mac/bluetooth_utility.h" | 24 #include "chrome/browser/mac/bluetooth_utility.h" |
| 23 #include "chrome/browser/shell_integration.h" | 25 #include "chrome/browser/shell_integration.h" |
| 24 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_list.h" | 27 #include "chrome/browser/ui/browser_list.h" |
| 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 27 #include "components/flags_ui/pref_service_flags_storage.h" | 29 #include "components/flags_ui/pref_service_flags_storage.h" |
| 28 #include "content/public/browser/browser_thread.h" | |
| 29 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
| 30 #include "ui/base/touch/touch_device.h" | 31 #include "ui/base/touch/touch_device.h" |
| 31 #include "ui/base/ui_base_switches.h" | 32 #include "ui/base/ui_base_switches.h" |
| 32 #include "ui/display/screen.h" | 33 #include "ui/display/screen.h" |
| 33 | 34 |
| 34 #if !defined(OS_ANDROID) | 35 #if !defined(OS_ANDROID) |
| 35 #include "chrome/browser/metrics/first_web_contents_profiler.h" | 36 #include "chrome/browser/metrics/first_web_contents_profiler.h" |
| 36 #include "chrome/browser/metrics/tab_usage_recorder.h" | 37 #include "chrome/browser/metrics/tab_usage_recorder.h" |
| 37 #endif // !defined(OS_ANDROID) | 38 #endif // !defined(OS_ANDROID) |
| 38 | 39 |
| 39 #if defined(OS_ANDROID) && defined(__arm__) | 40 #if defined(OS_ANDROID) && defined(__arm__) |
| 40 #include <cpu-features.h> | 41 #include <cpu-features.h> |
| 41 #endif // defined(OS_ANDROID) && defined(__arm__) | 42 #endif // defined(OS_ANDROID) && defined(__arm__) |
| 42 | 43 |
| 43 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 44 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 44 #include <gnu/libc-version.h> | 45 #include <gnu/libc-version.h> |
| 45 | 46 |
| 46 #include "base/linux_util.h" | 47 #include "base/linux_util.h" |
| 47 #include "base/strings/string_split.h" | 48 #include "base/strings/string_split.h" |
| 48 #include "base/strings/string_util.h" | 49 #include "base/strings/string_util.h" |
| 49 #include "base/task_scheduler/post_task.h" | |
| 50 #include "base/version.h" | 50 #include "base/version.h" |
| 51 #if defined(USE_X11) | 51 #if defined(USE_X11) |
| 52 #include "ui/base/x/x11_util.h" | 52 #include "ui/base/x/x11_util.h" |
| 53 #endif | 53 #endif |
| 54 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 54 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 55 | 55 |
| 56 #if defined(USE_OZONE) || defined(USE_X11) | 56 #if defined(USE_OZONE) || defined(USE_X11) |
| 57 #include "ui/events/devices/input_device_event_observer.h" | 57 #include "ui/events/devices/input_device_event_observer.h" |
| 58 #include "ui/events/devices/input_device_manager.h" | 58 #include "ui/events/devices/input_device_manager.h" |
| 59 #endif // defined(USE_OZONE) || defined(USE_X11) | 59 #endif // defined(USE_OZONE) || defined(USE_X11) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 } else { | 170 } else { |
| 171 UMA_HISTOGRAM_ENUMERATION("Android.ArmFpu", | 171 UMA_HISTOGRAM_ENUMERATION("Android.ArmFpu", |
| 172 UMA_ANDROID_ARM_FPU_VFPV3_D16, | 172 UMA_ANDROID_ARM_FPU_VFPV3_D16, |
| 173 UMA_ANDROID_ARM_FPU_COUNT); | 173 UMA_ANDROID_ARM_FPU_COUNT); |
| 174 } | 174 } |
| 175 #endif // defined(OS_ANDROID) && defined(__arm__) | 175 #endif // defined(OS_ANDROID) && defined(__arm__) |
| 176 UMA_HISTOGRAM_SPARSE_SLOWLY("Platform.LogicalCpuCount", | 176 UMA_HISTOGRAM_SPARSE_SLOWLY("Platform.LogicalCpuCount", |
| 177 base::SysInfo::NumberOfProcessors()); | 177 base::SysInfo::NumberOfProcessors()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Called on the blocking pool some time after startup to avoid slowing down | 180 // Called on a background thread, with low priority to avoid slowing down |
| 181 // startup with metrics that aren't trivial to compute. | 181 // startup with metrics that aren't trivial to compute. |
| 182 void RecordStartupMetricsOnBlockingPool() { | 182 void RecordStartupMetrics() { |
| 183 #if defined(OS_WIN) | 183 #if defined(OS_WIN) |
| 184 GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms(); | 184 GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms(); |
| 185 | 185 |
| 186 const base::win::OSInfo& os_info = *base::win::OSInfo::GetInstance(); | 186 const base::win::OSInfo& os_info = *base::win::OSInfo::GetInstance(); |
| 187 UMA_HISTOGRAM_ENUMERATION("Windows.GetVersionExVersion", os_info.version(), | 187 UMA_HISTOGRAM_ENUMERATION("Windows.GetVersionExVersion", os_info.version(), |
| 188 base::win::VERSION_WIN_LAST); | 188 base::win::VERSION_WIN_LAST); |
| 189 UMA_HISTOGRAM_ENUMERATION("Windows.Kernel32Version", | 189 UMA_HISTOGRAM_ENUMERATION("Windows.Kernel32Version", |
| 190 os_info.Kernel32Version(), | 190 os_info.Kernel32Version(), |
| 191 base::win::VERSION_WIN_LAST); | 191 base::win::VERSION_WIN_LAST); |
| 192 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", | 192 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 | 455 |
| 456 // Used for histograms; do not reorder. | 456 // Used for histograms; do not reorder. |
| 457 enum Result { NOT_PINNED = 0, PINNED = 1, FAILURE = 2, NUM_RESULTS }; | 457 enum Result { NOT_PINNED = 0, PINNED = 1, FAILURE = 2, NUM_RESULTS }; |
| 458 | 458 |
| 459 Result result = FAILURE; | 459 Result result = FAILURE; |
| 460 if (succeeded) | 460 if (succeeded) |
| 461 result = is_pinned_to_taskbar ? PINNED : NOT_PINNED; | 461 result = is_pinned_to_taskbar ? PINNED : NOT_PINNED; |
| 462 UMA_HISTOGRAM_ENUMERATION("Windows.IsPinnedToTaskbar", result, NUM_RESULTS); | 462 UMA_HISTOGRAM_ENUMERATION("Windows.IsPinnedToTaskbar", result, NUM_RESULTS); |
| 463 } | 463 } |
| 464 | 464 |
| 465 // Records the pinned state of the current executable into a histogram. | 465 // Records the pinned state of the current executable into a histogram. Should |
| 466 // be called on a background thread, with low priority, to avoid slowing down | |
| 467 // startup. | |
| 466 void RecordIsPinnedToTaskbarHistogram() { | 468 void RecordIsPinnedToTaskbarHistogram() { |
| 467 shell_integration::win::GetIsPinnedToTaskbarState( | 469 shell_integration::win::GetIsPinnedToTaskbarState( |
| 468 base::Bind(&OnShellHandlerConnectionError), | 470 base::Bind(&OnShellHandlerConnectionError), |
| 469 base::Bind(&OnIsPinnedToTaskbarResult)); | 471 base::Bind(&OnIsPinnedToTaskbarResult)); |
| 470 } | 472 } |
| 471 #endif // defined(OS_WIN) | 473 #endif // defined(OS_WIN) |
| 472 | 474 |
| 473 } // namespace | 475 } // namespace |
| 474 | 476 |
| 475 ChromeBrowserMainExtraPartsMetrics::ChromeBrowserMainExtraPartsMetrics() | 477 ChromeBrowserMainExtraPartsMetrics::ChromeBrowserMainExtraPartsMetrics() |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 500 ); | 502 ); |
| 501 #endif | 503 #endif |
| 502 } | 504 } |
| 503 | 505 |
| 504 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { | 506 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { |
| 505 RecordLinuxGlibcVersion(); | 507 RecordLinuxGlibcVersion(); |
| 506 #if defined(OS_LINUX) && defined(USE_X11) && !defined(OS_CHROMEOS) | 508 #if defined(OS_LINUX) && defined(USE_X11) && !defined(OS_CHROMEOS) |
| 507 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", GetLinuxWindowManager(), | 509 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", GetLinuxWindowManager(), |
| 508 UMA_LINUX_WINDOW_MANAGER_COUNT); | 510 UMA_LINUX_WINDOW_MANAGER_COUNT); |
| 509 #endif | 511 #endif |
| 512 | |
| 513 base::TaskTraits background_task_traits = { | |
|
Alexei Svitkine (slow)
2017/07/12 15:12:56
Nit: const
Ilya Sherman
2017/07/12 19:39:46
Done.
| |
| 514 base::MayBlock(), base::TaskPriority::BACKGROUND, | |
| 515 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}; | |
| 510 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 516 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 511 base::PostTaskWithTraits(FROM_HERE, | 517 base::PostTaskWithTraits(FROM_HERE, background_task_traits, |
| 512 {base::MayBlock(), base::TaskPriority::BACKGROUND}, | |
| 513 base::BindOnce(&RecordLinuxDistro)); | 518 base::BindOnce(&RecordLinuxDistro)); |
| 514 #endif | 519 #endif |
| 515 | 520 |
| 516 #if defined(USE_OZONE) || defined(USE_X11) | 521 #if defined(USE_OZONE) || defined(USE_X11) |
| 517 // The touch event state for X11 and Ozone based event sub-systems are based | 522 // The touch event state for X11 and Ozone based event sub-systems are based |
| 518 // on device scans that happen asynchronously. So we may need to attach an | 523 // on device scans that happen asynchronously. So we may need to attach an |
| 519 // observer to wait until these scans complete. | 524 // observer to wait until these scans complete. |
| 520 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { | 525 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { |
| 521 RecordTouchEventState(); | 526 RecordTouchEventState(); |
| 522 } else { | 527 } else { |
| 523 input_device_event_observer_.reset( | 528 input_device_event_observer_.reset( |
| 524 new AsynchronousTouchEventStateRecorder()); | 529 new AsynchronousTouchEventStateRecorder()); |
| 525 } | 530 } |
| 526 #else | 531 #else |
| 527 RecordTouchEventState(); | 532 RecordTouchEventState(); |
| 528 #endif // defined(USE_OZONE) || defined(USE_X11) | 533 #endif // defined(USE_OZONE) || defined(USE_X11) |
| 529 | 534 |
| 530 #if defined(OS_MACOSX) | 535 #if defined(OS_MACOSX) |
| 531 RecordMacMetrics(); | 536 RecordMacMetrics(); |
| 532 #endif // defined(OS_MACOSX) | 537 #endif // defined(OS_MACOSX) |
| 533 | 538 |
| 534 constexpr base::TimeDelta kStartupMetricsGatheringDelay = | |
| 535 base::TimeDelta::FromSeconds(45); | |
| 536 content::BrowserThread::GetBlockingPool()->PostDelayedTask( | |
| 537 FROM_HERE, base::BindOnce(&RecordStartupMetricsOnBlockingPool), | |
| 538 kStartupMetricsGatheringDelay); | |
| 539 #if defined(OS_WIN) | 539 #if defined(OS_WIN) |
| 540 content::BrowserThread::PostDelayedTask( | 540 // RecordStartupMetrics calls into shell_integration::GetDefaultBrowser(), |
| 541 content::BrowserThread::IO, FROM_HERE, | 541 // which requires a COM thread on Windows. |
| 542 base::Bind(&RecordIsPinnedToTaskbarHistogram), | 542 base::CreateCOMSTATaskRunnerWithTraits(background_task_traits) |
| 543 kStartupMetricsGatheringDelay); | 543 ->PostTask(FROM_HERE, base::BindOnce(&RecordStartupMetrics)); |
| 544 #else | |
| 545 base::PostTaskWithTraits(FROM_HERE, background_task_traits, | |
| 546 base::BindOnce(&RecordStartupMetrics)); | |
|
Alexei Svitkine (slow)
2017/07/12 15:12:56
The behavior change is we're now no longer doing t
Ilya Sherman
2017/07/12 19:39:46
Good point! Updated the CL description and filed
| |
| 547 #endif // defined(OS_WIN) | |
| 548 | |
| 549 #if defined(OS_WIN) | |
| 550 // TODO(isherman): The delay below is currently needed to avoid (flakily) | |
| 551 // breaking some tests, including all of the ProcessMemoryMetricsEmitterTest | |
| 552 // tests. Figure out why there is a dependency and fix the tests. | |
| 553 base::CreateSequencedTaskRunnerWithTraits(background_task_traits) | |
| 554 ->PostDelayedTask(FROM_HERE, | |
| 555 base::BindOnce(&RecordIsPinnedToTaskbarHistogram), | |
| 556 base::TimeDelta::FromSeconds(45)); | |
| 544 #endif // defined(OS_WIN) | 557 #endif // defined(OS_WIN) |
| 545 | 558 |
| 546 display_count_ = display::Screen::GetScreen()->GetNumDisplays(); | 559 display_count_ = display::Screen::GetScreen()->GetNumDisplays(); |
| 547 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); | 560 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); |
| 548 display::Screen::GetScreen()->AddObserver(this); | 561 display::Screen::GetScreen()->AddObserver(this); |
| 549 is_screen_observer_ = true; | 562 is_screen_observer_ = true; |
| 550 | 563 |
| 551 #if !defined(OS_ANDROID) | 564 #if !defined(OS_ANDROID) |
| 552 const BrowserList* browser_list = BrowserList::GetInstance(); | 565 const BrowserList* browser_list = BrowserList::GetInstance(); |
| 553 | 566 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 } | 599 } |
| 587 } | 600 } |
| 588 | 601 |
| 589 namespace chrome { | 602 namespace chrome { |
| 590 | 603 |
| 591 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 604 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
| 592 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 605 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
| 593 } | 606 } |
| 594 | 607 |
| 595 } // namespace chrome | 608 } // namespace chrome |
| OLD | NEW |