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

Side by Side Diff: chrome/browser/chromeos/version_loader.cc

Issue 8113025: base::Bind: More converts, mostly in WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 9 years, 2 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 | « chrome/browser/chromeos/version_loader.h ('k') | chrome/browser/ui/webui/bug_report_ui.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 "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"
(...skipping 26 matching lines...) Expand all
37 37
38 // Same but for short version (x.x.xx.x). 38 // Same but for short version (x.x.xx.x).
39 // static 39 // static
40 const char VersionLoader::kVersionPrefix[] = "CHROMEOS_RELEASE_VERSION="; 40 const char VersionLoader::kVersionPrefix[] = "CHROMEOS_RELEASE_VERSION=";
41 41
42 // Beginning of line we look for that gives the firmware version. 42 // Beginning of line we look for that gives the firmware version.
43 const char VersionLoader::kFirmwarePrefix[] = "version"; 43 const char VersionLoader::kFirmwarePrefix[] = "version";
44 44
45 VersionLoader::Handle VersionLoader::GetVersion( 45 VersionLoader::Handle VersionLoader::GetVersion(
46 CancelableRequestConsumerBase* consumer, 46 CancelableRequestConsumerBase* consumer,
47 VersionLoader::GetVersionCallback* callback, 47 const VersionLoader::GetVersionCallback& callback,
48 VersionFormat format) { 48 VersionFormat format) {
49 if (!g_browser_process->file_thread()) { 49 if (!g_browser_process->file_thread()) {
50 // This should only happen if Chrome is shutting down, so we don't do 50 // This should only happen if Chrome is shutting down, so we don't do
51 // anything. 51 // anything.
52 return 0; 52 return 0;
53 } 53 }
54 54
55 scoped_refptr<GetVersionRequest> request(new GetVersionRequest(callback)); 55 scoped_refptr<GetVersionRequest> request(new GetVersionRequest(callback));
56 AddRequest(request, consumer); 56 AddRequest(request, consumer);
57 57
58 g_browser_process->file_thread()->message_loop()->PostTask( 58 g_browser_process->file_thread()->message_loop()->PostTask(
59 FROM_HERE, 59 FROM_HERE,
60 NewRunnableMethod(backend_.get(), &Backend::GetVersion, request, format)); 60 NewRunnableMethod(backend_.get(), &Backend::GetVersion, request, format));
61 return request->handle(); 61 return request->handle();
62 } 62 }
63 63
64 VersionLoader::Handle VersionLoader::GetFirmware( 64 VersionLoader::Handle VersionLoader::GetFirmware(
65 CancelableRequestConsumerBase* consumer, 65 CancelableRequestConsumerBase* consumer,
66 VersionLoader::GetFirmwareCallback* callback) { 66 const VersionLoader::GetFirmwareCallback& callback) {
67 if (!g_browser_process->file_thread()) { 67 if (!g_browser_process->file_thread()) {
68 // This should only happen if Chrome is shutting down, so we don't do 68 // This should only happen if Chrome is shutting down, so we don't do
69 // anything. 69 // anything.
70 return 0; 70 return 0;
71 } 71 }
72 72
73 scoped_refptr<GetFirmwareRequest> request(new GetFirmwareRequest(callback)); 73 scoped_refptr<GetFirmwareRequest> request(new GetFirmwareRequest(callback));
74 AddRequest(request, consumer); 74 AddRequest(request, consumer);
75 75
76 g_browser_process->file_thread()->message_loop()->PostTask( 76 g_browser_process->file_thread()->message_loop()->PostTask(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (file_util::GetFileInfo(file_path, &fileinfo)) { 147 if (file_util::GetFileInfo(file_path, &fileinfo)) {
148 base::Time::Exploded ctime; 148 base::Time::Exploded ctime;
149 fileinfo.creation_time.UTCExplode(&ctime); 149 fileinfo.creation_time.UTCExplode(&ctime);
150 version += base::StringPrintf("-%02u.%02u.%02u", 150 version += base::StringPrintf("-%02u.%02u.%02u",
151 ctime.year % 100, 151 ctime.year % 100,
152 ctime.month, 152 ctime.month,
153 ctime.day_of_month); 153 ctime.day_of_month);
154 } 154 }
155 } 155 }
156 156
157 request->ForwardResult(GetVersionCallback::TupleType(request->handle(), 157 request->ForwardResult(request->handle(), version);
158 version));
159 } 158 }
160 159
161 void VersionLoader::Backend::GetFirmware( 160 void VersionLoader::Backend::GetFirmware(
162 scoped_refptr<GetFirmwareRequest> request) { 161 scoped_refptr<GetFirmwareRequest> request) {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
164 if (request->canceled()) 163 if (request->canceled())
165 return; 164 return;
166 165
167 std::string firmware; 166 std::string firmware;
168 std::string contents; 167 std::string contents;
169 const FilePath file_path(kPathFirmware); 168 const FilePath file_path(kPathFirmware);
170 if (file_util::ReadFileToString(file_path, &contents)) { 169 if (file_util::ReadFileToString(file_path, &contents)) {
171 firmware = ParseFirmware(contents); 170 firmware = ParseFirmware(contents);
172 } 171 }
173 172
174 request->ForwardResult(GetFirmwareCallback::TupleType(request->handle(), 173 request->ForwardResult(request->handle(), firmware);
175 firmware));
176 } 174 }
177 175
178 } // namespace chromeos 176 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/version_loader.h ('k') | chrome/browser/ui/webui/bug_report_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698