| 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/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/bind.h" |
| 11 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 11 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 12 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 13 #include "base/logging.h" | 15 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
| 16 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 17 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
| 18 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 19 #include "chrome/browser/memory_details.h" | 21 #include "chrome/browser/memory_details.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 const ReadCompleteCallback& callback) { | 215 const ReadCompleteCallback& callback) { |
| 214 // Register the callback request. | 216 // Register the callback request. |
| 215 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request( | 217 scoped_refptr<CancelableRequest<ReadCompleteCallback> > request( |
| 216 new CancelableRequest<ReadCompleteCallback>(callback)); | 218 new CancelableRequest<ReadCompleteCallback>(callback)); |
| 217 AddRequest(request, consumer); | 219 AddRequest(request, consumer); |
| 218 | 220 |
| 219 // Schedule a task on the FILE thread which will then trigger a request | 221 // Schedule a task on the FILE thread which will then trigger a request |
| 220 // callback on the calling thread (e.g. UI) when complete. | 222 // callback on the calling thread (e.g. UI) when complete. |
| 221 BrowserThread::PostTask( | 223 BrowserThread::PostTask( |
| 222 BrowserThread::FILE, FROM_HERE, | 224 BrowserThread::FILE, FROM_HERE, |
| 223 NewRunnableMethod( | 225 base::Bind(&SyslogsProviderImpl::ReadSyslogs, base::Unretained(this), |
| 224 this, &SyslogsProviderImpl::ReadSyslogs, request, | 226 request, compress_logs, context)); |
| 225 compress_logs, context)); | |
| 226 | 227 |
| 227 return request->handle(); | 228 return request->handle(); |
| 228 } | 229 } |
| 229 | 230 |
| 230 // Derived class from memoryDetails converts the results into a single string | 231 // Derived class from memoryDetails converts the results into a single string |
| 231 // and adds a "mem_usage" entry to the logs, then forwards the result. | 232 // and adds a "mem_usage" entry to the logs, then forwards the result. |
| 232 // Format of entry is (one process per line, reverse-sorted by size): | 233 // Format of entry is (one process per line, reverse-sorted by size): |
| 233 // Tab [Title1|Title2]: 50 MB | 234 // Tab [Title1|Title2]: 50 MB |
| 234 // Browser: 30 MB | 235 // Browser: 30 MB |
| 235 // Tab [Title]: 20 MB | 236 // Tab [Title]: 20 MB |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return Singleton<SyslogsProviderImpl, | 372 return Singleton<SyslogsProviderImpl, |
| 372 DefaultSingletonTraits<SyslogsProviderImpl> >::get(); | 373 DefaultSingletonTraits<SyslogsProviderImpl> >::get(); |
| 373 } | 374 } |
| 374 | 375 |
| 375 SyslogsProvider* SyslogsProvider::GetInstance() { | 376 SyslogsProvider* SyslogsProvider::GetInstance() { |
| 376 return SyslogsProviderImpl::GetInstance(); | 377 return SyslogsProviderImpl::GetInstance(); |
| 377 } | 378 } |
| 378 | 379 |
| 379 } // namespace system | 380 } // namespace system |
| 380 } // namespace chromeos | 381 } // namespace chromeos |
| 381 | |
| 382 // Allows InvokeLater without adding refcounting. SyslogsProviderImpl is a | |
| 383 // Singleton and won't be deleted until it's last InvokeLater is run. | |
| 384 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::SyslogsProviderImpl); | |
| OLD | NEW |