| 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 #ifndef BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ | 5 #ifndef BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ |
| 6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ | 6 #define BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ |
| 7 | 7 |
| 8 #include <CoreFoundation/CFDate.h> |
| 8 #include <dispatch/dispatch.h> | 9 #include <dispatch/dispatch.h> |
| 9 | 10 |
| 10 #include "base/base_export.h" | 11 #include "base/base_export.h" |
| 11 #include "base/mac/scoped_dispatch_object.h" | 12 #include "base/mac/scoped_dispatch_object.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/memory_pressure_listener.h" | 14 #include "base/memory/memory_pressure_listener.h" |
| 14 #include "base/memory/memory_pressure_monitor.h" | 15 #include "base/memory/memory_pressure_monitor.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 namespace mac { | 18 namespace mac { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 28 // Returns the currently-observed memory pressure. | 29 // Returns the currently-observed memory pressure. |
| 29 MemoryPressureLevel GetCurrentPressureLevel() const override; | 30 MemoryPressureLevel GetCurrentPressureLevel() const override; |
| 30 | 31 |
| 31 void SetDispatchCallback(const DispatchCallback& callback) override; | 32 void SetDispatchCallback(const DispatchCallback& callback) override; |
| 32 | 33 |
| 33 private: | 34 private: |
| 34 friend TestMemoryPressureMonitor; | 35 friend TestMemoryPressureMonitor; |
| 35 | 36 |
| 36 static MemoryPressureLevel | 37 static MemoryPressureLevel |
| 37 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure); | 38 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure); |
| 38 static void NotifyMemoryPressureChanged( | 39 void NotifyMemoryPressureChanged(dispatch_source_s* event_source, |
| 39 dispatch_source_s* event_source, | 40 const DispatchCallback& dispatch_callback); |
| 40 const DispatchCallback& dispatch_callback); | |
| 41 | 41 |
| 42 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_; | 42 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_; |
| 43 | 43 |
| 44 DispatchCallback dispatch_callback_; | 44 DispatchCallback dispatch_callback_; |
| 45 | 45 |
| 46 CFTimeInterval last_pressure_change_; |
| 47 |
| 48 MemoryPressureLevel last_pressure_level_; |
| 49 |
| 46 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); | 50 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
| 47 }; | 51 }; |
| 48 | 52 |
| 49 } // namespace mac | 53 } // namespace mac |
| 50 } // namespace base | 54 } // namespace base |
| 51 | 55 |
| 52 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ | 56 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ |
| OLD | NEW |