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

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

Issue 2743253006: [Mac] Return cached pressure level in GetCurrentPressureLevel(). (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | base/memory/memory_pressure_monitor_mac_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/memory/memory_pressure_monitor_mac.h" 5 #include "base/memory/memory_pressure_monitor_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 } 156 }
157 157
158 // Static. 158 // Static.
159 int MemoryPressureMonitor::GetSecondsPerUMATick() { 159 int MemoryPressureMonitor::GetSecondsPerUMATick() {
160 return kUMATickSize; 160 return kUMATickSize;
161 } 161 }
162 162
163 MemoryPressureListener::MemoryPressureLevel 163 MemoryPressureListener::MemoryPressureLevel
164 MemoryPressureMonitor::GetCurrentPressureLevel() { 164 MemoryPressureMonitor::GetCurrentPressureLevel() {
165 UpdatePressureLevel();
166 return last_pressure_level_; 165 return last_pressure_level_;
167 } 166 }
168 167
169 void MemoryPressureMonitor::OnMemoryPressureChanged( 168 void MemoryPressureMonitor::OnMemoryPressureChanged(
170 dispatch_source_s* event_source, 169 dispatch_source_s* event_source,
171 const MemoryPressureMonitor::DispatchCallback& dispatch_callback) { 170 const MemoryPressureMonitor::DispatchCallback& dispatch_callback) {
172 // Get the Chrome-equvialent memory pressure level. 171 // Get the Chrome-equvialent memory pressure level.
173 int mac_memory_pressure_level = dispatch_source_get_data(event_source); 172 int mac_memory_pressure_level = dispatch_source_get_data(event_source);
174 MemoryPressureListener::MemoryPressureLevel memory_pressure_level = 173 MemoryPressureListener::MemoryPressureLevel memory_pressure_level =
175 MemoryPressureLevelForMacMemoryPressureLevel(mac_memory_pressure_level); 174 MemoryPressureLevelForMacMemoryPressureLevel(mac_memory_pressure_level);
(...skipping 15 matching lines...) Expand all
191 dispatch_callback.Run(memory_pressure_level); 190 dispatch_callback.Run(memory_pressure_level);
192 } 191 }
193 192
194 void MemoryPressureMonitor::SetDispatchCallback( 193 void MemoryPressureMonitor::SetDispatchCallback(
195 const DispatchCallback& callback) { 194 const DispatchCallback& callback) {
196 dispatch_callback_ = callback; 195 dispatch_callback_ = callback;
197 } 196 }
198 197
199 } // namespace mac 198 } // namespace mac
200 } // namespace base 199 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/memory/memory_pressure_monitor_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698