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

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: Create handle per child 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..24fb7f0330035ac14f3251ee7e26a2c402426fb3 100644
--- a/components/memory_coordinator/child/child_memory_coordinator_impl.cc
+++ b/components/memory_coordinator/child/child_memory_coordinator_impl.cc
@@ -7,16 +7,36 @@
namespace memory_coordinator {
ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl(
- mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request,
- scoped_refptr<ClientList> clients)
- : binding_(this, std::move(request)),
- clients_(clients) {}
+ shell::InterfaceProvider* remote_interfaces)
+ : binding_(this), clients_(new ClientList) {
+ if (remote_interfaces) {
+ remote_interfaces->GetInterface(mojo::GetProxy(&parent_));
+ parent_->AddChild(binding_.CreateInterfacePtrAndBind());
+ }
+}
+
+ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {
+}
+
+void ChildMemoryCoordinatorImpl::RegisterClient(
+ MemoryCoordinatorClient* client) {
+ clients_->AddObserver(client);
+}
-ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {}
+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::GetCurrentStateForTesting(
+ const GetCurrentStateForTestingCallback& callback) {
+ callback.Run(state_);
+}
+
} // namespace memory_coordinator

Powered by Google App Engine
This is Rietveld 408576698