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

Unified Diff: base/memory/memory_coordinator_client.h

Issue 2363353002: Document memory coordinator (Closed)
Patch Set: Created 4 years, 3 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_coordinator_client.h
diff --git a/base/memory/memory_coordinator_client.h b/base/memory/memory_coordinator_client.h
index da7104a8d94395decb299f15e86aa79069ce2e32..94174ceeb5c977f410ef5d4181759e04c395a94b 100644
--- a/base/memory/memory_coordinator_client.h
+++ b/base/memory/memory_coordinator_client.h
@@ -9,6 +9,15 @@
namespace base {
+// OVERVIEW:
+//
+// MemoryCoordinatorClient is an interface which a component can implement to
+// respond memory state changes. Unlike MemoryPressureListener, this is a
dcheng 2016/09/26 04:55:07 Nit: to respond => to respond to
bashi 2016/09/26 05:57:22 Done.
+// stateful mechanism and clients receive notifications only when memory states
+// are changed. In order to avoid thrashing, state transitions won't occur in a
dcheng 2016/09/26 04:55:07 Nit: State transitions are throttled to avoid thra
bashi 2016/09/26 05:57:22 Done. I choose "5-10 seconds" as the design doc wh
+// short period of time. The minimum time period of transtion depends on
+// platforms/OSes but at least in seconds.
+
// MemoryState is an indicator that processes can use to guide their memory
// allocation policies. For example, a process that receives the suspended
// state can use that as as signal to drop memory caches.
@@ -24,12 +33,18 @@ enum class MemoryState {
};
// This is an interface for components which can respond to memory status
-// changes.
+// changes. See MemoryCoordinatorClientRegistry for threading guarantees and
+// ownership management.
class BASE_EXPORT MemoryCoordinatorClient {
public:
virtual ~MemoryCoordinatorClient() {}
- // Called when memory state has changed.
+ // Called when memory state has changed. Any transition could occur except for
dcheng 2016/09/26 04:55:07 Is UNKNOWN an initial state?
bashi 2016/09/26 05:57:22 At this point, NORMAL is an initial state. But the
+ // UNKNOWN. General guidelines are:
+ // * NORMAL: Restore the default settings for memory allocation/usage if
+ // it has changed.
+ // * THROTTLED: Use smaller limits for memory allocations and caches.
+ // * SUSPENDED: Purge memory.
virtual void OnMemoryStateChange(MemoryState state) = 0;
};
« no previous file with comments | « no previous file | base/memory/memory_coordinator_client_registry.h » ('j') | base/memory/memory_coordinator_client_registry.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698