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/child/blink_memory_coordinator_client.h" | |
8 | |
7 namespace memory_coordinator { | 9 namespace memory_coordinator { |
8 | 10 |
11 // static | |
12 void ChildMemoryCoordinatorImpl::Create( | |
13 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request) { | |
14 scoped_refptr<ClientList> clients(new ClientList); | |
15 new ChildMemoryCoordinatorImpl(std::move(request), clients); | |
haraken
2016/06/27 02:17:07
Nit: new ChildMemoryCoordinatorImpl(std::move(requ
bashi
2016/06/27 03:49:29
Done.
| |
16 } | |
17 | |
9 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( | 18 ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( |
10 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, | 19 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, |
11 scoped_refptr<ClientList> clients) | 20 scoped_refptr<ClientList> clients) |
12 : binding_(this, std::move(request)), | 21 : binding_(this, std::move(request)), |
13 clients_(clients) {} | 22 clients_(clients), |
23 blink_client_(new BlinkMemoryCoordinatorClient) { | |
haraken
2016/06/27 02:17:07
Do we need the member variable |blink_client_|?
bashi
2016/06/27 03:49:29
Someone needs to have the ownership of BlinkMemory
| |
24 // TODO(bashi): Add more clients (e.g. skia). | |
25 clients_->AddObserver(blink_client_.get()); | |
26 } | |
14 | 27 |
15 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {} | 28 ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() {} |
16 | 29 |
17 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { | 30 void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { |
31 state_ = state; | |
18 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, | 32 clients_->Notify(FROM_HERE, &MemoryCoordinatorClient::OnMemoryStateChange, |
19 state); | 33 state); |
20 } | 34 } |
21 | 35 |
36 void ChildMemoryCoordinatorImpl::GetLastState( | |
37 const GetLastStateCallback& callback) { | |
38 callback.Run(state_); | |
39 } | |
40 | |
22 } // namespace memory_coordinator | 41 } // namespace memory_coordinator |
OLD | NEW |