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

Unified Diff: base/memory/memory_coordinator_proxy.cc

Issue 2703743002: Refactor MemoryCoordinatorProxy (Closed)
Patch Set: Remove atomics Created 3 years, 10 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 | « base/memory/memory_coordinator_proxy.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/memory_coordinator_proxy.cc
diff --git a/base/memory/memory_coordinator_proxy.cc b/base/memory/memory_coordinator_proxy.cc
index 24b6d66655e0e0d1cdaf59f89b7c2f2cb0c7458f..59c7a6a1ef287ce8fb6887a49594c1cd42adb385 100644
--- a/base/memory/memory_coordinator_proxy.cc
+++ b/base/memory/memory_coordinator_proxy.cc
@@ -6,36 +6,40 @@
namespace base {
+namespace {
+
+MemoryCoordinator* g_memory_coordinator = nullptr;
+
+} // namespace
+
MemoryCoordinatorProxy::MemoryCoordinatorProxy() {
}
MemoryCoordinatorProxy::~MemoryCoordinatorProxy() {
}
+// static
MemoryCoordinatorProxy* MemoryCoordinatorProxy::GetInstance() {
return Singleton<base::MemoryCoordinatorProxy>::get();
}
+// static
+void MemoryCoordinatorProxy::SetMemoryCoordinator(
+ MemoryCoordinator* coordinator) {
+ DCHECK(!g_memory_coordinator);
+ g_memory_coordinator = coordinator;
+}
+
MemoryState MemoryCoordinatorProxy::GetCurrentMemoryState() const {
- if (!getter_callback_)
+ if (!g_memory_coordinator)
return MemoryState::NORMAL;
- return getter_callback_.Run();
+ return g_memory_coordinator->GetCurrentMemoryState();
}
void MemoryCoordinatorProxy::SetCurrentMemoryStateForTesting(
MemoryState memory_state) {
- DCHECK(setter_callback_);
- setter_callback_.Run(memory_state);
-}
-
-void MemoryCoordinatorProxy::SetGetCurrentMemoryStateCallback(
- GetCurrentMemoryStateCallback callback) {
- getter_callback_ = callback;
-}
-
-void MemoryCoordinatorProxy::SetSetCurrentMemoryStateForTestingCallback(
- SetCurrentMemoryStateCallback callback) {
- setter_callback_ = callback;
+ DCHECK(g_memory_coordinator);
+ g_memory_coordinator->SetCurrentMemoryStateForTesting(memory_state);
}
} // namespace base
« no previous file with comments | « base/memory/memory_coordinator_proxy.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698