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

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

Issue 2094583002: Add MemoryCoordinator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 4 years, 5 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 75889ed43f66e6463c0e9b3dc0ed578ca745b85b..6a8fc57cf1b67a4e9b6a308dbea627f227d018b3 100644
--- a/components/memory_coordinator/child/child_memory_coordinator_impl.cc
+++ b/components/memory_coordinator/child/child_memory_coordinator_impl.cc
@@ -4,19 +4,39 @@
#include "components/memory_coordinator/child/child_memory_coordinator_impl.h"
+#include "components/memory_coordinator/public/interfaces/memory_coordinator.mojom.h"
+
namespace memory_coordinator {
-ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl(
- mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request,
- scoped_refptr<ClientList> clients)
- : binding_(this, std::move(request)),
- clients_(clients) {}
+ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl()
+ : binding_(this), clients_(new ClientList) {}
ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {}
+void ChildMemoryCoordinatorImpl::Bind(
+ mojom::ChildMemoryCoordinatorRequest request) {
+ binding_.Bind(std::move(request));
+}
+
+void ChildMemoryCoordinatorImpl::RegisterClient(
+ MemoryCoordinatorClient* client) {
+ clients_->AddObserver(client);
+}
+
+void ChildMemoryCoordinatorImpl::UnregisterClient(
+ MemoryCoordinatorClient* client) {
+ clients_->RemoveObserver(client);
+}
+
void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) {
+ state_ = state;
clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange,
state);
}
+void ChildMemoryCoordinatorImpl::GetCurrentState(
+ const GetCurrentStateCallback& callback) {
+ callback.Run(state_);
+}
+
} // namespace memory_coordinator

Powered by Google App Engine
This is Rietveld 408576698