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

Unified Diff: base/memory/memory_coordinator_proxy.h

Issue 2565323002: Stop using callbacks in MemoryCoordinatorProxy (Closed)
Patch Set: Created 4 years 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..2adf5657de490b5f1bdbd05b6c4fbf5e5babe3ab 100644
--- a/base/memory/memory_coordinator_proxy.h
+++ b/base/memory/memory_coordinator_proxy.h
@@ -6,33 +6,38 @@
#define BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_
#include "base/base_export.h"
-#include "base/callback.h"
#include "base/memory/memory_coordinator_client.h"
#include "base/memory/singleton.h"
+#include "base/memory/weak_ptr.h"
namespace base {
+// An interface to MemoryCoordinator. See comments in MemoryCoordinatorProxy for
+// method descriptions.
+class BASE_EXPORT MemoryCoordinatorInterface {
+ public:
+ virtual ~MemoryCoordinatorInterface() {}
+
+ virtual MemoryState GetLocalMemoryState() = 0;
+ virtual void SetMemoryStateForTesting(MemoryState state) = 0;
+};
+
// The proxy of MemoryCoordinator to be accessed from components that are not
// in content/browser e.g. net.
class BASE_EXPORT MemoryCoordinatorProxy {
public:
- using GetCurrentMemoryStateCallback = base::Callback<MemoryState()>;
- using SetCurrentMemoryStateCallback = base::Callback<void(MemoryState)>;
-
static MemoryCoordinatorProxy* GetInstance();
- // Returns the current memory state.
- MemoryState GetCurrentMemoryState() const;
-
- // Sets the current memory state. This function is for testing only.
- void SetCurrentMemoryStateForTesting(MemoryState memory_state);
+ // Sets an instance of MemoryCoordinator
+ void Set(WeakPtr<MemoryCoordinatorInterface> instance);
- // Sets state-getter callback.
- void SetGetCurrentMemoryStateCallback(GetCurrentMemoryStateCallback callback);
+ // Returns the process's current memory state. Note that the local state
+ // could be different from the global memory state as some processes cannot
+ // be suspended.
+ MemoryState GetLocalMemoryState() const;
- // Sets state-setter callback.
- void SetSetCurrentMemoryStateForTestingCallback(
- SetCurrentMemoryStateCallback callback);
+ // Sets the memory state of this process. This function is for testing only.
+ void SetMemoryStateForTesting(MemoryState memory_state);
haraken 2016/12/12 06:51:57 This sets the global memory state, not the memory
bashi 2016/12/12 07:17:55 This is a tricky part in some reasons. First, from
private:
friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>;
@@ -40,8 +45,7 @@ class BASE_EXPORT MemoryCoordinatorProxy {
MemoryCoordinatorProxy();
virtual ~MemoryCoordinatorProxy();
- GetCurrentMemoryStateCallback getter_callback_;
- SetCurrentMemoryStateCallback setter_callback_;
+ WeakPtr<MemoryCoordinatorInterface> instance_;
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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698