| 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 <dispatch/dispatch.h> | 8 #include <dispatch/dispatch.h> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // Declares the interface for the Mac MemoryPressureMonitor, which reports | 21 // Declares the interface for the Mac MemoryPressureMonitor, which reports |
| 22 // memory pressure events and status. | 22 // memory pressure events and status. |
| 23 class BASE_EXPORT MemoryPressureMonitor : public base::MemoryPressureMonitor { | 23 class BASE_EXPORT MemoryPressureMonitor : public base::MemoryPressureMonitor { |
| 24 public: | 24 public: |
| 25 MemoryPressureMonitor(); | 25 MemoryPressureMonitor(); |
| 26 ~MemoryPressureMonitor() override; | 26 ~MemoryPressureMonitor() override; |
| 27 | 27 |
| 28 // Returns the currently-observed memory pressure. | 28 // Returns the currently-observed memory pressure. |
| 29 MemoryPressureLevel GetCurrentPressureLevel() const override; | 29 MemoryPressureLevel GetCurrentPressureLevel() const override; |
| 30 | 30 |
| 31 void SetDispatchCallback(const DispatchCallback& callback) override; |
| 32 |
| 31 private: | 33 private: |
| 32 friend TestMemoryPressureMonitor; | 34 friend TestMemoryPressureMonitor; |
| 33 | 35 |
| 34 static MemoryPressureLevel | 36 static MemoryPressureLevel |
| 35 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure); | 37 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure); |
| 36 static void NotifyMemoryPressureChanged(dispatch_source_s* event_source); | 38 static void NotifyMemoryPressureChanged( |
| 39 dispatch_source_s* event_source, |
| 40 const DispatchCallback& dispatch_callback); |
| 37 | 41 |
| 38 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_; | 42 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_; |
| 39 | 43 |
| 44 DispatchCallback dispatch_callback_; |
| 45 |
| 40 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); | 46 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 } // namespace mac | 49 } // namespace mac |
| 44 } // namespace base | 50 } // namespace base |
| 45 | 51 |
| 46 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ | 52 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ |
| OLD | NEW |