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 #include "components/memory_coordinator/public/interfaces/memory_coordinator.moj om.h" | |
8 | |
7 namespace memory_coordinator { | 9 namespace memory_coordinator { |
8 | 10 |
9 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( | 11 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl() |
10 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, | 12 : binding_(this), clients_(new ClientList) {} |
11 scoped_refptr<ClientList> clients) | |
12 : binding_(this, std::move(request)), | |
13 clients_(clients) {} | |
14 | 13 |
15 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {} | 14 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {} |
16 | 15 |
16 void ChildMemoryCoordinatorImpl::Bind( | |
17 mojom::ChildMemoryCoordinatorRequest request) { | |
18 binding_.Bind(std::move(request)); | |
dcheng
2016/07/08 07:10:35
I think it is somewhat unusual that we have a pers
bashi
2016/07/08 07:32:39
Yeah.. Actually, in PS#5 I didn't use this pattern
| |
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 } | |
30 | |
17 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { | 31 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { |
32 state_ = state; | |
18 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, | 33 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, |
19 state); | 34 state); |
20 } | 35 } |
21 | 36 |
37 void ChildMemoryCoordinatorImpl::GetCurrentStateForTesting( | |
38 const GetCurrentStateForTestingCallback& callback) { | |
39 callback.Run(state_); | |
40 } | |
41 | |
22 } // namespace memory_coordinator | 42 } // namespace memory_coordinator |
OLD | NEW |