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

Unified Diff: base/memory/memory_coordinator_proxy.h

Issue 2479673002: Expose MemoryCoordinator's global budget information. (Closed)
Patch Set: Small cleanup. Created 4 years, 1 month 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_proxy.h
diff --git a/base/memory/memory_coordinator_proxy.h b/base/memory/memory_coordinator_proxy.h
index 4148da5dceec0c59e39462a6f740569263432ba9..ce6192c6876840ac7e066f003e33acdb1fa536a7 100644
--- a/base/memory/memory_coordinator_proxy.h
+++ b/base/memory/memory_coordinator_proxy.h
@@ -14,10 +14,13 @@ namespace base {
// The proxy of MemoryCoordinator to be accessed from components that are not
// in content/browser e.g. net.
+// TODO(chrisha): Consider moving these individual callbacks to a delegate that
+// is injected.
bashi 2016/11/07 00:16:37 +1 :)
chrisha 2016/11/07 19:33:41 I'll do this in a follow-up CL, as it's going to b
bashi 2016/11/07 23:17:08 Oh, I didn't mean I wanted this refactoring in thi
class BASE_EXPORT MemoryCoordinatorProxy {
public:
using GetCurrentMemoryStateCallback = base::Callback<MemoryState()>;
using SetCurrentMemoryStateCallback = base::Callback<void(MemoryState)>;
+ using GetRemainingGlobalBudgetCallback = base::Callback<int64_t()>;
static MemoryCoordinatorProxy* GetInstance();
@@ -27,6 +30,13 @@ class BASE_EXPORT MemoryCoordinatorProxy {
// Sets the current memory state. This function is for testing only.
void SetCurrentMemoryStateForTesting(MemoryState memory_state);
+ // Returns the remaining global budget usable in aggregate by all Chrome
+ // processes. This indicates how many MB of memory are remaining for Chrome
+ // processes to use before the memory coordinator will take efforts to reclaim
+ // memory. A negative amount indicates that the coordinator is actively trying
+ // to reclaim that much memory.
+ int64_t GetRemainingGlobalBudget() const;
bashi 2016/11/07 00:16:37 nit: we use int for MemoryMonitor::GetFreeMemoryUn
chrisha 2016/11/07 19:33:41 Well, an auto-scaled 'int' is sufficient for each
bashi 2016/11/07 23:17:08 I see.
+
// Sets state-getter callback.
void SetGetCurrentMemoryStateCallback(GetCurrentMemoryStateCallback callback);
@@ -34,6 +44,10 @@ class BASE_EXPORT MemoryCoordinatorProxy {
void SetSetCurrentMemoryStateForTestingCallback(
SetCurrentMemoryStateCallback callback);
+ // Sets the remaining global budget callback.
+ void SetGetRemainingGlobalBudgetCallback(
+ GetRemainingGlobalBudgetCallback get_remaining_budget_callback);
+
private:
friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>;
@@ -42,6 +56,7 @@ class BASE_EXPORT MemoryCoordinatorProxy {
GetCurrentMemoryStateCallback getter_callback_;
SetCurrentMemoryStateCallback setter_callback_;
+ GetRemainingGlobalBudgetCallback get_remaining_budget_callback_;
DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorProxy);
};
« no previous file with comments | « no previous file | base/memory/memory_coordinator_proxy.cc » ('j') | content/browser/memory/memory_coordinator_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698