| 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/stringprintf.h" |
| 17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 18 #include "chrome/browser/memory_details.h" | 19 #include "chrome/browser/memory_details.h" |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
| 21 | 22 |
| 22 namespace chromeos { | 23 namespace chromeos { |
| 23 namespace system { | 24 namespace system { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 const char kSysLogsScript[] = | 27 const char kSysLogsScript[] = |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 process_string += titles; | 273 process_string += titles; |
| 273 } | 274 } |
| 274 // Use private working set for memory used calculation. | 275 // Use private working set for memory used calculation. |
| 275 int ws_mbytes = static_cast<int>(iter1->working_set.priv) / 1024; | 276 int ws_mbytes = static_cast<int>(iter1->working_set.priv) / 1024; |
| 276 process_info.insert(std::make_pair(ws_mbytes, process_string)); | 277 process_info.insert(std::make_pair(ws_mbytes, process_string)); |
| 277 } | 278 } |
| 278 // Add one line for each reverse-sorted entry. | 279 // Add one line for each reverse-sorted entry. |
| 279 std::string mem_string; | 280 std::string mem_string; |
| 280 for (ProcInfoSet::iterator iter = process_info.begin(); | 281 for (ProcInfoSet::iterator iter = process_info.begin(); |
| 281 iter != process_info.end(); ++iter) { | 282 iter != process_info.end(); ++iter) { |
| 282 mem_string += iter->second + StringPrintf(": %d MB", iter->first) + "\n"; | 283 mem_string += |
| 284 iter->second + base::StringPrintf(": %d MB", iter->first) + "\n"; |
| 283 } | 285 } |
| 284 (*logs_)["mem_usage"] = mem_string; | 286 (*logs_)["mem_usage"] = mem_string; |
| 285 // This will call the callback on the calling thread. | 287 // This will call the callback on the calling thread. |
| 286 request_->ForwardResult( | 288 request_->ForwardResult( |
| 287 Tuple2<LogDictionaryType*, std::string*>(logs_, zip_content_)); | 289 Tuple2<LogDictionaryType*, std::string*>(logs_, zip_content_)); |
| 288 } | 290 } |
| 289 | 291 |
| 290 private: | 292 private: |
| 291 virtual ~SyslogsMemoryHandler() {} | 293 virtual ~SyslogsMemoryHandler() {} |
| 292 | 294 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 SyslogsProvider* SyslogsProvider::GetInstance() { | 374 SyslogsProvider* SyslogsProvider::GetInstance() { |
| 373 return SyslogsProviderImpl::GetInstance(); | 375 return SyslogsProviderImpl::GetInstance(); |
| 374 } | 376 } |
| 375 | 377 |
| 376 } // namespace system | 378 } // namespace system |
| 377 } // namespace chromeos | 379 } // namespace chromeos |
| 378 | 380 |
| 379 // Allows InvokeLater without adding refcounting. SyslogsProviderImpl is a | 381 // Allows InvokeLater without adding refcounting. SyslogsProviderImpl is a |
| 380 // Singleton and won't be deleted until it's last InvokeLater is run. | 382 // Singleton and won't be deleted until it's last InvokeLater is run. |
| 381 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::SyslogsProviderImpl); | 383 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::system::SyslogsProviderImpl); |
| OLD | NEW |