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

Side by Side Diff: base/sys_info_chromeos.cc

Issue 6816024: Revert 80819 due to failed tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « base/sys_info.h ('k') | base/sys_info_mac.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 25 matching lines...) Expand all
36 int32 major_version; 36 int32 major_version;
37 int32 minor_version; 37 int32 minor_version;
38 int32 bugfix_version; 38 int32 bugfix_version;
39 bool parsed; 39 bool parsed;
40 }; 40 };
41 41
42 static base::LazyInstance<ChromeOSVersionNumbers> 42 static base::LazyInstance<ChromeOSVersionNumbers>
43 g_chrome_os_version_numbers(base::LINKER_INITIALIZED); 43 g_chrome_os_version_numbers(base::LINKER_INITIALIZED);
44 44
45 // static 45 // static
46 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, 46 void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
47 int32* minor_version, 47 int32 *minor_version,
48 int32* bugfix_version) { 48 int32 *bugfix_version) {
49 if (!g_chrome_os_version_numbers.Get().parsed) { 49 if (!g_chrome_os_version_numbers.Get().parsed) {
50 // The other implementations of SysInfo don't block on the disk. 50 // The other implementations of SysInfo don't block on the disk.
51 // See http://code.google.com/p/chromium/issues/detail?id=60394 51 // See http://code.google.com/p/chromium/issues/detail?id=60394
52 // Perhaps the caller ought to cache this? 52 // Perhaps the caller ought to cache this?
53 // Temporary allowing while we work the bug out. 53 // Temporary allowing while we work the bug out.
54 base::ThreadRestrictions::ScopedAllowIO allow_io; 54 base::ThreadRestrictions::ScopedAllowIO allow_io;
55 55
56 FilePath path(kLinuxStandardBaseReleaseFile); 56 FilePath path(kLinuxStandardBaseReleaseFile);
57 std::string contents; 57 std::string contents;
58 if (file_util::ReadFileToString(path, &contents)) { 58 if (file_util::ReadFileToString(path, &contents)) {
59 g_chrome_os_version_numbers.Get().parsed = true; 59 g_chrome_os_version_numbers.Get().parsed = true;
60 ParseLsbRelease(contents, 60 ParseLsbRelease(contents,
61 &(g_chrome_os_version_numbers.Get().major_version), 61 &(g_chrome_os_version_numbers.Get().major_version),
62 &(g_chrome_os_version_numbers.Get().minor_version), 62 &(g_chrome_os_version_numbers.Get().minor_version),
63 &(g_chrome_os_version_numbers.Get().bugfix_version)); 63 &(g_chrome_os_version_numbers.Get().bugfix_version));
64 } 64 }
65 } 65 }
66 *major_version = g_chrome_os_version_numbers.Get().major_version; 66 *major_version = g_chrome_os_version_numbers.Get().major_version;
67 *minor_version = g_chrome_os_version_numbers.Get().minor_version; 67 *minor_version = g_chrome_os_version_numbers.Get().minor_version;
68 *bugfix_version = g_chrome_os_version_numbers.Get().bugfix_version; 68 *bugfix_version = g_chrome_os_version_numbers.Get().bugfix_version;
69 } 69 }
70 70
71 // static 71 // static
72 std::string SysInfo::GetLinuxStandardBaseVersionKey() { 72 std::string SysInfo::GetLinuxStandardBaseVersionKey() {
73 return std::string(kLinuxStandardBaseVersionKeys[0]); 73 return std::string(kLinuxStandardBaseVersionKeys[0]);
74 } 74 }
75 75
76 // static 76 // static
77 void SysInfo::ParseLsbRelease(const std::string& lsb_release, 77 void SysInfo::ParseLsbRelease(const std::string& lsb_release,
78 int32* major_version, 78 int32 *major_version,
79 int32* minor_version, 79 int32 *minor_version,
80 int32* bugfix_version) { 80 int32 *bugfix_version) {
81 size_t version_key_index = std::string::npos; 81 size_t version_key_index = std::string::npos;
82 for (int i = 0; kLinuxStandardBaseVersionKeys[i] != NULL; ++i) { 82 for (int i = 0; kLinuxStandardBaseVersionKeys[i] != NULL; ++i) {
83 version_key_index = lsb_release.find(kLinuxStandardBaseVersionKeys[i]); 83 version_key_index = lsb_release.find(kLinuxStandardBaseVersionKeys[i]);
84 if (std::string::npos != version_key_index) { 84 if (std::string::npos != version_key_index) {
85 break; 85 break;
86 } 86 }
87 } 87 }
88 if (std::string::npos == version_key_index) { 88 if (std::string::npos == version_key_index) {
89 return; 89 return;
90 } 90 }
(...skipping 15 matching lines...) Expand all
106 minor_version); 106 minor_version);
107 } else { // 2 == i 107 } else { // 2 == i
108 StringToInt(tokenizer.token_begin(), 108 StringToInt(tokenizer.token_begin(),
109 tokenizer.token_end(), 109 tokenizer.token_end(),
110 bugfix_version); 110 bugfix_version);
111 } 111 }
112 } 112 }
113 } 113 }
114 114
115 } // namespace base 115 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698