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

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

Issue 2097753002: Make memory pressure notifier configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_chromeos.h" 5 #include "base/memory/memory_pressure_monitor_chromeos.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/select.h> 8 #include <sys/select.h>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } else if (current_memory_pressure_level_ == 223 } else if (current_memory_pressure_level_ ==
224 MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE && 224 MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE &&
225 old_pressure == 225 old_pressure ==
226 MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { 226 MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
227 // When we reducing the pressure level from critical to moderate, we 227 // When we reducing the pressure level from critical to moderate, we
228 // restart the timeout and do not send another notification. 228 // restart the timeout and do not send another notification.
229 moderate_pressure_repeat_count_ = 0; 229 moderate_pressure_repeat_count_ = 0;
230 return; 230 return;
231 } 231 }
232 moderate_pressure_repeat_count_ = 0; 232 moderate_pressure_repeat_count_ = 0;
233 MemoryPressureListener::NotifyMemoryPressure(current_memory_pressure_level_); 233 Notify(current_memory_pressure_level_);
234 } 234 }
235 235
236 // Gets the used ChromeOS memory in percent. 236 // Gets the used ChromeOS memory in percent.
237 int MemoryPressureMonitor::GetUsedMemoryInPercent() { 237 int MemoryPressureMonitor::GetUsedMemoryInPercent() {
238 base::SystemMemoryInfoKB info; 238 base::SystemMemoryInfoKB info;
239 if (!base::GetSystemMemoryInfo(&info)) { 239 if (!base::GetSystemMemoryInfo(&info)) {
240 VLOG(1) << "Cannot determine the free memory of the system."; 240 VLOG(1) << "Cannot determine the free memory of the system.";
241 return 0; 241 return 0;
242 } 242 }
243 // TODO(skuhne): Instead of adding the kernel memory pressure calculation 243 // TODO(skuhne): Instead of adding the kernel memory pressure calculation
(...skipping 22 matching lines...) Expand all
266 int available_memory = 266 int available_memory =
267 info.free + info.swap_free / kSwapWeight + file_memory; 267 info.free + info.swap_free / kSwapWeight + file_memory;
268 268
269 DCHECK(available_memory < total_memory); 269 DCHECK(available_memory < total_memory);
270 int percentage = ((total_memory - available_memory) * 100) / total_memory; 270 int percentage = ((total_memory - available_memory) * 100) / total_memory;
271 return percentage; 271 return percentage;
272 } 272 }
273 273
274 } // namespace chromeos 274 } // namespace chromeos
275 } // namespace base 275 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698