| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/feedback/system_logs/log_sources/memory_details_log_sou
rce.h" | 5 #include "chrome/browser/feedback/system_logs/log_sources/memory_details_log_sou
rce.h" |
| 6 | 6 |
| 7 #include "chrome/browser/memory_details.h" | 7 #include "chrome/browser/memory_details.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 namespace system_logs { | 10 namespace system_logs { |
| 11 | 11 |
| 12 // Reads Chrome memory usage. | 12 // Reads Chrome memory usage. |
| 13 class SystemLogsMemoryHandler : public MemoryDetails { | 13 class SystemLogsMemoryHandler : public MemoryDetails { |
| 14 public: | 14 public: |
| 15 explicit SystemLogsMemoryHandler(const SysLogsSourceCallback& callback) | 15 explicit SystemLogsMemoryHandler(const SysLogsSourceCallback& callback) |
| 16 : callback_(callback) {} | 16 : callback_(callback) {} |
| 17 | 17 |
| 18 // Sends the data to the callback. | 18 // Sends the data to the callback. |
| 19 // MemoryDetails override. | 19 // MemoryDetails override. |
| 20 void OnDetailsAvailable() override { | 20 void OnDetailsAvailable() override { |
| 21 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 22 | 22 |
| 23 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); | 23 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); |
| 24 (*response)["mem_usage"] = ToLogString(); | 24 (*response)["mem_usage"] = ToLogString(); |
| 25 callback_.Run(response.get()); | 25 callback_.Run(response.get()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 ~SystemLogsMemoryHandler() override {} | 29 ~SystemLogsMemoryHandler() override {} |
| 30 SysLogsSourceCallback callback_; | 30 SysLogsSourceCallback callback_; |
| 31 | 31 |
| 32 DISALLOW_COPY_AND_ASSIGN(SystemLogsMemoryHandler); | 32 DISALLOW_COPY_AND_ASSIGN(SystemLogsMemoryHandler); |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 MemoryDetailsLogSource::MemoryDetailsLogSource() | 35 MemoryDetailsLogSource::MemoryDetailsLogSource() |
| 36 : SystemLogsSource("MemoryDetails") { | 36 : SystemLogsSource("MemoryDetails") { |
| 37 } | 37 } |
| 38 | 38 |
| 39 MemoryDetailsLogSource::~MemoryDetailsLogSource() { | 39 MemoryDetailsLogSource::~MemoryDetailsLogSource() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void MemoryDetailsLogSource::Fetch(const SysLogsSourceCallback& callback) { | 42 void MemoryDetailsLogSource::Fetch(const SysLogsSourceCallback& callback) { |
| 43 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 44 DCHECK(!callback.is_null()); | 44 DCHECK(!callback.is_null()); |
| 45 | 45 |
| 46 scoped_refptr<SystemLogsMemoryHandler> | 46 scoped_refptr<SystemLogsMemoryHandler> |
| 47 handler(new SystemLogsMemoryHandler(callback)); | 47 handler(new SystemLogsMemoryHandler(callback)); |
| 48 handler->StartFetch(MemoryDetails::FROM_CHROME_ONLY); | 48 handler->StartFetch(MemoryDetails::FROM_CHROME_ONLY); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace system_logs | 51 } // namespace system_logs |
| OLD | NEW |