| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chromecast/browser/cast_memory_pressure_monitor.h" | 5 #include "chromecast/browser/cast_memory_pressure_monitor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 system_reserved_kb_(GetSystemReservedKb()), | 48 system_reserved_kb_(GetSystemReservedKb()), |
| 49 dispatch_callback_( | 49 dispatch_callback_( |
| 50 base::Bind(&base::MemoryPressureListener::NotifyMemoryPressure)), | 50 base::Bind(&base::MemoryPressureListener::NotifyMemoryPressure)), |
| 51 weak_ptr_factory_(this) { | 51 weak_ptr_factory_(this) { |
| 52 PollPressureLevel(); | 52 PollPressureLevel(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 CastMemoryPressureMonitor::~CastMemoryPressureMonitor() {} | 55 CastMemoryPressureMonitor::~CastMemoryPressureMonitor() {} |
| 56 | 56 |
| 57 CastMemoryPressureMonitor::MemoryPressureLevel | 57 CastMemoryPressureMonitor::MemoryPressureLevel |
| 58 CastMemoryPressureMonitor::GetCurrentPressureLevel() const { | 58 CastMemoryPressureMonitor::GetCurrentPressureLevel() { |
| 59 return current_level_; | 59 return current_level_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void CastMemoryPressureMonitor::PollPressureLevel() { | 62 void CastMemoryPressureMonitor::PollPressureLevel() { |
| 63 MemoryPressureLevel level = | 63 MemoryPressureLevel level = |
| 64 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; | 64 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE; |
| 65 | 65 |
| 66 base::SystemMemoryInfoKB info; | 66 base::SystemMemoryInfoKB info; |
| 67 if (!base::GetSystemMemoryInfo(&info)) { | 67 if (!base::GetSystemMemoryInfo(&info)) { |
| 68 LOG(ERROR) << "GetSystemMemoryInfo failed"; | 68 LOG(ERROR) << "GetSystemMemoryInfo failed"; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEventWithValue( | 125 metrics::CastMetricsHelper::GetInstance()->RecordApplicationEventWithValue( |
| 126 "Memory.Pressure.LevelChange", new_level); | 126 "Memory.Pressure.LevelChange", new_level); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void CastMemoryPressureMonitor::SetDispatchCallback( | 129 void CastMemoryPressureMonitor::SetDispatchCallback( |
| 130 const DispatchCallback& callback) { | 130 const DispatchCallback& callback) { |
| 131 dispatch_callback_ = callback; | 131 dispatch_callback_ = callback; |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace chromecast | 134 } // namespace chromecast |
| OLD | NEW |