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 // static | |
10 void ChildMemoryCoordinatorImpl::Create( | |
11 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request) { | |
12 new ChildMemoryCoordinatorImpl(std::move(request), new ClientList); | |
13 } | |
14 | |
9 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( | 15 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( |
10 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, | 16 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, |
11 scoped_refptr<ClientList> clients) | 17 scoped_refptr<ClientList> clients) |
12 : binding_(this, std::move(request)), | 18 : binding_(this, std::move(request)), |
13 clients_(clients) {} | 19 clients_(clients) { |
20 // TODO(bashi): Add clients (e.g. skia). | |
chrisha
2016/06/27 20:35:30
Wouldn't it make more sense for clients to add the
bashi
2016/06/27 22:40:23
It was my first attempt. MemoryPressureListener us
| |
21 } | |
14 | 22 |
15 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {} | 23 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {} |
16 | 24 |
17 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { | 25 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { |
26 state_ = state; | |
18 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, | 27 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, |
19 state); | 28 state); |
20 } | 29 } |
21 | 30 |
31 void ChildMemoryCoordinatorImpl::GetCurrentState( | |
chrisha
2016/06/27 20:35:30
Do we need this call? The state is centrally impos
bashi
2016/06/27 22:40:23
This is for testing. Without it it's hard to make
| |
32 const GetCurrentStateCallback& callback) { | |
33 callback.Run(state_); | |
34 } | |
35 | |
22 } // namespace memory_coordinator | 36 } // namespace memory_coordinator |
OLD | NEW |