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 #include <vector> | |
9 | 8 |
10 #include "base/bind.h" | 9 #include "base/bind.h" |
11 #include "base/command_line.h" | 10 #include "base/command_line.h" |
12 #include "base/cpu.h" | 11 #include "base/cpu.h" |
13 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
14 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
15 #include "base/time.h" | 14 #include "base/time.h" |
16 #include "chrome/browser/about_flags.h" | 15 #include "chrome/browser/about_flags.h" |
17 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/chrome_browser_main.h" | 17 #include "chrome/browser/chrome_browser_main.h" |
19 #include "chrome/browser/shell_integration.h" | 18 #include "chrome/browser/shell_integration.h" |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
21 #include "ui/base/touch/touch_device.h" | 20 #include "ui/base/touch/touch_device.h" |
22 #include "ui/base/ui_base_switches.h" | 21 #include "ui/base/ui_base_switches.h" |
23 | 22 |
24 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 23 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
25 #include <gnu/libc-version.h> | 24 #include <gnu/libc-version.h> |
26 | 25 |
27 #include "base/strings/string_number_conversions.h" | 26 #include "base/version.h" |
28 #include "base/strings/string_split.h" | |
29 #endif | 27 #endif |
30 | 28 |
31 namespace { | 29 namespace { |
32 | 30 |
33 enum UMALinuxGlibcVersion { | 31 enum UMALinuxGlibcVersion { |
34 UMA_LINUX_GLIBC_NOT_PARSEABLE, | 32 UMA_LINUX_GLIBC_NOT_PARSEABLE, |
35 UMA_LINUX_GLIBC_UNKNOWN, | 33 UMA_LINUX_GLIBC_UNKNOWN, |
36 UMA_LINUX_GLIBC_2_11, | 34 UMA_LINUX_GLIBC_2_11, |
37 UMA_LINUX_GLIBC_2_19 = UMA_LINUX_GLIBC_2_11 + 8, | 35 UMA_LINUX_GLIBC_2_19 = UMA_LINUX_GLIBC_2_11 + 8, |
38 // NOTE: Add new version above this line and update the enum list in | 36 // NOTE: Add new version above this line and update the enum list in |
(...skipping 23 matching lines...) Expand all Loading... | |
62 void RecordDefaultBrowserUMAStat() { | 60 void RecordDefaultBrowserUMAStat() { |
63 // Record whether Chrome is the default browser or not. | 61 // Record whether Chrome is the default browser or not. |
64 ShellIntegration::DefaultWebClientState default_state = | 62 ShellIntegration::DefaultWebClientState default_state = |
65 ShellIntegration::GetDefaultBrowser(); | 63 ShellIntegration::GetDefaultBrowser(); |
66 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, | 64 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, |
67 ShellIntegration::NUM_DEFAULT_STATES); | 65 ShellIntegration::NUM_DEFAULT_STATES); |
68 } | 66 } |
69 | 67 |
70 void RecordLinuxGlibcVersion() { | 68 void RecordLinuxGlibcVersion() { |
71 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 69 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
72 std::string glibc_version_string(gnu_get_libc_version()); | 70 Version version(gnu_get_libc_version()); |
73 std::vector<std::string> split_glibc_version; | |
74 base::SplitString(glibc_version_string, '.', &split_glibc_version); | |
75 | 71 |
76 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; | 72 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; |
77 unsigned glibc_major_version = 0; | 73 if (version.IsValid() && version.components().size() == 2) { |
78 unsigned glibc_minor_version = 0; | |
79 if (split_glibc_version.size() == 2 && | |
80 base::StringToUint(split_glibc_version[0], &glibc_major_version) && | |
81 base::StringToUint(split_glibc_version[1], &glibc_minor_version)) { | |
82 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; | 74 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; |
75 uint16 glibc_major_version = version.components()[0]; | |
xhwang
2013/04/16 22:51:38
here and below, just use int?
Lei Zhang
2013/04/16 23:20:23
|version.components()| returns a vector of uint16s
| |
76 uint16 glibc_minor_version = version.components()[1]; | |
83 if (glibc_major_version == 2) { | 77 if (glibc_major_version == 2) { |
84 // A constant to translate glibc 2.x minor versions to their | 78 // A constant to translate glibc 2.x minor versions to their |
85 // equivalent UMALinuxGlibcVersion values. | 79 // equivalent UMALinuxGlibcVersion values. |
86 const unsigned kGlibcMinorVersionTranslationOffset = | 80 const uint16 kGlibcMinorVersionTranslationOffset = |
jar (doing other things)
2013/04/16 23:42:52
nit: not a big deal... but why mess with uint16?
| |
87 11 - UMA_LINUX_GLIBC_2_11; | 81 11 - UMA_LINUX_GLIBC_2_11; |
xhwang
2013/04/16 22:51:38
wondering if it'll make our life easier if we just
Lei Zhang
2013/04/16 23:20:23
jar@ preferred if the enum did not have any gaps.
jar (doing other things)
2013/04/16 23:42:52
... and also... we'll eventually support major ver
xhwang
2013/04/17 00:05:02
sg, I just hate the number "11" here :) But not a
| |
88 unsigned translated_glibc_minor_version = | 82 uint16 translated_glibc_minor_version = |
89 glibc_minor_version - kGlibcMinorVersionTranslationOffset; | 83 glibc_minor_version - kGlibcMinorVersionTranslationOffset; |
90 if (translated_glibc_minor_version >= UMA_LINUX_GLIBC_2_11 && | 84 if (translated_glibc_minor_version >= UMA_LINUX_GLIBC_2_11 && |
91 translated_glibc_minor_version <= UMA_LINUX_GLIBC_2_19) { | 85 translated_glibc_minor_version <= UMA_LINUX_GLIBC_2_19) { |
92 glibc_version_result = | 86 glibc_version_result = |
93 static_cast<UMALinuxGlibcVersion>(translated_glibc_minor_version); | 87 static_cast<UMALinuxGlibcVersion>(translated_glibc_minor_version); |
94 } | 88 } |
95 } | 89 } |
96 } | 90 } |
97 UMA_HISTOGRAM_ENUMERATION("Linux.GlibcVersion", glibc_version_result, | 91 UMA_HISTOGRAM_ENUMERATION("Linux.GlibcVersion", glibc_version_result, |
98 UMA_LINUX_GLIBC_VERSION_COUNT); | 92 UMA_LINUX_GLIBC_VERSION_COUNT); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 RecordTouchEventState(); | 145 RecordTouchEventState(); |
152 } | 146 } |
153 | 147 |
154 namespace chrome { | 148 namespace chrome { |
155 | 149 |
156 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 150 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
157 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 151 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
158 } | 152 } |
159 | 153 |
160 } // namespace chrome | 154 } // namespace chrome |
OLD | NEW |