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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ 5 #ifndef BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_
6 #define BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ 6 #define BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/memory_coordinator_client.h" 10 #include "base/memory/memory_coordinator_client.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 // The proxy of MemoryCoordinator to be accessed from components that are not 15 // The proxy of MemoryCoordinator to be accessed from components that are not
16 // in content/browser e.g. net. 16 // in content/browser e.g. net.
17 // TODO(chrisha): Consider moving these individual callbacks to a delegate that
18 // 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
17 class BASE_EXPORT MemoryCoordinatorProxy { 19 class BASE_EXPORT MemoryCoordinatorProxy {
18 public: 20 public:
19 using GetCurrentMemoryStateCallback = base::Callback<MemoryState()>; 21 using GetCurrentMemoryStateCallback = base::Callback<MemoryState()>;
20 using SetCurrentMemoryStateCallback = base::Callback<void(MemoryState)>; 22 using SetCurrentMemoryStateCallback = base::Callback<void(MemoryState)>;
23 using GetRemainingGlobalBudgetCallback = base::Callback<int64_t()>;
21 24
22 static MemoryCoordinatorProxy* GetInstance(); 25 static MemoryCoordinatorProxy* GetInstance();
23 26
24 // Returns the current memory state. 27 // Returns the current memory state.
25 MemoryState GetCurrentMemoryState() const; 28 MemoryState GetCurrentMemoryState() const;
26 29
27 // Sets the current memory state. This function is for testing only. 30 // Sets the current memory state. This function is for testing only.
28 void SetCurrentMemoryStateForTesting(MemoryState memory_state); 31 void SetCurrentMemoryStateForTesting(MemoryState memory_state);
29 32
33 // Returns the remaining global budget usable in aggregate by all Chrome
34 // processes. This indicates how many MB of memory are remaining for Chrome
35 // processes to use before the memory coordinator will take efforts to reclaim
36 // memory. A negative amount indicates that the coordinator is actively trying
37 // to reclaim that much memory.
38 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.
39
30 // Sets state-getter callback. 40 // Sets state-getter callback.
31 void SetGetCurrentMemoryStateCallback(GetCurrentMemoryStateCallback callback); 41 void SetGetCurrentMemoryStateCallback(GetCurrentMemoryStateCallback callback);
32 42
33 // Sets state-setter callback. 43 // Sets state-setter callback.
34 void SetSetCurrentMemoryStateForTestingCallback( 44 void SetSetCurrentMemoryStateForTestingCallback(
35 SetCurrentMemoryStateCallback callback); 45 SetCurrentMemoryStateCallback callback);
36 46
47 // Sets the remaining global budget callback.
48 void SetGetRemainingGlobalBudgetCallback(
49 GetRemainingGlobalBudgetCallback get_remaining_budget_callback);
50
37 private: 51 private:
38 friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>; 52 friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>;
39 53
40 MemoryCoordinatorProxy(); 54 MemoryCoordinatorProxy();
41 virtual ~MemoryCoordinatorProxy(); 55 virtual ~MemoryCoordinatorProxy();
42 56
43 GetCurrentMemoryStateCallback getter_callback_; 57 GetCurrentMemoryStateCallback getter_callback_;
44 SetCurrentMemoryStateCallback setter_callback_; 58 SetCurrentMemoryStateCallback setter_callback_;
59 GetRemainingGlobalBudgetCallback get_remaining_budget_callback_;
45 60
46 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorProxy); 61 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorProxy);
47 }; 62 };
48 63
49 } // namespace base 64 } // namespace base
50 65
51 #endif // BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ 66 #endif // BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_
OLDNEW
« 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