Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc

Issue 13888010: Improve the code added in r194423 by using the Version class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: int Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 int glibc_major_version = version.components()[0];
76 int 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 int kGlibcMinorVersionTranslationOffset = 11 - UMA_LINUX_GLIBC_2_11;
87 11 - UMA_LINUX_GLIBC_2_11; 81 int translated_glibc_minor_version =
88 unsigned translated_glibc_minor_version =
89 glibc_minor_version - kGlibcMinorVersionTranslationOffset; 82 glibc_minor_version - kGlibcMinorVersionTranslationOffset;
90 if (translated_glibc_minor_version >= UMA_LINUX_GLIBC_2_11 && 83 if (translated_glibc_minor_version >= UMA_LINUX_GLIBC_2_11 &&
91 translated_glibc_minor_version <= UMA_LINUX_GLIBC_2_19) { 84 translated_glibc_minor_version <= UMA_LINUX_GLIBC_2_19) {
92 glibc_version_result = 85 glibc_version_result =
93 static_cast<UMALinuxGlibcVersion>(translated_glibc_minor_version); 86 static_cast<UMALinuxGlibcVersion>(translated_glibc_minor_version);
94 } 87 }
95 } 88 }
96 } 89 }
97 UMA_HISTOGRAM_ENUMERATION("Linux.GlibcVersion", glibc_version_result, 90 UMA_HISTOGRAM_ENUMERATION("Linux.GlibcVersion", glibc_version_result,
98 UMA_LINUX_GLIBC_VERSION_COUNT); 91 UMA_LINUX_GLIBC_VERSION_COUNT);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 RecordTouchEventState(); 144 RecordTouchEventState();
152 } 145 }
153 146
154 namespace chrome { 147 namespace chrome {
155 148
156 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { 149 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) {
157 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); 150 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics());
158 } 151 }
159 152
160 } // namespace chrome 153 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698