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

Unified Diff: base/memory/memory_coordinator_client.h

Issue 2363353002: Document memory coordinator (Closed)
Patch Set: comments 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
« no previous file with comments | « no previous file | base/memory/memory_coordinator_client_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d1ea2106bc9316c8826c7bcbba19d332c0a40056 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 to memory state changes. Unlike MemoryPressureListener, this is a
+// stateful mechanism and clients that receive notifications only when memory
chrisha 2016/09/26 14:10:45 clients receive (remove "that")
bashi 2016/09/26 23:08:10 Done.
+// states are changed. State transitions are throttled to avoid thrashing; the
+// exact throttling period is platform dependent, but will be at least 5-10
+// seconds.
chrisha 2016/09/26 14:10:45 Mention that clients are expected to make changes
Ryan Sleevi 2016/09/26 15:05:17 Interesting. So to confirm - if a memory state is
bashi 2016/09/26 23:08:10 Done.
+
// 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. An initial state is NORMAL. 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 can occur except for
+ // 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698