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

Unified Diff: components/memory_coordinator/child/child_memory_coordinator_impl.cc

Issue 2311723002: Move memory_coordinator_client and its registry to base/memory (Closed)
Patch Set: Update 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
Index: components/memory_coordinator/child/child_memory_coordinator_impl.cc
diff --git a/components/memory_coordinator/child/child_memory_coordinator_impl.cc b/components/memory_coordinator/child/child_memory_coordinator_impl.cc
index 75dd8ed5243e46e1ee1cec024a90a67f034a700d..b1419bb998102342a39d7545dfdab0db39c147c4 100644
--- a/components/memory_coordinator/child/child_memory_coordinator_impl.cc
+++ b/components/memory_coordinator/child/child_memory_coordinator_impl.cc
@@ -5,6 +5,7 @@
#include "components/memory_coordinator/child/child_memory_coordinator_impl.h"
#include "base/lazy_instance.h"
+#include "base/memory/memory_coordinator_client_registry.h"
#include "base/synchronization/lock.h"
namespace memory_coordinator {
@@ -14,6 +15,22 @@ namespace {
base::LazyInstance<base::Lock>::Leaky g_lock = LAZY_INSTANCE_INITIALIZER;
ChildMemoryCoordinatorImpl* g_child_memory_coordinator = nullptr;
+base::MemoryState ToBaseMemoryState(mojom::MemoryState state) {
+ switch (state) {
+ case mojom::MemoryState::UNKNOWN:
+ return base::MemoryState::UNKNOWN;
+ case mojom::MemoryState::NORMAL:
+ return base::MemoryState::NORMAL;
+ case mojom::MemoryState::THROTTLED:
+ return base::MemoryState::THROTTLED;
+ case mojom::MemoryState::SUSPENDED:
+ return base::MemoryState::SUSPENDED;
+ default:
+ NOTREACHED();
+ return base::MemoryState::UNKNOWN;
+ }
+}
+
} // namespace
// static
@@ -40,8 +57,10 @@ ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {
}
void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) {
- clients()->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange,
- state);
+ base::MemoryState base_state = ToBaseMemoryState(state);
+ base::MemoryCoordinatorClientRegistry::GetInstance()->clients()->Notify(
+ FROM_HERE, &base::MemoryCoordinatorClient::OnMemoryStateChange,
+ base_state);
}
#if !defined(OS_ANDROID)

Powered by Google App Engine
This is Rietveld 408576698