Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: base/memory/memory_pressure_monitor_mac.h

Issue 2097753002: Make memory pressure notifier configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 private: 31 void SetObserver(MemoryPressureMonitorObserver* observer) override;
32
33 void Notify(MemoryPressureLevel level);
34
35 private:
32 friend TestMemoryPressureMonitor; 36 friend TestMemoryPressureMonitor;
33 37
34 static MemoryPressureLevel 38 static MemoryPressureLevel
35 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure); 39 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure);
36 static void NotifyMemoryPressureChanged(dispatch_source_s* event_source); 40 static void NotifyMemoryPressureChanged(dispatch_source_s* event_source,
41 MemoryPressureMonitor* monitor);
37 42
38 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_; 43 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_;
39 44
45 MemoryPressureMonitorObserver* observer_ = nullptr;
46
40 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); 47 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor);
41 }; 48 };
42 49
43 } // namespace mac 50 } // namespace mac
44 } // namespace base 51 } // namespace base
45 52
46 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ 53 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698