OLD | NEW |
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 "chrome/browser/chromeos/version_loader.h" | 5 #include "chrome/browser/chromeos/version_loader.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/stringprintf.h" |
14 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
15 #include "base/time.h" | 16 #include "base/time.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
18 | 19 |
19 namespace chromeos { | 20 namespace chromeos { |
20 | 21 |
21 // File to look for version number in. | 22 // File to look for version number in. |
22 static const char kPathVersion[] = "/etc/lsb-release"; | 23 static const char kPathVersion[] = "/etc/lsb-release"; |
23 | 24 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 162 } |
162 } | 163 } |
163 } | 164 } |
164 } | 165 } |
165 | 166 |
166 if (format == VERSION_SHORT_WITH_DATE) { | 167 if (format == VERSION_SHORT_WITH_DATE) { |
167 base::PlatformFileInfo fileinfo; | 168 base::PlatformFileInfo fileinfo; |
168 if (file_util::GetFileInfo(file_path, &fileinfo)) { | 169 if (file_util::GetFileInfo(file_path, &fileinfo)) { |
169 base::Time::Exploded ctime; | 170 base::Time::Exploded ctime; |
170 fileinfo.creation_time.UTCExplode(&ctime); | 171 fileinfo.creation_time.UTCExplode(&ctime); |
171 version += StringPrintf("-%02u.%02u.%02u", | 172 version += base::StringPrintf("-%02u.%02u.%02u", |
172 ctime.year % 100, | 173 ctime.year % 100, |
173 ctime.month, | 174 ctime.month, |
174 ctime.day_of_month); | 175 ctime.day_of_month); |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 request->ForwardResult(GetVersionCallback::TupleType(request->handle(), | 179 request->ForwardResult(GetVersionCallback::TupleType(request->handle(), |
179 version)); | 180 version)); |
180 } | 181 } |
181 | 182 |
182 void VersionLoader::Backend::GetFirmware( | 183 void VersionLoader::Backend::GetFirmware( |
183 scoped_refptr<GetFirmwareRequest> request) { | 184 scoped_refptr<GetFirmwareRequest> request) { |
184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
185 if (request->canceled()) | 186 if (request->canceled()) |
186 return; | 187 return; |
187 | 188 |
188 std::string firmware; | 189 std::string firmware; |
189 std::string contents; | 190 std::string contents; |
190 const FilePath file_path(kPathFirmware); | 191 const FilePath file_path(kPathFirmware); |
191 if (file_util::ReadFileToString(file_path, &contents)) { | 192 if (file_util::ReadFileToString(file_path, &contents)) { |
192 firmware = ParseFirmware(contents); | 193 firmware = ParseFirmware(contents); |
193 } | 194 } |
194 | 195 |
195 request->ForwardResult(GetFirmwareCallback::TupleType(request->handle(), | 196 request->ForwardResult(GetFirmwareCallback::TupleType(request->handle(), |
196 firmware)); | 197 firmware)); |
197 } | 198 } |
198 | 199 |
199 } // namespace chromeos | 200 } // namespace chromeos |
OLD | NEW |