| 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 // Note: Add new distros to the list above this line, and update LinuxDistro |
| 84 // in tools/metrics/histograms/enums.xml accordingly. |
| 85 UMA_LINUX_DISTRO_MAX |
| 86 }; |
| 87 |
| 63 enum UMALinuxGlibcVersion { | 88 enum UMALinuxGlibcVersion { |
| 64 UMA_LINUX_GLIBC_NOT_PARSEABLE, | 89 UMA_LINUX_GLIBC_NOT_PARSEABLE, |
| 65 UMA_LINUX_GLIBC_UNKNOWN, | 90 UMA_LINUX_GLIBC_UNKNOWN, |
| 66 UMA_LINUX_GLIBC_2_11, | 91 UMA_LINUX_GLIBC_2_11, |
| 67 // To log newer versions, just update tools/metrics/histograms/histograms.xml. | 92 // To log newer versions, just update tools/metrics/histograms/histograms.xml. |
| 68 }; | 93 }; |
| 69 | 94 |
| 70 enum UMALinuxWindowManager { | 95 enum UMALinuxWindowManager { |
| 71 UMA_LINUX_WINDOW_MANAGER_OTHER, | 96 UMA_LINUX_WINDOW_MANAGER_OTHER, |
| 72 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, | 97 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", | 181 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", |
| 157 os_info.version() != os_info.Kernel32Version()); | 182 os_info.version() != os_info.Kernel32Version()); |
| 158 #endif // defined(OS_WIN) | 183 #endif // defined(OS_WIN) |
| 159 | 184 |
| 160 #if defined(OS_MACOSX) | 185 #if defined(OS_MACOSX) |
| 161 bluetooth_utility::BluetoothAvailability availability = | 186 bluetooth_utility::BluetoothAvailability availability = |
| 162 bluetooth_utility::GetBluetoothAvailability(); | 187 bluetooth_utility::GetBluetoothAvailability(); |
| 163 UMA_HISTOGRAM_ENUMERATION("OSX.BluetoothAvailability", | 188 UMA_HISTOGRAM_ENUMERATION("OSX.BluetoothAvailability", |
| 164 availability, | 189 availability, |
| 165 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); | 190 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); |
| 166 #endif // defined(OS_MACOSX) | 191 #endif // defined(OS_MACOSX) |
| 167 | 192 |
| 168 // Record whether Chrome is the default browser or not. | 193 // Record whether Chrome is the default browser or not. |
| 169 shell_integration::DefaultWebClientState default_state = | 194 shell_integration::DefaultWebClientState default_state = |
| 170 shell_integration::GetDefaultBrowser(); | 195 shell_integration::GetDefaultBrowser(); |
| 171 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, | 196 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, |
| 172 shell_integration::NUM_DEFAULT_STATES); | 197 shell_integration::NUM_DEFAULT_STATES); |
| 173 } | 198 } |
| 174 | 199 |
| 200 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 201 void RecordLinuxDistro() { |
| 202 UMALinuxDistro distro_result = UMA_LINUX_DISTRO_UNKNOWN; |
| 203 |
| 204 std::vector<std::string> distro_tokens = |
| 205 base::SplitString(base::GetLinuxDistro(), base::kWhitespaceASCII, |
| 206 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 207 if (distro_tokens.size() > 0) { |
| 208 if (distro_tokens[0] == "Ubuntu") { |
| 209 // Format: Ubuntu YY.MM.P [LTS] |
| 210 // We are only concerned with release (YY.MM) not the patch (P). |
| 211 distro_result = UMA_LINUX_DISTRO_UBUNTU_OTHER; |
| 212 if (distro_tokens.size() >= 3) { |
| 213 base::Version version(distro_tokens[1]); |
| 214 if (version.IsValid()) { |
| 215 if (version.CompareToWildcardString("14.04.*") == 0) { |
| 216 distro_result = UMA_LINUX_DISTRO_UBUNTU_14_04; |
| 217 } else if (version.CompareToWildcardString("16.04.*") == 0) { |
| 218 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_04; |
| 219 } else if (version.CompareToWildcardString("16.10.*") == 0) { |
| 220 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_10; |
| 221 } else if (version.CompareToWildcardString("17.04.*") == 0) { |
| 222 distro_result = UMA_LINUX_DISTRO_UBUNTU_17_04; |
| 223 } |
| 224 } |
| 225 } |
| 226 } else if (distro_tokens[0] == "openSUSE") { |
| 227 // Format: openSUSE Leap RR.R |
| 228 distro_result = UMA_LINUX_DISTRO_OPENSUSE_OTHER; |
| 229 if (distro_tokens.size() >= 4 && distro_tokens[1] == "Leap" && |
| 230 distro_tokens[2] == "42.2") { |
| 231 distro_result = UMA_LINUX_DISTRO_OPENSUSE_LEAP_42_2; |
| 232 } |
| 233 } else if (distro_tokens[0] == "Debian") { |
| 234 // Format: Debian GNU/Linux R.P (<codename>) |
| 235 // We are only concerned with the release (R) not the patch (P). |
| 236 distro_result = UMA_LINUX_DISTRO_DEBIAN_OTHER; |
| 237 if (distro_tokens.size() >= 3) { |
| 238 base::Version version(distro_tokens[2]); |
| 239 if (version.IsValid() && version.CompareToWildcardString("8.*")) { |
| 240 distro_result = UMA_LINUX_DISTRO_DEBIAN_8; |
| 241 } |
| 242 } |
| 243 } else if (distro_tokens[0] == "Fedora") { |
| 244 // Format: Fedora release RR (<codename>) |
| 245 distro_result = UMA_LINUX_DISTRO_FEDORA_OTHER; |
| 246 if (distro_tokens.size() >= 3) { |
| 247 if (distro_tokens[2] == "24") { |
| 248 distro_result = UMA_LINUX_DISTRO_FEDORA_24; |
| 249 } else if (distro_tokens[2] == "25") { |
| 250 distro_result = UMA_LINUX_DISTRO_FEDORA_25; |
| 251 } |
| 252 } |
| 253 } |
| 254 } |
| 255 |
| 256 UMA_HISTOGRAM_ENUMERATION("Linux.Distro", distro_result, |
| 257 UMA_LINUX_DISTRO_MAX); |
| 258 } |
| 259 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 260 |
| 175 void RecordLinuxGlibcVersion() { | 261 void RecordLinuxGlibcVersion() { |
| 176 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 262 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 177 base::Version version(gnu_get_libc_version()); | 263 base::Version version(gnu_get_libc_version()); |
| 178 | 264 |
| 179 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; | 265 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; |
| 180 if (version.IsValid() && version.components().size() == 2) { | 266 if (version.IsValid() && version.components().size() == 2) { |
| 181 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; | 267 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; |
| 182 uint32_t glibc_major_version = version.components()[0]; | 268 uint32_t glibc_major_version = version.components()[0]; |
| 183 uint32_t glibc_minor_version = version.components()[1]; | 269 uint32_t glibc_minor_version = version.components()[1]; |
| 184 if (glibc_major_version == 2) { | 270 if (glibc_major_version == 2) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 ); | 461 ); |
| 376 #endif | 462 #endif |
| 377 } | 463 } |
| 378 | 464 |
| 379 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { | 465 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { |
| 380 RecordLinuxGlibcVersion(); | 466 RecordLinuxGlibcVersion(); |
| 381 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 467 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 382 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", | 468 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", |
| 383 GetLinuxWindowManager(), | 469 GetLinuxWindowManager(), |
| 384 UMA_LINUX_WINDOW_MANAGER_COUNT); | 470 UMA_LINUX_WINDOW_MANAGER_COUNT); |
| 471 base::PostTaskWithTraits(FROM_HERE, |
| 472 {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 473 base::BindOnce(&RecordLinuxDistro)); |
| 385 #endif | 474 #endif |
| 386 | 475 |
| 387 #if defined(USE_OZONE) || defined(USE_X11) | 476 #if defined(USE_OZONE) || defined(USE_X11) |
| 388 // The touch event state for X11 and Ozone based event sub-systems are based | 477 // 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 | 478 // on device scans that happen asynchronously. So we may need to attach an |
| 390 // observer to wait until these scans complete. | 479 // observer to wait until these scans complete. |
| 391 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { | 480 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { |
| 392 RecordTouchEventState(); | 481 RecordTouchEventState(); |
| 393 } else { | 482 } else { |
| 394 input_device_event_observer_.reset( | 483 input_device_event_observer_.reset( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 536 } |
| 448 } | 537 } |
| 449 | 538 |
| 450 namespace chrome { | 539 namespace chrome { |
| 451 | 540 |
| 452 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 541 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
| 453 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 542 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
| 454 } | 543 } |
| 455 | 544 |
| 456 } // namespace chrome | 545 } // namespace chrome |
| OLD | NEW |