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

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

Issue 2495003004: [Mac] Report statistics more regularly in Mac memory pressure monitor (Closed)
Patch Set: Fix parameter name in header Created 4 years, 1 month 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 <CoreFoundation/CFDate.h> 8 #include <CoreFoundation/CFDate.h>
9 #include <dispatch/dispatch.h> 9 #include <dispatch/dispatch.h>
10 10
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/mac/scoped_dispatch_object.h" 12 #include "base/mac/scoped_dispatch_object.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/memory_pressure_listener.h" 14 #include "base/memory/memory_pressure_listener.h"
15 #include "base/memory/memory_pressure_monitor.h" 15 #include "base/memory/memory_pressure_monitor.h"
16 16
17 namespace base { 17 namespace base {
18 namespace mac { 18 namespace mac {
19 19
20 class TestMemoryPressureMonitor; 20 class TestMemoryPressureMonitor;
21 21
22 // Declares the interface for the Mac MemoryPressureMonitor, which reports 22 // Declares the interface for the Mac MemoryPressureMonitor, which reports
23 // memory pressure events and status. 23 // memory pressure events and status.
24 class BASE_EXPORT MemoryPressureMonitor : public base::MemoryPressureMonitor { 24 class BASE_EXPORT MemoryPressureMonitor : public base::MemoryPressureMonitor {
25 public: 25 public:
26 MemoryPressureMonitor(); 26 MemoryPressureMonitor();
27 ~MemoryPressureMonitor() override; 27 ~MemoryPressureMonitor() override;
28 28
29 // Returns the currently-observed memory pressure. 29 // Returns the currently-observed memory pressure.
30 MemoryPressureLevel GetCurrentPressureLevel() const override; 30 MemoryPressureLevel GetCurrentPressureLevel() override;
31 31
32 void SetDispatchCallback(const DispatchCallback& callback) override; 32 void SetDispatchCallback(const DispatchCallback& callback) override;
33 33
34 private: 34 private:
35 friend TestMemoryPressureMonitor; 35 friend TestMemoryPressureMonitor;
36 36
37 static MemoryPressureLevel 37 static MemoryPressureLevel
38 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure); 38 MemoryPressureLevelForMacMemoryPressure(int mac_memory_pressure);
39 void OnMemoryPressureChanged(dispatch_source_s* event_source, 39 void OnMemoryPressureChanged(dispatch_source_s* event_source,
40 const DispatchCallback& dispatch_callback); 40 const DispatchCallback& dispatch_callback);
41 void SendStatisticsIfNecessary(bool pressure_level_changed);
41 42
42 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_; 43 ScopedDispatchObject<dispatch_source_t> memory_level_event_source_;
43 44
44 DispatchCallback dispatch_callback_; 45 DispatchCallback dispatch_callback_;
45 46
46 CFTimeInterval last_pressure_change_; 47 CFTimeInterval last_statistic_report_;
47 48
48 MemoryPressureLevel last_pressure_level_; 49 MemoryPressureLevel last_pressure_level_;
49 50
50 // The UMA statistic is recorded in 5 second increments. This 51 // The UMA statistic is recorded in 5 second increments. This
51 // accumulates the remaining time to be rolled into the next 52 // accumulates the remaining time to be rolled into the next
52 // call. 53 // call.
53 CFTimeInterval reporting_error_; 54 CFTimeInterval reporting_error_;
54 55
55 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor); 56 DISALLOW_COPY_AND_ASSIGN(MemoryPressureMonitor);
56 }; 57 };
57 58
58 } // namespace mac 59 } // namespace mac
59 } // namespace base 60 } // namespace base
60 61
61 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_ 62 #endif // BASE_MEMORY_MEMORY_PRESSURE_MONITOR_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698