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" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "chrome/browser/metrics/tab_usage_recorder.h" | 33 #include "chrome/browser/metrics/tab_usage_recorder.h" |
| 34 #endif // !defined(OS_ANDROID) | 34 #endif // !defined(OS_ANDROID) |
| 35 | 35 |
| 36 #if defined(OS_ANDROID) && defined(__arm__) | 36 #if defined(OS_ANDROID) && defined(__arm__) |
| 37 #include <cpu-features.h> | 37 #include <cpu-features.h> |
| 38 #endif // defined(OS_ANDROID) && defined(__arm__) | 38 #endif // defined(OS_ANDROID) && defined(__arm__) |
| 39 | 39 |
| 40 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 40 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 41 #include <gnu/libc-version.h> | 41 #include <gnu/libc-version.h> |
| 42 | 42 |
| 43 #include "base/linux_util.h" | |
| 44 #include "base/strings/string_split.h" | |
| 45 #include "base/strings/string_util.h" | |
| 46 #include "base/task_scheduler/post_task.h" | |
| 43 #include "base/version.h" | 47 #include "base/version.h" |
| 44 #if defined(USE_X11) | 48 #if defined(USE_X11) |
| 45 #include "ui/base/x/x11_util.h" | 49 #include "ui/base/x/x11_util.h" |
| 46 #endif | 50 #endif |
| 47 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 51 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 48 | 52 |
| 49 #if defined(USE_OZONE) || defined(USE_X11) | 53 #if defined(USE_OZONE) || defined(USE_X11) |
| 50 #include "ui/events/devices/input_device_event_observer.h" | 54 #include "ui/events/devices/input_device_event_observer.h" |
| 51 #include "ui/events/devices/input_device_manager.h" | 55 #include "ui/events/devices/input_device_manager.h" |
| 52 #endif // defined(USE_OZONE) || defined(USE_X11) | 56 #endif // defined(USE_OZONE) || defined(USE_X11) |
| 53 | 57 |
| 54 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 55 #include "base/win/windows_version.h" | 59 #include "base/win/windows_version.h" |
| 56 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 60 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 57 #include "chrome/browser/shell_integration_win.h" | 61 #include "chrome/browser/shell_integration_win.h" |
| 58 #include "chrome/installer/util/google_update_settings.h" | 62 #include "chrome/installer/util/google_update_settings.h" |
| 59 #endif // defined(OS_WIN) | 63 #endif // defined(OS_WIN) |
| 60 | 64 |
| 61 namespace { | 65 namespace { |
| 62 | 66 |
| 67 // These values are written to logs. New enum values can be added, but existing | |
| 68 // enums must never be renumbered or deleted and reused. | |
| 69 enum UMALinuxDistro { | |
| 70 UMA_LINUX_DISTRO_UNKNOWN = 0, | |
| 71 UMA_LINUX_DISTRO_UBUNTU_OTHER = 1, | |
| 72 UMA_LINUX_DISTRO_UBUNTU_14_04 = 2, | |
| 73 UMA_LINUX_DISTRO_UBUNTU_16_04 = 3, | |
| 74 UMA_LINUX_DISTRO_UBUNTU_16_10 = 4, | |
| 75 UMA_LINUX_DISTRO_UBUNTU_17_04 = 5, | |
| 76 UMA_LINUX_DISTRO_DEBIAN_OTHER = 6, | |
| 77 UMA_LINUX_DISTRO_DEBIAN_8 = 7, | |
| 78 UMA_LINUX_DISTRO_OPENSUSE_OTHER = 8, | |
| 79 UMA_LINUX_DISTRO_OPENSUSE_LEAP_42_2 = 9, | |
| 80 UMA_LINUX_DISTRO_FEDORA_OTHER = 10, | |
| 81 UMA_LINUX_DISTRO_FEDORA_24 = 11, | |
| 82 UMA_LINUX_DISTRO_FEDORA_25 = 12, | |
| 83 }; | |
| 84 | |
| 63 enum UMALinuxGlibcVersion { | 85 enum UMALinuxGlibcVersion { |
| 64 UMA_LINUX_GLIBC_NOT_PARSEABLE, | 86 UMA_LINUX_GLIBC_NOT_PARSEABLE, |
| 65 UMA_LINUX_GLIBC_UNKNOWN, | 87 UMA_LINUX_GLIBC_UNKNOWN, |
| 66 UMA_LINUX_GLIBC_2_11, | 88 UMA_LINUX_GLIBC_2_11, |
| 67 // To log newer versions, just update tools/metrics/histograms/histograms.xml. | 89 // To log newer versions, just update tools/metrics/histograms/histograms.xml. |
| 68 }; | 90 }; |
| 69 | 91 |
| 70 enum UMALinuxWindowManager { | 92 enum UMALinuxWindowManager { |
| 71 UMA_LINUX_WINDOW_MANAGER_OTHER, | 93 UMA_LINUX_WINDOW_MANAGER_OTHER, |
| 72 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, | 94 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", | 178 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", |
| 157 os_info.version() != os_info.Kernel32Version()); | 179 os_info.version() != os_info.Kernel32Version()); |
| 158 #endif // defined(OS_WIN) | 180 #endif // defined(OS_WIN) |
| 159 | 181 |
| 160 #if defined(OS_MACOSX) | 182 #if defined(OS_MACOSX) |
| 161 bluetooth_utility::BluetoothAvailability availability = | 183 bluetooth_utility::BluetoothAvailability availability = |
| 162 bluetooth_utility::GetBluetoothAvailability(); | 184 bluetooth_utility::GetBluetoothAvailability(); |
| 163 UMA_HISTOGRAM_ENUMERATION("OSX.BluetoothAvailability", | 185 UMA_HISTOGRAM_ENUMERATION("OSX.BluetoothAvailability", |
| 164 availability, | 186 availability, |
| 165 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); | 187 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); |
| 166 #endif // defined(OS_MACOSX) | 188 #endif // defined(OS_MACOSX) |
| 167 | 189 |
| 168 // Record whether Chrome is the default browser or not. | 190 // Record whether Chrome is the default browser or not. |
| 169 shell_integration::DefaultWebClientState default_state = | 191 shell_integration::DefaultWebClientState default_state = |
| 170 shell_integration::GetDefaultBrowser(); | 192 shell_integration::GetDefaultBrowser(); |
| 171 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, | 193 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, |
| 172 shell_integration::NUM_DEFAULT_STATES); | 194 shell_integration::NUM_DEFAULT_STATES); |
| 173 } | 195 } |
| 174 | 196 |
| 197 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 198 void RecordLinuxDistro() { | |
| 199 UMALinuxDistro distro_result = UMA_LINUX_DISTRO_UNKNOWN; | |
| 200 | |
| 201 std::vector<std::string> distro_tokens = | |
| 202 base::SplitString(base::GetLinuxDistro(), base::kWhitespaceASCII, | |
| 203 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | |
| 204 if (distro_tokens.size() > 0) { | |
| 205 if (distro_tokens[0] == "Ubuntu") { | |
| 206 // Format: Ubuntu YY.MM.P [LTS] | |
| 207 // We are only concerned with release (YY.MM) not the patch (P). | |
| 208 distro_result = UMA_LINUX_DISTRO_UBUNTU_OTHER; | |
| 209 if (distro_tokens.size() >= 3) { | |
| 210 base::Version version(distro_tokens[1]); | |
| 211 if (version.IsValid()) { | |
| 212 if (version.CompareToWildcardString("14.04.*") == 0) { | |
| 213 distro_result = UMA_LINUX_DISTRO_UBUNTU_14_04; | |
| 214 } else if (version.CompareToWildcardString("16.04.*") == 0) { | |
| 215 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_04; | |
| 216 } else if (version.CompareToWildcardString("16.10.*") == 0) { | |
| 217 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_10; | |
| 218 } else if (version.CompareToWildcardString("17.04.*") == 0) { | |
| 219 distro_result = UMA_LINUX_DISTRO_UBUNTU_17_04; | |
| 220 } | |
| 221 } | |
| 222 } | |
| 223 } else if (distro_tokens[0] == "openSUSE") { | |
| 224 // Format: openSUSE Leap RR.R | |
| 225 distro_result = UMA_LINUX_DISTRO_OPENSUSE_OTHER; | |
| 226 if (distro_tokens.size() >= 4 && distro_tokens[1] == "Leap" && | |
| 227 distro_tokens[2] == "42.2") { | |
| 228 distro_result = UMA_LINUX_DISTRO_OPENSUSE_LEAP_42_2; | |
| 229 } | |
| 230 } else if (distro_tokens[0] == "Debian") { | |
| 231 // Format: Debian GNU/Linux R.P (<codename>) | |
| 232 // We are only concerned with the release (R) not the patch (P). | |
| 233 distro_result = UMA_LINUX_DISTRO_DEBIAN_OTHER; | |
| 234 if (distro_tokens.size() >= 3) { | |
| 235 base::Version version(distro_tokens[2]); | |
| 236 if (version.IsValid() && version.CompareToWildcardString("8.*")) { | |
| 237 distro_result = UMA_LINUX_DISTRO_DEBIAN_8; | |
| 238 } | |
| 239 } | |
| 240 } else if (distro_tokens[0] == "Fedora") { | |
| 241 // Format: Fedora release RR (<codename>) | |
| 242 distro_result = UMA_LINUX_DISTRO_FEDORA_OTHER; | |
| 243 if (distro_tokens.size() >= 3) { | |
| 244 if (distro_tokens[2] == "24") { | |
| 245 distro_result = UMA_LINUX_DISTRO_FEDORA_24; | |
| 246 } else if (distro_tokens[2] == "25") { | |
| 247 distro_result = UMA_LINUX_DISTRO_FEDORA_25; | |
| 248 } | |
| 249 } | |
| 250 } | |
| 251 } | |
| 252 | |
| 253 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.Distro", distro_result); | |
|
rkaplow
2017/05/24 17:53:06
I agree that this can just be a regular UMA_HISTOG
timbrown
2017/05/24 21:13:25
Done.
| |
| 254 } | |
| 255 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 256 | |
| 175 void RecordLinuxGlibcVersion() { | 257 void RecordLinuxGlibcVersion() { |
| 176 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 258 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 177 base::Version version(gnu_get_libc_version()); | 259 base::Version version(gnu_get_libc_version()); |
| 178 | 260 |
| 179 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; | 261 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; |
| 180 if (version.IsValid() && version.components().size() == 2) { | 262 if (version.IsValid() && version.components().size() == 2) { |
| 181 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; | 263 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; |
| 182 uint32_t glibc_major_version = version.components()[0]; | 264 uint32_t glibc_major_version = version.components()[0]; |
| 183 uint32_t glibc_minor_version = version.components()[1]; | 265 uint32_t glibc_minor_version = version.components()[1]; |
| 184 if (glibc_major_version == 2) { | 266 if (glibc_major_version == 2) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 ); | 457 ); |
| 376 #endif | 458 #endif |
| 377 } | 459 } |
| 378 | 460 |
| 379 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { | 461 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { |
| 380 RecordLinuxGlibcVersion(); | 462 RecordLinuxGlibcVersion(); |
| 381 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 463 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 382 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", | 464 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", |
| 383 GetLinuxWindowManager(), | 465 GetLinuxWindowManager(), |
| 384 UMA_LINUX_WINDOW_MANAGER_COUNT); | 466 UMA_LINUX_WINDOW_MANAGER_COUNT); |
| 467 base::PostTaskWithTraits(FROM_HERE, | |
| 468 {base::MayBlock(), base::TaskPriority::BACKGROUND}, | |
| 469 base::BindOnce(&RecordLinuxDistro)); | |
| 385 #endif | 470 #endif |
| 386 | 471 |
| 387 #if defined(USE_OZONE) || defined(USE_X11) | 472 #if defined(USE_OZONE) || defined(USE_X11) |
| 388 // The touch event state for X11 and Ozone based event sub-systems are based | 473 // The touch event state for X11 and Ozone based event sub-systems are based |
| 389 // on device scans that happen asynchronously. So we may need to attach an | 474 // on device scans that happen asynchronously. So we may need to attach an |
| 390 // observer to wait until these scans complete. | 475 // observer to wait until these scans complete. |
| 391 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { | 476 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { |
| 392 RecordTouchEventState(); | 477 RecordTouchEventState(); |
| 393 } else { | 478 } else { |
| 394 input_device_event_observer_.reset( | 479 input_device_event_observer_.reset( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 } | 532 } |
| 448 } | 533 } |
| 449 | 534 |
| 450 namespace chrome { | 535 namespace chrome { |
| 451 | 536 |
| 452 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 537 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
| 453 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 538 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
| 454 } | 539 } |
| 455 | 540 |
| 456 } // namespace chrome | 541 } // namespace chrome |
| OLD | NEW |