| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/system_logs/memory_details_log_source.h" |
| 6 |
| 7 #include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h" |
| 8 #include "chrome/browser/memory_details.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 |
| 11 namespace chromeos { |
| 12 |
| 13 // Reads Chrome memory usage. |
| 14 class SystemLogsMemoryHandler : public MemoryDetails { |
| 15 public: |
| 16 explicit SystemLogsMemoryHandler(const SysLogsSourceCallback& callback) |
| 17 : callback_(callback) {} |
| 18 |
| 19 // Sends the data to the callback. |
| 20 // MemoryDetails override. |
| 21 virtual void OnDetailsAvailable() OVERRIDE { |
| 22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 23 |
| 24 scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); |
| 25 (*response)["mem_usage"] = ToLogString(); |
| 26 callback_.Run(response.get()); |
| 27 } |
| 28 |
| 29 private: |
| 30 virtual ~SystemLogsMemoryHandler() {} |
| 31 SysLogsSourceCallback callback_; |
| 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(SystemLogsMemoryHandler); |
| 34 }; |
| 35 |
| 36 void MemoryDetailsLogSource::Fetch(const SysLogsSourceCallback& callback) { |
| 37 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 38 DCHECK(!callback.is_null()); |
| 39 |
| 40 scoped_refptr<SystemLogsMemoryHandler> |
| 41 handler(new SystemLogsMemoryHandler(callback)); |
| 42 // TODO(jamescook): Maybe we don't need to update histograms here? |
| 43 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); |
| 44 } |
| 45 |
| 46 } // namespace chromeos |
| OLD | NEW |