summaryrefslogtreecommitdiffstats
path: root/base/memory
diff options
context:
space:
mode:
authorskuhne <skuhne@chromium.org>2014-12-16 16:01:49 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-17 00:02:29 +0000
commit18c2280bd19edee2bfb10d3231eca2ab7652efac (patch)
treea87db406b7bf559fe3945c98c8d6790ac292059d /base/memory
parent536637f025bbec62cf8b6164e4825dc17af77895 (diff)
downloadchromium_src-18c2280bd19edee2bfb10d3231eca2ab7652efac.zip
chromium_src-18c2280bd19edee2bfb10d3231eca2ab7652efac.tar.gz
chromium_src-18c2280bd19edee2bfb10d3231eca2ab7652efac.tar.bz2
Extending the memory pressure system by adding one more state to denote a lack of memory pressure.
This CL is adding one more state to the resource pressure states to allow a system state query to use the pressure value. Please see go/chromeosresourcepressure for more information. BUG=439493 TEST=Since there are no users of the new state, this cannot be "tested" yet. Review URL: https://codereview.chromium.org/782053002 Cr-Commit-Position: refs/heads/master@{#308696}
Diffstat (limited to 'base/memory')
-rw-r--r--base/memory/memory_pressure_listener.cc1
-rw-r--r--base/memory/memory_pressure_listener.h17
2 files changed, 10 insertions, 8 deletions
diff --git a/base/memory/memory_pressure_listener.cc b/base/memory/memory_pressure_listener.cc
index 745c985..d51d918 100644
--- a/base/memory/memory_pressure_listener.cc
+++ b/base/memory/memory_pressure_listener.cc
@@ -51,6 +51,7 @@ void MemoryPressureListener::Notify(MemoryPressureLevel memory_pressure_level) {
// static
void MemoryPressureListener::NotifyMemoryPressure(
MemoryPressureLevel memory_pressure_level) {
+ DCHECK_NE(memory_pressure_level, MEMORY_PRESSURE_LEVEL_NONE);
TRACE_EVENT1("memory", "MemoryPressureListener::NotifyMemoryPressure",
"level", memory_pressure_level);
g_observers.Get().Notify(&MemoryPressureListener::Notify,
diff --git a/base/memory/memory_pressure_listener.h b/base/memory/memory_pressure_listener.h
index f586209..f159fb0 100644
--- a/base/memory/memory_pressure_listener.h
+++ b/base/memory/memory_pressure_listener.h
@@ -3,12 +3,9 @@
// found in the LICENSE file.
// MemoryPressure provides static APIs for handling memory pressure on
-// platforms that have such signals, such as Android.
+// platforms that have such signals, such as Android and ChromeOS.
// The app will try to discard buffers that aren't deemed essential (individual
// modules will implement their own policy).
-//
-// Refer to memory_pressure_level_list.h for information about what sorts of
-// signals can be sent under what conditions.
#ifndef BASE_MEMORY_PRESSURE_LISTENER_H_
#define BASE_MEMORY_PRESSURE_LISTENER_H_
@@ -26,12 +23,11 @@ namespace base {
// the listener.
// Note that even on the same thread, the callback is not guaranteed to be
// called synchronously within the system memory pressure broadcast.
-// Please see notes on memory_pressure_level_list.h: some levels are absolutely
-// critical, and if not enough memory is returned to the system, it'll
-// potentially kill the app, and then later the app will have to be
+// Please see notes in MemoryPressureLevel enum below: some levels are
+// absolutely critical, and if not enough memory is returned to the system,
+// it'll potentially kill the app, and then later the app will have to be
// cold-started.
//
-//
// Example:
//
// void OnMemoryPressure(MemoryPressureLevel memory_pressure_level) {
@@ -52,6 +48,11 @@ class BASE_EXPORT MemoryPressureListener {
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.base
enum MemoryPressureLevel {
+ // No problems, there is enough memory to use. This event is not sent via
+ // callback, but the enum is used in other places to find out the current
+ // state of the system.
+ MEMORY_PRESSURE_LEVEL_NONE = -1,
+
// Modules are advised to free buffers that are cheap to re-allocate and not
// immediately needed.
MEMORY_PRESSURE_LEVEL_MODERATE = 0,