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> | |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/cpu.h" | 12 #include "base/cpu.h" |
12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
14 #include "base/time.h" | 15 #include "base/time.h" |
15 #include "chrome/browser/about_flags.h" | 16 #include "chrome/browser/about_flags.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chrome_browser_main.h" | 18 #include "chrome/browser/chrome_browser_main.h" |
18 #include "chrome/browser/shell_integration.h" | 19 #include "chrome/browser/shell_integration.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 #include "ui/base/touch/touch_device.h" | 21 #include "ui/base/touch/touch_device.h" |
21 #include "ui/base/ui_base_switches.h" | 22 #include "ui/base/ui_base_switches.h" |
22 | 23 |
24 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
25 #include <gnu/libc-version.h> | |
26 | |
27 #include "base/strings/string_number_conversions.h" | |
28 #include "base/strings/string_split.h" | |
29 #endif | |
30 | |
23 namespace { | 31 namespace { |
24 | 32 |
33 enum UMALinuxGlibcVersion { | |
34 UMA_LINUX_GLIBC_NOT_PARSEABLE, | |
35 UMA_LINUX_GLIBC_UNKNOWN, | |
36 UMA_LINUX_GLIBC_2_11 = 11, | |
jar (doing other things)
2013/04/14 16:14:15
See note below about how to avoid having to list t
| |
37 UMA_LINUX_GLIBC_2_12 = 12, | |
38 UMA_LINUX_GLIBC_2_13 = 13, | |
39 UMA_LINUX_GLIBC_2_14 = 14, | |
40 UMA_LINUX_GLIBC_2_15 = 15, | |
41 UMA_LINUX_GLIBC_2_16 = 16, | |
42 UMA_LINUX_GLIBC_2_17 = 17, | |
43 UMA_LINUX_GLIBC_2_18 = 18, | |
44 UMA_LINUX_GLIBC_2_19 = 19, | |
45 // NOTE: Add new version above this line and update the enum list in | |
46 // tools/histograms/histograms.xml accordingly. | |
47 UMA_LINUX_GLIBC_VERSION_COUNT | |
48 }; | |
49 | |
25 enum UMATouchEventsState { | 50 enum UMATouchEventsState { |
26 UMA_TOUCH_EVENTS_ENABLED, | 51 UMA_TOUCH_EVENTS_ENABLED, |
27 UMA_TOUCH_EVENTS_AUTO_ENABLED, | 52 UMA_TOUCH_EVENTS_AUTO_ENABLED, |
28 UMA_TOUCH_EVENTS_AUTO_DISABLED, | 53 UMA_TOUCH_EVENTS_AUTO_DISABLED, |
29 UMA_TOUCH_EVENTS_DISABLED, | 54 UMA_TOUCH_EVENTS_DISABLED, |
30 // NOTE: Add states only immediately above this line. Make sure to | 55 // NOTE: Add states only immediately above this line. Make sure to |
31 // update the enum list in tools/histograms/histograms.xml accordingly. | 56 // update the enum list in tools/histograms/histograms.xml accordingly. |
32 UMA_TOUCH_EVENTS_STATE_COUNT | 57 UMA_TOUCH_EVENTS_STATE_COUNT |
33 }; | 58 }; |
34 | 59 |
35 void LogIntelMicroArchitecture() { | 60 void RecordIntelMicroArchitecture() { |
36 #if defined(ARCH_CPU_X86_FAMILY) | 61 #if defined(ARCH_CPU_X86_FAMILY) |
37 base::CPU cpu; | 62 base::CPU cpu; |
38 base::CPU::IntelMicroArchitecture arch = cpu.GetIntelMicroArchitecture(); | 63 base::CPU::IntelMicroArchitecture arch = cpu.GetIntelMicroArchitecture(); |
39 UMA_HISTOGRAM_ENUMERATION("Platform.IntelMaxMicroArchitecture", arch, | 64 UMA_HISTOGRAM_ENUMERATION("Platform.IntelMaxMicroArchitecture", arch, |
40 base::CPU::MAX_INTEL_MICRO_ARCHITECTURE); | 65 base::CPU::MAX_INTEL_MICRO_ARCHITECTURE); |
41 #endif // defined(ARCH_CPU_X86_FAMILY) | 66 #endif // defined(ARCH_CPU_X86_FAMILY) |
42 } | 67 } |
43 | 68 |
44 void RecordDefaultBrowserUMAStat() { | 69 void RecordDefaultBrowserUMAStat() { |
45 // Record whether Chrome is the default browser or not. | 70 // Record whether Chrome is the default browser or not. |
46 ShellIntegration::DefaultWebClientState default_state = | 71 ShellIntegration::DefaultWebClientState default_state = |
47 ShellIntegration::GetDefaultBrowser(); | 72 ShellIntegration::GetDefaultBrowser(); |
48 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, | 73 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.State", default_state, |
49 ShellIntegration::NUM_DEFAULT_STATES); | 74 ShellIntegration::NUM_DEFAULT_STATES); |
50 } | 75 } |
51 | 76 |
77 void RecordLinuxGlibcVersion() { | |
78 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
79 std::string glibc_version_string(gnu_get_libc_version()); | |
80 std::vector<std::string> split_glibc_version; | |
81 base::SplitString(glibc_version_string, '.', &split_glibc_version); | |
82 | |
83 UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE; | |
84 unsigned glibc_major_version = 0; | |
85 unsigned glibc_minor_version = 0; | |
86 if (split_glibc_version.size() == 2 && | |
87 base::StringToUint(split_glibc_version[0], &glibc_major_version) && | |
88 base::StringToUint(split_glibc_version[1], &glibc_minor_version)) { | |
89 if (glibc_major_version == 2 && | |
90 (glibc_minor_version >= 11 && glibc_minor_version <= 19)) { | |
91 // |glibc_minor_version| values lines up with the enum values. | |
92 glibc_version_result = | |
93 static_cast<UMALinuxGlibcVersion>(glibc_minor_version); | |
jar (doing other things)
2013/04/14 16:14:15
I think this might read better if you have the adj
| |
94 } else { | |
95 glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN; | |
96 } | |
97 } | |
98 UMA_HISTOGRAM_ENUMERATION("Linux.GlibcVersion", glibc_version_result, | |
99 UMA_LINUX_GLIBC_VERSION_COUNT); | |
100 #endif | |
101 } | |
102 | |
52 void RecordTouchEventState() { | 103 void RecordTouchEventState() { |
53 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 104 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
54 const std::string touch_enabled_switch = | 105 const std::string touch_enabled_switch = |
55 command_line.HasSwitch(switches::kTouchEvents) ? | 106 command_line.HasSwitch(switches::kTouchEvents) ? |
56 command_line.GetSwitchValueASCII(switches::kTouchEvents) : | 107 command_line.GetSwitchValueASCII(switches::kTouchEvents) : |
57 switches::kTouchEventsAuto; | 108 switches::kTouchEventsAuto; |
58 | 109 |
59 UMATouchEventsState state; | 110 UMATouchEventsState state; |
60 if (touch_enabled_switch.empty() || | 111 if (touch_enabled_switch.empty() || |
61 touch_enabled_switch == switches::kTouchEventsEnabled) { | 112 touch_enabled_switch == switches::kTouchEventsEnabled) { |
(...skipping 14 matching lines...) Expand all Loading... | |
76 | 127 |
77 } // namespace | 128 } // namespace |
78 | 129 |
79 ChromeBrowserMainExtraPartsMetrics::ChromeBrowserMainExtraPartsMetrics() { | 130 ChromeBrowserMainExtraPartsMetrics::ChromeBrowserMainExtraPartsMetrics() { |
80 } | 131 } |
81 | 132 |
82 ChromeBrowserMainExtraPartsMetrics::~ChromeBrowserMainExtraPartsMetrics() { | 133 ChromeBrowserMainExtraPartsMetrics::~ChromeBrowserMainExtraPartsMetrics() { |
83 } | 134 } |
84 | 135 |
85 void ChromeBrowserMainExtraPartsMetrics::PreProfileInit() { | 136 void ChromeBrowserMainExtraPartsMetrics::PreProfileInit() { |
86 LogIntelMicroArchitecture(); | 137 RecordIntelMicroArchitecture(); |
87 } | 138 } |
88 | 139 |
89 void ChromeBrowserMainExtraPartsMetrics::PreBrowserStart() { | 140 void ChromeBrowserMainExtraPartsMetrics::PreBrowserStart() { |
90 about_flags::RecordUMAStatistics(g_browser_process->local_state()); | 141 about_flags::RecordUMAStatistics(g_browser_process->local_state()); |
91 | 142 |
92 // Querying the default browser state can be slow, do it in the background. | 143 // Querying the default browser state can be slow, do it in the background. |
93 content::BrowserThread::GetBlockingPool()->PostDelayedTask( | 144 content::BrowserThread::GetBlockingPool()->PostDelayedTask( |
94 FROM_HERE, | 145 FROM_HERE, |
95 base::Bind(&RecordDefaultBrowserUMAStat), | 146 base::Bind(&RecordDefaultBrowserUMAStat), |
96 base::TimeDelta::FromSeconds(45)); | 147 base::TimeDelta::FromSeconds(45)); |
97 } | 148 } |
98 | 149 |
99 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { | 150 void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { |
151 RecordLinuxGlibcVersion(); | |
100 RecordTouchEventState(); | 152 RecordTouchEventState(); |
101 } | 153 } |
102 | 154 |
103 namespace chrome { | 155 namespace chrome { |
104 | 156 |
105 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 157 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
106 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 158 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
107 } | 159 } |
108 | 160 |
109 } // namespace chrome | 161 } // namespace chrome |
OLD | NEW |