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

Unified Diff: base/memory/memory_pressure_level_list.h

Issue 15995014: Adds MemoryPressureListener. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More comments Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: base/memory/memory_pressure_level_list.h
diff --git a/base/memory/memory_pressure_level_list.h b/base/memory/memory_pressure_level_list.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d3223081a8b679275a56ff78bbfd7ee490df992
--- /dev/null
+++ b/base/memory/memory_pressure_level_list.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file intentionally does not have header guards, it's included
+// inside a macro to generate enum and a java class for the values.
+
+#ifndef DEFINE_MEMORY_PRESSURE_LEVEL
+#error "DEFINE_MEMORY_PRESSURE_LEVEL should be defined."
+#endif
+
+// Modules are advised to free buffers that are cheap to re-allocate and not
+// immediately needed.
+DEFINE_MEMORY_PRESSURE_LEVEL(MEMORY_PRESSURE_MODERATE, 0)
+
+// At this level, modules are advised to free all possible memory.
+// The alternative is to be killed by the system, which means all memory will
+// have to be re-created, plus the cost of starting up from cold.
Peter Kasting 2013/06/07 01:00:43 Nit: starting up from cold -> a cold start
bulach 2013/06/07 11:06:58 Done.
+DEFINE_MEMORY_PRESSURE_LEVEL(MEMORY_PRESSURE_CRITICAL, 2)
+
+// TODO(bulach): REMOVE ME!!!!
+// At this level, the system has no other option but to kill the app.
+// All modules should free as much memory as they possibly can, otherwise the
+// platform will just kill the app.
+// In other words, if a module holds on to a buffer X and the app gets killed,
+// later on the entire app will have to be restarted and the buffer X will have
+// to be recreated. So it's almost always guaranteed to be better to free
+// all possible memory at this pressure level.
+DEFINE_MEMORY_PRESSURE_LEVEL(MEMORY_PRESSURE_SURRENDER_OR_DIE, 2)
bulach 2013/06/06 09:28:30 btw: I don't want this to be funny or anything, bu
joth 2013/06/06 22:36:46 This gets into brinkmanship. IF the system _really
Peter Kasting 2013/06/07 01:00:43 I think this SURRENDER_OR_DIE case adds nothing to
bulach 2013/06/07 11:06:58 Done.

Powered by Google App Engine
This is Rietveld 408576698