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

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

Issue 8960010: base::Bind: Convert NewRunnableMethod in chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix 55. Created 8 years, 12 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
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/bind.h"
9 #include "base/file_path.h" 10 #include "base/file_path.h"
10 #include "base/file_util.h" 11 #include "base/file_util.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "base/string_split.h" 13 #include "base/string_split.h"
13 #include "base/string_util.h" 14 #include "base/string_util.h"
14 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "base/time.h" 17 #include "base/time.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 52 if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
52 // This should only happen if Chrome is shutting down, so we don't do 53 // This should only happen if Chrome is shutting down, so we don't do
53 // anything. 54 // anything.
54 return 0; 55 return 0;
55 } 56 }
56 57
57 scoped_refptr<GetVersionRequest> request(new GetVersionRequest(callback)); 58 scoped_refptr<GetVersionRequest> request(new GetVersionRequest(callback));
58 AddRequest(request, consumer); 59 AddRequest(request, consumer);
59 60
60 BrowserThread::PostTask( 61 BrowserThread::PostTask(
61 BrowserThread::FILE, 62 BrowserThread::FILE, FROM_HERE,
62 FROM_HERE, 63 base::Bind(&Backend::GetVersion, backend_.get(), request, format));
63 NewRunnableMethod(backend_.get(), &Backend::GetVersion, request, format));
64 return request->handle(); 64 return request->handle();
65 } 65 }
66 66
67 VersionLoader::Handle VersionLoader::GetFirmware( 67 VersionLoader::Handle VersionLoader::GetFirmware(
68 CancelableRequestConsumerBase* consumer, 68 CancelableRequestConsumerBase* consumer,
69 const VersionLoader::GetFirmwareCallback& callback) { 69 const VersionLoader::GetFirmwareCallback& callback) {
70 if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 70 if (!BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
71 // This should only happen if Chrome is shutting down, so we don't do 71 // This should only happen if Chrome is shutting down, so we don't do
72 // anything. 72 // anything.
73 return 0; 73 return 0;
74 } 74 }
75 75
76 scoped_refptr<GetFirmwareRequest> request(new GetFirmwareRequest(callback)); 76 scoped_refptr<GetFirmwareRequest> request(new GetFirmwareRequest(callback));
77 AddRequest(request, consumer); 77 AddRequest(request, consumer);
78 78
79 BrowserThread::PostTask( 79 BrowserThread::PostTask(
80 BrowserThread::FILE, 80 BrowserThread::FILE, FROM_HERE,
81 FROM_HERE, 81 base::Bind(&Backend::GetFirmware, backend_.get(), request));
82 NewRunnableMethod(backend_.get(), &Backend::GetFirmware, request));
83 return request->handle(); 82 return request->handle();
84 } 83 }
85 84
86 // static 85 // static
87 std::string VersionLoader::ParseVersion(const std::string& contents, 86 std::string VersionLoader::ParseVersion(const std::string& contents,
88 const std::string& prefix) { 87 const std::string& prefix) {
89 // The file contains lines such as: 88 // The file contains lines such as:
90 // XXX=YYY 89 // XXX=YYY
91 // AAA=ZZZ 90 // AAA=ZZZ
92 // Split the lines and look for the one that starts with prefix. The version 91 // Split the lines and look for the one that starts with prefix. The version
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 std::string contents; 170 std::string contents;
172 const FilePath file_path(kPathFirmware); 171 const FilePath file_path(kPathFirmware);
173 if (file_util::ReadFileToString(file_path, &contents)) { 172 if (file_util::ReadFileToString(file_path, &contents)) {
174 firmware = ParseFirmware(contents); 173 firmware = ParseFirmware(contents);
175 } 174 }
176 175
177 request->ForwardResult(request->handle(), firmware); 176 request->ForwardResult(request->handle(), firmware);
178 } 177 }
179 178
180 } // namespace chromeos 179 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/syslogs_provider.cc ('k') | chrome/browser/chromeos/web_socket_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698