| 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 #ifndef CHROMECAST_BROWSER_CAST_MEMORY_PRESSURE_MONITOR_H_ | 5 #ifndef CHROMECAST_BROWSER_CAST_MEMORY_PRESSURE_MONITOR_H_ |
| 6 #define CHROMECAST_BROWSER_CAST_MEMORY_PRESSURE_MONITOR_H_ | 6 #define CHROMECAST_BROWSER_CAST_MEMORY_PRESSURE_MONITOR_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/memory_pressure_monitor.h" | 9 #include "base/memory/memory_pressure_monitor.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 | 11 |
| 12 namespace chromecast { | 12 namespace chromecast { |
| 13 | 13 |
| 14 // Memory pressure monitor for Cast: polls for current memory | 14 // Memory pressure monitor for Cast: polls for current memory |
| 15 // usage periodically and sends memory pressure notifications. | 15 // usage periodically and sends memory pressure notifications. |
| 16 // TODO(halliwell): switch to //components/memory_pressure when that's | |
| 17 // ready. | |
| 18 class CastMemoryPressureMonitor : public base::MemoryPressureMonitor { | 16 class CastMemoryPressureMonitor : public base::MemoryPressureMonitor { |
| 19 public: | 17 public: |
| 20 CastMemoryPressureMonitor(); | 18 CastMemoryPressureMonitor(); |
| 21 ~CastMemoryPressureMonitor() override; | 19 ~CastMemoryPressureMonitor() override; |
| 22 | 20 |
| 23 // base::MemoryPressureMonitor implementation: | 21 // base::MemoryPressureMonitor implementation: |
| 24 MemoryPressureLevel GetCurrentPressureLevel() override; | 22 MemoryPressureLevel GetCurrentPressureLevel() override; |
| 25 void SetDispatchCallback(const DispatchCallback& callback) override; | 23 void SetDispatchCallback(const DispatchCallback& callback) override; |
| 26 | 24 |
| 27 private: | 25 private: |
| 28 void PollPressureLevel(); | 26 void PollPressureLevel(); |
| 29 void UpdateMemoryPressureLevel(MemoryPressureLevel new_level); | 27 void UpdateMemoryPressureLevel(MemoryPressureLevel new_level); |
| 30 | 28 |
| 31 MemoryPressureLevel current_level_; | 29 MemoryPressureLevel current_level_; |
| 32 const int system_reserved_kb_; | 30 const int system_reserved_kb_; |
| 33 DispatchCallback dispatch_callback_; | 31 DispatchCallback dispatch_callback_; |
| 34 base::WeakPtrFactory<CastMemoryPressureMonitor> weak_ptr_factory_; | 32 base::WeakPtrFactory<CastMemoryPressureMonitor> weak_ptr_factory_; |
| 35 | 33 |
| 36 DISALLOW_COPY_AND_ASSIGN(CastMemoryPressureMonitor); | 34 DISALLOW_COPY_AND_ASSIGN(CastMemoryPressureMonitor); |
| 37 }; | 35 }; |
| 38 | 36 |
| 39 } // namespace chromecast | 37 } // namespace chromecast |
| 40 | 38 |
| 41 #endif // CHROMECAST_BROWSER_CAST_MEMORY_PRESSURE_MONITOR_H_ | 39 #endif // CHROMECAST_BROWSER_CAST_MEMORY_PRESSURE_MONITOR_H_ |
| OLD | NEW |