| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/memory/oom_memory_details.h" | 5 #include "chrome/browser/memory/oom_memory_details.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/process/process_metrics.h" | 8 #include "base/process/process_metrics.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/memory/oom_memory_details.h" | 11 #include "chrome/browser/memory/oom_memory_details.h" |
| 12 #include "ui/base/text/bytes_formatting.h" | 12 #include "ui/base/text/bytes_formatting.h" |
| 13 | 13 |
| 14 namespace memory { | 14 namespace memory { |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 void OomMemoryDetails::Log(const std::string& title, | 17 void OomMemoryDetails::Log(const std::string& title, |
| 18 const base::Closure& callback) { | 18 const base::Closure& callback) { |
| 19 // Deletes itself upon completion. | 19 // Deletes itself upon completion. |
| 20 OomMemoryDetails* details = new OomMemoryDetails(title, callback); | 20 OomMemoryDetails* details = new OomMemoryDetails(title, callback); |
| 21 details->StartFetch(MemoryDetails::FROM_CHROME_ONLY); | 21 details->StartFetch(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 OomMemoryDetails::OomMemoryDetails(const std::string& title, | 24 OomMemoryDetails::OomMemoryDetails(const std::string& title, |
| 25 const base::Closure& callback) | 25 const base::Closure& callback) |
| 26 : title_(title), callback_(callback) { | 26 : title_(title), callback_(callback) { |
| 27 AddRef(); // Released in OnDetailsAvailable(). | 27 AddRef(); // Released in OnDetailsAvailable(). |
| 28 start_time_ = base::TimeTicks::Now(); | 28 start_time_ = base::TimeTicks::Now(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 OomMemoryDetails::~OomMemoryDetails() { | 31 OomMemoryDetails::~OomMemoryDetails() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 LOG(WARNING) << title_ << " (" << delta.InMilliseconds() << " ms):\n" | 46 LOG(WARNING) << title_ << " (" << delta.InMilliseconds() << " ms):\n" |
| 47 << log_string; | 47 << log_string; |
| 48 if (!callback_.is_null()) | 48 if (!callback_.is_null()) |
| 49 callback_.Run(); | 49 callback_.Run(); |
| 50 // Delete ourselves so we don't have to worry about OomPriorityManager | 50 // Delete ourselves so we don't have to worry about OomPriorityManager |
| 51 // deleting us when we're still working. | 51 // deleting us when we're still working. |
| 52 Release(); | 52 Release(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace memory | 55 } // namespace memory |
| OLD | NEW |