OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/memory_coordinator/child/child_memory_coordinator_impl.h" | 5 #include "components/memory_coordinator/child/child_memory_coordinator_impl.h" |
6 | 6 |
7 namespace memory_coordinator { | 7 namespace memory_coordinator { |
8 | 8 |
9 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( | 9 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( |
10 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, | 10 shell::InterfaceProvider* remote_interfaces) |
11 scoped_refptr<ClientList> clients) | 11 : binding_(this), clients_(new ClientList) { |
12 : binding_(this, std::move(request)), | 12 if (remote_interfaces) { |
13 clients_(clients) {} | 13 remote_interfaces->GetInterface(mojo::GetProxy(&parent_)); |
| 14 parent_->AddChild(binding_.CreateInterfacePtrAndBind()); |
| 15 } |
| 16 } |
14 | 17 |
15 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {} | 18 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() { |
| 19 } |
| 20 |
| 21 void ChildMemoryCoordinatorImpl::RegisterClient( |
| 22 MemoryCoordinatorClient* client) { |
| 23 clients_->AddObserver(client); |
| 24 } |
| 25 |
| 26 void ChildMemoryCoordinatorImpl::UnregisterClient( |
| 27 MemoryCoordinatorClient* client) { |
| 28 clients_->RemoveObserver(client); |
| 29 } |
16 | 30 |
17 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { | 31 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { |
18 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, | 32 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, |
19 state); | 33 state); |
20 } | 34 } |
21 | 35 |
22 } // namespace memory_coordinator | 36 } // namespace memory_coordinator |
OLD | NEW |