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

Side by Side Diff: chrome/browser/chromeos/system/syslogs_provider.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
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/system/syslogs_provider.h" 5 #include "chrome/browser/chromeos/system/syslogs_provider.h"
6 6
7 #include <functional> 7 #include <functional>
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 } // namespace 169 } // namespace
170 170
171 class SyslogsProviderImpl : public SyslogsProvider { 171 class SyslogsProviderImpl : public SyslogsProvider {
172 public: 172 public:
173 // SyslogsProvider implementation: 173 // SyslogsProvider implementation:
174 virtual Handle RequestSyslogs( 174 virtual Handle RequestSyslogs(
175 bool compress_logs, 175 bool compress_logs,
176 SyslogsContext context, 176 SyslogsContext context,
177 CancelableRequestConsumerBase* consumer, 177 CancelableRequestConsumerBase* consumer,
178 ReadCompleteCallback* callback); 178 const ReadCompleteCallback& callback);
179 179
180 // Reads system logs, compresses content if requested. 180 // Reads system logs, compresses content if requested.
181 // Called from FILE thread. 181 // Called from FILE thread.
182 void ReadSyslogs( 182 void ReadSyslogs(
183 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request, 183 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request,
184 bool compress_logs, 184 bool compress_logs,
185 SyslogsContext context); 185 SyslogsContext context);
186 186
187 // Loads compressed logs and writes into |zip_content|. 187 // Loads compressed logs and writes into |zip_content|.
188 void LoadCompressedLogs(const FilePath& zip_file, 188 void LoadCompressedLogs(const FilePath& zip_file,
(...skipping 12 matching lines...) Expand all
201 DISALLOW_COPY_AND_ASSIGN(SyslogsProviderImpl); 201 DISALLOW_COPY_AND_ASSIGN(SyslogsProviderImpl);
202 }; 202 };
203 203
204 SyslogsProviderImpl::SyslogsProviderImpl() { 204 SyslogsProviderImpl::SyslogsProviderImpl() {
205 } 205 }
206 206
207 CancelableRequestProvider::Handle SyslogsProviderImpl::RequestSyslogs( 207 CancelableRequestProvider::Handle SyslogsProviderImpl::RequestSyslogs(
208 bool compress_logs, 208 bool compress_logs,
209 SyslogsContext context, 209 SyslogsContext context,
210 CancelableRequestConsumerBase* consumer, 210 CancelableRequestConsumerBase* consumer,
211 ReadCompleteCallback* callback) { 211 const ReadCompleteCallback& callback) {
212 // Register the callback request. 212 // Register the callback request.
213 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request( 213 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request(
214 new CancelableRequest<ReadCompleteCallback>(callback)); 214 new CancelableRequest<ReadCompleteCallback>(callback));
215 AddRequest(request, consumer); 215 AddRequest(request, consumer);
216 216
217 // Schedule a task on the FILE thread which will then trigger a request 217 // Schedule a task on the FILE thread which will then trigger a request
218 // callback on the calling thread (e.g. UI) when complete. 218 // callback on the calling thread (e.g. UI) when complete.
219 BrowserThread::PostTask( 219 BrowserThread::PostTask(
220 BrowserThread::FILE, FROM_HERE, 220 BrowserThread::FILE, FROM_HERE,
221 NewRunnableMethod( 221 NewRunnableMethod(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 // Add one line for each reverse-sorted entry. 279 // Add one line for each reverse-sorted entry.
280 std::string mem_string; 280 std::string mem_string;
281 for (ProcInfoSet::iterator iter = process_info.begin(); 281 for (ProcInfoSet::iterator iter = process_info.begin();
282 iter != process_info.end(); ++iter) { 282 iter != process_info.end(); ++iter) {
283 mem_string += 283 mem_string +=
284 iter->second + base::StringPrintf(": %d MB", iter->first) + "\n"; 284 iter->second + base::StringPrintf(": %d MB", iter->first) + "\n";
285 } 285 }
286 (*logs_)["mem_usage"] = mem_string; 286 (*logs_)["mem_usage"] = mem_string;
287 // This will call the callback on the calling thread. 287 // This will call the callback on the calling thread.
288 request_->ForwardResult( 288 request_->ForwardResult(logs_, zip_content_);
289 Tuple2<LogDictionaryType*, std::string*>(logs_, zip_content_));
290 } 289 }
291 290
292 private: 291 private:
293 virtual ~SyslogsMemoryHandler() {} 292 virtual ~SyslogsMemoryHandler() {}
294 293
295 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request_; 294 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request_;
296 LogDictionaryType* logs_; 295 LogDictionaryType* logs_;
297 std::string* zip_content_; 296 std::string* zip_content_;
298 DISALLOW_COPY_AND_ASSIGN(SyslogsMemoryHandler); 297 DISALLOW_COPY_AND_ASSIGN(SyslogsMemoryHandler);
299 }; 298 };
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 SyslogsProvider* SyslogsProvider::GetInstance() { 373 SyslogsProvider* SyslogsProvider::GetInstance() {
375 return SyslogsProviderImpl::GetInstance(); 374 return SyslogsProviderImpl::GetInstance();
376 } 375 }
377 376
378 } // namespace system 377 } // namespace system
379 } // namespace chromeos 378 } // namespace chromeos
380 379
381 // Allows InvokeLater without adding refcounting. SyslogsProviderImpl is a 380 // Allows InvokeLater without adding refcounting. SyslogsProviderImpl is a
382 // Singleton and won't be deleted until it's last InvokeLater is run. 381 // Singleton and won't be deleted until it's last InvokeLater is run.
383 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::SyslogsProviderImpl); 382 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::SyslogsProviderImpl);
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/syslogs_provider.h ('k') | chrome/browser/chromeos/version_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698