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

Side by Side Diff: base/sys_info_chromeos.cc

Issue 467053: Fix test failure: SysInfoTest.GoogleChromeOSVersionNumbersFirst (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years 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 | base/sys_info_unittest.cc » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/sys_info.h" 5 #include "base/sys_info.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
(...skipping 25 matching lines...) Expand all
36 // static 36 // static
37 std::string SysInfo::GetLinuxStandardBaseVersionKey() { 37 std::string SysInfo::GetLinuxStandardBaseVersionKey() {
38 return std::string(kLinuxStandardBaseVersionKey); 38 return std::string(kLinuxStandardBaseVersionKey);
39 } 39 }
40 40
41 // static 41 // static
42 void SysInfo::ParseLsbRelease(const std::string& lsb_release, 42 void SysInfo::ParseLsbRelease(const std::string& lsb_release,
43 int32 *major_version, 43 int32 *major_version,
44 int32 *minor_version, 44 int32 *minor_version,
45 int32 *bugfix_version) { 45 int32 *bugfix_version) {
46 size_t version_key_index = 46 size_t version_key_index = lsb_release.find(kLinuxStandardBaseVersionKey);
47 lsb_release.find(kLinuxStandardBaseVersionKey,
48 arraysize(kLinuxStandardBaseVersionKey) - 1);
49 if (std::string::npos == version_key_index) { 47 if (std::string::npos == version_key_index) {
50 return; 48 return;
51 } 49 }
52 size_t start_index = lsb_release.find_first_of('=', version_key_index); 50 size_t start_index = lsb_release.find_first_of('=', version_key_index);
53 start_index++; // Move past '='. 51 start_index++; // Move past '='.
54 size_t length = lsb_release.find_first_of('\n', start_index) - start_index; 52 size_t length = lsb_release.find_first_of('\n', start_index) - start_index;
55 std::string version = lsb_release.substr(start_index, length); 53 std::string version = lsb_release.substr(start_index, length);
56 StringTokenizer tokenizer(version, "."); 54 StringTokenizer tokenizer(version, ".");
57 for (int i = 0; i < 3 && tokenizer.GetNext(); i++) { 55 for (int i = 0; i < 3 && tokenizer.GetNext(); i++) {
58 if (0 == i) { 56 if (0 == i) {
59 *major_version = StringToInt(tokenizer.token()); 57 *major_version = StringToInt(tokenizer.token());
60 *minor_version = *bugfix_version = 0; 58 *minor_version = *bugfix_version = 0;
61 } else if (1 == i) { 59 } else if (1 == i) {
62 *minor_version = StringToInt(tokenizer.token()); 60 *minor_version = StringToInt(tokenizer.token());
63 } else { // 2 == i 61 } else { // 2 == i
64 *bugfix_version = StringToInt(tokenizer.token()); 62 *bugfix_version = StringToInt(tokenizer.token());
65 } 63 }
66 } 64 }
67 } 65 }
68 66
69 } // namespace base 67 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/sys_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698