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/linux_util.h" | |
|
Tom Anderson
2017/05/23 22:12:13
Guard this include with #if defined(OS_LINUX) && !
timbrown
2017/05/24 00:40:55
Ah, I missed those sections. Done.
| |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "chrome/browser/about_flags.h" | 20 #include "chrome/browser/about_flags.h" |
| 20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_browser_main.h" | 22 #include "chrome/browser/chrome_browser_main.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 | 54 |
| 54 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
| 55 #include "base/win/windows_version.h" | 56 #include "base/win/windows_version.h" |
| 56 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 57 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 57 #include "chrome/browser/shell_integration_win.h" | 58 #include "chrome/browser/shell_integration_win.h" |
| 58 #include "chrome/installer/util/google_update_settings.h" | 59 #include "chrome/installer/util/google_update_settings.h" |
| 59 #endif // defined(OS_WIN) | 60 #endif // defined(OS_WIN) |
| 60 | 61 |
| 61 namespace { | 62 namespace { |
| 62 | 63 |
| 64 enum UMALinuxDistro { | |
|
Tom Anderson
2017/05/23 22:12:13
Please follow the practices here:
https://chromium
timbrown
2017/05/24 00:40:55
Done.
| |
| 65 UMA_LINUX_DISTRO_UNKNOWN, | |
| 66 UMA_LINUX_DISTRO_UBUNTU_OTHER, | |
| 67 UMA_LINUX_DISTRO_UBUNTU_14_04, | |
| 68 UMA_LINUX_DISTRO_UBUNTU_16_04, | |
| 69 UMA_LINUX_DISTRO_UBUNTU_16_10, | |
| 70 UMA_LINUX_DISTRO_UBUNTU_17_04, | |
| 71 UMA_LINUX_DISTRO_DEBIAN_OTHER, | |
| 72 UMA_LINUX_DISTRO_DEBIAN_8, | |
| 73 UMA_LINUX_DISTRO_OPENSUSE_OTHER, | |
| 74 UMA_LINUX_DISTRO_OPENSUSE_LEAP_42_2, | |
| 75 UMA_LINUX_DISTRO_FEDORA_OTHER, | |
| 76 UMA_LINUX_DISTRO_FEDORA_24, | |
| 77 UMA_LINUX_DISTRO_FEDORA_25, | |
| 78 }; | |
| 79 | |
| 63 enum UMALinuxGlibcVersion { | 80 enum UMALinuxGlibcVersion { |
| 64 UMA_LINUX_GLIBC_NOT_PARSEABLE, | 81 UMA_LINUX_GLIBC_NOT_PARSEABLE, |
| 65 UMA_LINUX_GLIBC_UNKNOWN, | 82 UMA_LINUX_GLIBC_UNKNOWN, |
| 66 UMA_LINUX_GLIBC_2_11, | 83 UMA_LINUX_GLIBC_2_11, |
| 67 // To log newer versions, just update tools/metrics/histograms/histograms.xml. | 84 // To log newer versions, just update tools/metrics/histograms/histograms.xml. |
| 68 }; | 85 }; |
| 69 | 86 |
| 70 enum UMALinuxWindowManager { | 87 enum UMALinuxWindowManager { |
| 71 UMA_LINUX_WINDOW_MANAGER_OTHER, | 88 UMA_LINUX_WINDOW_MANAGER_OTHER, |
| 72 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, | 89 UMA_LINUX_WINDOW_MANAGER_BLACKBOX, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); | 182 bluetooth_utility::BLUETOOTH_AVAILABILITY_COUNT); |
| 166 #endif // defined(OS_MACOSX) | 183 #endif // defined(OS_MACOSX) |
| 167 | 184 |
| 168 // Record whether Chrome is the default browser or not. | 185 // Record whether Chrome is the default browser or not. |
| 169 shell_integration::DefaultWebClientState default_state = | 186 shell_integration::DefaultWebClientState default_state = |
| 170 shell_integration::GetDefaultBrowser(); | 187 shell_integration::GetDefaultBrowser(); |
| 171 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, | 188 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, |
| 172 shell_integration::NUM_DEFAULT_STATES); | 189 shell_integration::NUM_DEFAULT_STATES); |
| 173 } | 190 } |
| 174 | 191 |
| 192 void RecordLinuxDistro() { | |
| 193 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 194 const std::string distro = base::GetLinuxDistro(); | |
|
Tom Anderson
2017/05/23 22:12:13
Does this call block? (GetLinuxDistro caches its
timbrown
2017/05/24 00:40:55
Good catch. GetLinuxDistro() is called previously,
| |
| 195 | |
| 196 UMALinuxDistro distro_result = UMA_LINUX_DISTRO_UNKNOWN; | |
| 197 | |
| 198 const char ubuntu[] = "Ubuntu "; | |
|
Tom Anderson
2017/05/23 22:12:13
constants should have a k prefix and should be nam
timbrown
2017/05/24 00:40:55
Acknowledged.
| |
| 199 const char openSuse[] = "openSUSE "; | |
| 200 const char debian[] = "Debian GNU/Linux "; | |
| 201 const char fedora[] = "Fedora release "; | |
| 202 if (distro.compare(0, strlen(ubuntu), ubuntu) == 0) { | |
|
Tom Anderson
2017/05/23 22:12:13
I think it's better to use base::SplitString() on
timbrown
2017/05/24 00:40:55
Good idea. It's a little longer now with guards on
| |
| 203 // Ubuntu uses point releases for the same version, so we need to do | |
| 204 // prefix matching. | |
| 205 distro_result = UMA_LINUX_DISTRO_UBUNTU_OTHER; | |
| 206 const std::string version = distro.substr(strlen(ubuntu), 5); | |
| 207 if (version == "14.04") { | |
| 208 distro_result = UMA_LINUX_DISTRO_UBUNTU_14_04; | |
| 209 } else if (version == "16.04") { | |
| 210 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_04; | |
| 211 } else if (version == "16.10") { | |
| 212 distro_result = UMA_LINUX_DISTRO_UBUNTU_16_10; | |
| 213 } else if (version == "17.04") { | |
| 214 distro_result = UMA_LINUX_DISTRO_UBUNTU_17_04; | |
| 215 } | |
| 216 } else if (distro.compare(0, strlen(openSuse), openSuse) == 0) { | |
| 217 distro_result = UMA_LINUX_DISTRO_OPENSUSE_OTHER; | |
| 218 const std::string version = distro.substr(strlen(openSuse)); | |
| 219 if (version == "Leap 42.2") { | |
| 220 distro_result = UMA_LINUX_DISTRO_OPENSUSE_LEAP_42_2; | |
| 221 } | |
| 222 } else if (distro.compare(0, strlen(debian), debian) == 0) { | |
| 223 // Debian uses point releases for the same version, so we need to do | |
| 224 // prefix matching. | |
| 225 distro_result = UMA_LINUX_DISTRO_DEBIAN_OTHER; | |
| 226 const std::string version = distro.substr(strlen(debian)); | |
| 227 if (version[0] == '8') { | |
| 228 distro_result = UMA_LINUX_DISTRO_DEBIAN_8; | |
| 229 } | |
| 230 } else if (distro.compare(0, strlen(fedora), fedora) == 0) { | |
| 231 distro_result = UMA_LINUX_DISTRO_FEDORA_OTHER; | |
| 232 const std::string version = distro.substr(strlen(debian)); | |
| 233 if (version == "24") { | |
| 234 distro_result = UMA_LINUX_DISTRO_FEDORA_24; | |
| 235 } else if (distro == "25") { | |
| 236 distro_result = UMA_LINUX_DISTRO_FEDORA_25; | |
| 237 } | |
| 238 } | |
| 239 | |
| 240 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.Distro", distro_result); | |
|
Tom Anderson
2017/05/23 22:12:13
UMA_HISTOGRAM_SPARSE_SLOWLY => UMA_HISTOGRAM_ENUME
timbrown
2017/05/24 00:40:55
rkaplow: Do you agree? From the comments here http
| |
| 241 #endif | |
| 242 } | |
| 243 | |
| 175 void RecordLinuxGlibcVersion() { | 244 void RecordLinuxGlibcVersion() { |
| 176 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 245 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 177 base::Version version(gnu_get_libc_version()); | 246 base::Version version(gnu_get_libc_version()); |
| 178 | 247 |
| 179 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; | 248 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; |
| 180 if (version.IsValid() && version.components().size() == 2) { | 249 if (version.IsValid() && version.components().size() == 2) { |
| 181 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; | 250 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; |
| 182 uint32_t glibc_major_version = version.components()[0]; | 251 uint32_t glibc_major_version = version.components()[0]; |
| 183 uint32_t glibc_minor_version = version.components()[1]; | 252 uint32_t glibc_minor_version = version.components()[1]; |
| 184 if (glibc_major_version == 2) { | 253 if (glibc_major_version == 2) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 #if defined(__clang__) | 439 #if defined(__clang__) |
| 371 "Enabled" | 440 "Enabled" |
| 372 #else | 441 #else |
| 373 "Disabled" | 442 "Disabled" |
| 374 #endif | 443 #endif |
| 375 ); | 444 ); |
| 376 #endif | 445 #endif |
| 377 } | 446 } |
| 378 | 447 |
| 379 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { | 448 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { |
| 449 RecordLinuxDistro(); | |
| 380 RecordLinuxGlibcVersion(); | 450 RecordLinuxGlibcVersion(); |
| 381 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 451 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 382 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", | 452 UMA_HISTOGRAM_ENUMERATION("Linux.WindowManager", |
| 383 GetLinuxWindowManager(), | 453 GetLinuxWindowManager(), |
| 384 UMA_LINUX_WINDOW_MANAGER_COUNT); | 454 UMA_LINUX_WINDOW_MANAGER_COUNT); |
| 385 #endif | 455 #endif |
| 386 | 456 |
| 387 #if defined(USE_OZONE) || defined(USE_X11) | 457 #if defined(USE_OZONE) || defined(USE_X11) |
| 388 // The touch event state for X11 and Ozone based event sub-systems are based | 458 // 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 | 459 // on device scans that happen asynchronously. So we may need to attach an |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 } | 517 } |
| 448 } | 518 } |
| 449 | 519 |
| 450 namespace chrome { | 520 namespace chrome { |
| 451 | 521 |
| 452 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 522 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
| 453 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 523 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
| 454 } | 524 } |
| 455 | 525 |
| 456 } // namespace chrome | 526 } // namespace chrome |
| OLD | NEW |