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/task_scheduler/post_task.h" | |
| 43 #include "base/version.h" | 46 #include "base/version.h" |
| 44 #if defined(USE_X11) | 47 #if defined(USE_X11) |
| 45 #include "ui/base/x/x11_util.h" | 48 #include "ui/base/x/x11_util.h" |
| 46 #endif | 49 #endif |
| 47 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 50 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 48 | 51 |
| 49 #if defined(USE_OZONE) || defined(USE_X11) | 52 #if defined(USE_OZONE) || defined(USE_X11) |
| 50 #include "ui/events/devices/input_device_event_observer.h" | 53 #include "ui/events/devices/input_device_event_observer.h" |
| 51 #include "ui/events/devices/input_device_manager.h" | 54 #include "ui/events/devices/input_device_manager.h" |
| 52 #endif // defined(USE_OZONE) || defined(USE_X11) | 55 #endif // defined(USE_OZONE) || defined(USE_X11) |
| 53 | 56 |
| 54 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 55 #include "base/win/windows_version.h" | 58 #include "base/win/windows_version.h" |
| 56 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 59 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 57 #include "chrome/browser/shell_integration_win.h" | 60 #include "chrome/browser/shell_integration_win.h" |
| 58 #include "chrome/installer/util/google_update_settings.h" | 61 #include "chrome/installer/util/google_update_settings.h" |
| 59 #endif // defined(OS_WIN) | 62 #endif // defined(OS_WIN) |
| 60 | 63 |
| 61 namespace { | 64 namespace { |
| 62 | 65 |
| 66 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
|
Tom Anderson
2017/05/24 01:19:13
nit: I don't think the include guards here are nec
timbrown
2017/05/24 17:35:41
Done.
| |
| 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 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 85 | |
| 63 enum UMALinuxGlibcVersion { | 86 enum UMALinuxGlibcVersion { |
| 64 UMA_LINUX_GLIBC_NOT_PARSEABLE, | 87 UMA_LINUX_GLIBC_NOT_PARSEABLE, |
| 65 UMA_LINUX_GLIBC_UNKNOWN, | 88 UMA_LINUX_GLIBC_UNKNOWN, |
| 66 UMA_LINUX_GLIBC_2_11, | 89 UMA_LINUX_GLIBC_2_11, |
| 67 // To log newer versions, just update tools/metrics/histograms/histograms.xml. | 90 // To log newer versions, just update tools/metrics/histograms/histograms.xml. |
| 68 }; | 91 }; |
| 69 | 92 |
| 70 enum UMALinuxWindowManager { | 93 enum UMALinuxWindowManager { |
| 71 UMA_LINUX_WINDOW_MANAGER_OTHER, | 94 UMA_LINUX_WINDOW_MANAGER_OTHER, |
| 72 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, | 95 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", | 179 UMA_HISTOGRAM_BOOLEAN("Windows.InCompatibilityMode", |
| 157 os_info.version() != os_info.Kernel32Version()); | 180 os_info.version() != os_info.Kernel32Version()); |
| 158 #endif // defined(OS_WIN) | 181 #endif // defined(OS_WIN) |
| 159 | 182 |
| 160 #if defined(OS_MACOSX) | 183 #if defined(OS_MACOSX) |
| 161 bluetooth_utility::BluetoothAvailability availability = | 184 bluetooth_utility::BluetoothAvailability availability = |
| 162 bluetooth_utility::GetBluetoothAvailability(); | 185 bluetooth_utility::GetBluetoothAvailability(); |
| 163 UMA_HISTOGRAM_ENUMERATION("OSX.BluetoothAvailability", | 186 UMA_HISTOGRAM_ENUMERATION("OSX.BluetoothAvailability", |
| 164 availability, | 187 availability, |
| 165 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); | 188 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); |
| 166 #endif // defined(OS_MACOSX) | 189 #endif // defined(OS_MACOSX) |
| 167 | 190 |
| 168 // Record whether Chrome is the default browser or not. | 191 // Record whether Chrome is the default browser or not. |
| 169 shell_integration::DefaultWebClientState default_state = | 192 shell_integration::DefaultWebClientState default_state = |
| 170 shell_integration::GetDefaultBrowser(); | 193 shell_integration::GetDefaultBrowser(); |
| 171 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, | 194 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, |
| 172 shell_integration::NUM_DEFAULT_STATES); | 195 shell_integration::NUM_DEFAULT_STATES); |
| 173 } | 196 } |
| 174 | 197 |
| 198 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 199 void RecordLinuxDistro() { | |
| 200 UMALinuxDistro distro_result = UMA_LINUX_DISTRO_UNKNOWN; | |
| 201 | |
| 202 std::vector<std::string> distro_tokens = | |
| 203 base::SplitString(base::GetLinuxDistro(), " .", base::TRIM_WHITESPACE, | |
|
Tom Anderson
2017/05/24 01:19:13
Instead of using " ." as the separators, use base:
timbrown
2017/05/24 17:35:41
Done.
| |
| 204 base::SPLIT_WANT_NONEMPTY); | |
| 205 if (distro_tokens.size() > 0) { | |
| 206 if (distro_tokens[0] == "Ubuntu") { | |
| 207 // Format: Ubuntu YY.MM.P [LTS] | |
| 208 // We are only concerned with release (YY.MM) not the patch (P). | |
| 209 distro_result = UMA_LINUX_DISTRO_UBUNTU_OTHER; | |
| 210 if (distro_tokens.size() >= 3) { | |
|
Tom Anderson
2017/05/24 01:19:13
Use base::Version for distro versions.
You can co
timbrown
2017/05/24 17:35:41
Done.
I also changed the debian check, since it u
| |
| 211 if (distro_tokens[1] == "14" && distro_tokens[2] == "04") { | |
| 212 distro_result = UMA_LINUX_DISTRO_UBUNTU_14_04; | |
| 213 } else if (distro_tokens[1] == "16" && distro_tokens[2] == "04") { | |
| 214 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_04; | |
| 215 } else if (distro_tokens[1] == "16" && distro_tokens[2] == "10") { | |
| 216 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_10; | |
| 217 } else if (distro_tokens[1] == "17" && distro_tokens[2] == "04") { | |
| 218 distro_result = UMA_LINUX_DISTRO_UBUNTU_17_04; | |
| 219 } | |
| 220 } | |
| 221 } else if (distro_tokens[0] == "openSUSE") { | |
| 222 // Format: openSUSE Leap RR.R | |
| 223 distro_result = UMA_LINUX_DISTRO_OPENSUSE_OTHER; | |
| 224 if (distro_tokens.size() >= 4 && distro_tokens[1] == "Leap" && | |
| 225 distro_tokens[2] == "42" && distro_tokens[3] == "2") { | |
| 226 distro_result = UMA_LINUX_DISTRO_OPENSUSE_LEAP_42_2; | |
| 227 } | |
| 228 } else if (distro_tokens[0] == "Debian") { | |
| 229 // Format: Debian GNU/Linux R.P (<codename>) | |
| 230 // We are only concerned with the release (R) not the patch (P). | |
| 231 distro_result = UMA_LINUX_DISTRO_DEBIAN_OTHER; | |
| 232 if (distro_tokens.size() >= 3 && distro_tokens[2][0] == '8') { | |
| 233 distro_result = UMA_LINUX_DISTRO_DEBIAN_8; | |
| 234 } | |
| 235 } else if (distro_tokens[0] == "Fedora") { | |
| 236 // Format: Fedora release RR (<codename>) | |
| 237 distro_result = UMA_LINUX_DISTRO_FEDORA_OTHER; | |
| 238 if (distro_tokens.size() >= 3) { | |
| 239 if (distro_tokens[2] == "24") { | |
| 240 distro_result = UMA_LINUX_DISTRO_FEDORA_24; | |
| 241 } else if (distro_tokens[2] == "25") { | |
| 242 distro_result = UMA_LINUX_DISTRO_FEDORA_25; | |
| 243 } | |
| 244 } | |
| 245 } | |
| 246 } | |
| 247 | |
| 248 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.Distro", distro_result); | |
| 249 } | |
| 250 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 251 | |
| 175 void RecordLinuxGlibcVersion() { | 252 void RecordLinuxGlibcVersion() { |
| 176 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 253 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 177 base::Version version(gnu_get_libc_version()); | 254 base::Version version(gnu_get_libc_version()); |
| 178 | 255 |
| 179 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; | 256 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; |
| 180 if (version.IsValid() && version.components().size() == 2) { | 257 if (version.IsValid() && version.components().size() == 2) { |
| 181 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; | 258 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; |
| 182 uint32_t glibc_major_version = version.components()[0]; | 259 uint32_t glibc_major_version = version.components()[0]; |
| 183 uint32_t glibc_minor_version = version.components()[1]; | 260 uint32_t glibc_minor_version = version.components()[1]; |
| 184 if (glibc_major_version == 2) { | 261 if (glibc_major_version == 2) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 ); | 452 ); |
| 376 #endif | 453 #endif |
| 377 } | 454 } |
| 378 | 455 |
| 379 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { | 456 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { |
| 380 RecordLinuxGlibcVersion(); | 457 RecordLinuxGlibcVersion(); |
| 381 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 458 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 382 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", | 459 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", |
| 383 GetLinuxWindowManager(), | 460 GetLinuxWindowManager(), |
| 384 UMA_LINUX_WINDOW_MANAGER_COUNT); | 461 UMA_LINUX_WINDOW_MANAGER_COUNT); |
| 462 base::PostTaskWithTraits( | |
| 463 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, | |
| 464 base::BindOnce(base::IgnoreResult(&RecordLinuxDistro))); | |
|
Tom Anderson
2017/05/24 01:19:13
RecordLinuxDistro doesn't return anything, so you
timbrown
2017/05/24 17:35:41
Done.
| |
| 385 #endif | 465 #endif |
| 386 | 466 |
| 387 #if defined(USE_OZONE) || defined(USE_X11) | 467 #if defined(USE_OZONE) || defined(USE_X11) |
| 388 // The touch event state for X11 and Ozone based event sub-systems are based | 468 // 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 | 469 // on device scans that happen asynchronously. So we may need to attach an |
| 390 // observer to wait until these scans complete. | 470 // observer to wait until these scans complete. |
| 391 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { | 471 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) { |
| 392 RecordTouchEventState(); | 472 RecordTouchEventState(); |
| 393 } else { | 473 } else { |
| 394 input_device_event_observer_.reset( | 474 input_device_event_observer_.reset( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 } | 527 } |
| 448 } | 528 } |
| 449 | 529 |
| 450 namespace chrome { | 530 namespace chrome { |
| 451 | 531 |
| 452 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 532 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
| 453 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 533 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
| 454 } | 534 } |
| 455 | 535 |
| 456 } // namespace chrome | 536 } // namespace chrome |
| OLD | NEW |