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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
===================================================================
--- chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc (revision 194467)
+++ chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc (working copy)
@@ -5,7 +5,6 @@
#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
#include <string>
-#include <vector>
#include "base/bind.h"
#include "base/command_line.h"
@@ -24,8 +23,7 @@
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include <gnu/libc-version.h>
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_split.h"
+#include "base/version.h"
#endif
namespace {
@@ -69,23 +67,19 @@
void RecordLinuxGlibcVersion() {
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- std::string glibc_version_string(gnu_get_libc_version());
- std::vector<std::string> split_glibc_version;
- base::SplitString(glibc_version_string, '.', &split_glibc_version);
+ Version version(gnu_get_libc_version());
UMALinuxGlibcVersion glibc_version_result = UMA_LINUX_GLIBC_NOT_PARSEABLE;
- unsigned glibc_major_version = 0;
- unsigned glibc_minor_version = 0;
- if (split_glibc_version.size() == 2 &&
- base::StringToUint(split_glibc_version[0], &glibc_major_version) &&
- base::StringToUint(split_glibc_version[1], &glibc_minor_version)) {
+ if (version.IsValid() && version.components().size() == 2) {
glibc_version_result = UMA_LINUX_GLIBC_UNKNOWN;
+ 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
+ uint16 glibc_minor_version = version.components()[1];
if (glibc_major_version == 2) {
// A constant to translate glibc 2.x minor versions to their
// equivalent UMALinuxGlibcVersion values.
- const unsigned kGlibcMinorVersionTranslationOffset =
+ const uint16 kGlibcMinorVersionTranslationOffset =
jar (doing other things) 2013/04/16 23:42:52 nit: not a big deal... but why mess with uint16?
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
- unsigned translated_glibc_minor_version =
+ uint16 translated_glibc_minor_version =
glibc_minor_version - kGlibcMinorVersionTranslationOffset;
if (translated_glibc_minor_version >= UMA_LINUX_GLIBC_2_11 &&
translated_glibc_minor_version <= UMA_LINUX_GLIBC_2_19) {
« 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