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 #ifndef COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ | 5 #ifndef COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ |
6 #define COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ | 6 #define COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/observer_list_threadsafe.h" | 11 #include "base/observer_list_threadsafe.h" |
10 #include "components/memory_coordinator/common/memory_coordinator_client.h" | 12 #include "components/memory_coordinator/common/memory_coordinator_client.h" |
11 #include "components/memory_coordinator/public/interfaces/child_memory_coordinat
or.mojom.h" | 13 #include "components/memory_coordinator/public/interfaces/child_memory_coordinat
or.mojom.h" |
12 #include "mojo/public/cpp/bindings/strong_binding.h" | 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
13 | 15 |
14 namespace memory_coordinator { | 16 namespace memory_coordinator { |
15 | 17 |
| 18 class BlinkMemoryCoordinatorClient; |
| 19 |
16 // ChildMemoryCoordinatorImpl is the implementation of ChildMemoryCoordinator. | 20 // ChildMemoryCoordinatorImpl is the implementation of ChildMemoryCoordinator. |
17 // It lives in child processes and is responsible for dispatching memory events | 21 // It lives in child processes and is responsible for dispatching memory events |
18 // to its clients. | 22 // to its clients. |
19 class ChildMemoryCoordinatorImpl | 23 class ChildMemoryCoordinatorImpl |
20 : NON_EXPORTED_BASE(public mojom::ChildMemoryCoordinator) { | 24 : NON_EXPORTED_BASE(public mojom::ChildMemoryCoordinator) { |
21 public: | 25 public: |
22 using ClientList = base::ObserverListThreadSafe<MemoryCoordinatorClient>; | 26 using ClientList = base::ObserverListThreadSafe<MemoryCoordinatorClient>; |
23 ChildMemoryCoordinatorImpl( | 27 ChildMemoryCoordinatorImpl( |
24 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, | 28 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request, |
25 scoped_refptr<ClientList> clients); | 29 scoped_refptr<ClientList> clients); |
26 ~ChildMemoryCoordinatorImpl() override; | 30 ~ChildMemoryCoordinatorImpl() override; |
27 | 31 |
| 32 static void Create( |
| 33 mojo::InterfaceRequest<mojom::ChildMemoryCoordinator> request); |
| 34 |
28 // mojom::ChildMemoryCoordinator implementations: | 35 // mojom::ChildMemoryCoordinator implementations: |
29 void OnStateChange(mojom::MemoryState state) override; | 36 void OnStateChange(mojom::MemoryState state) override; |
| 37 void GetLastState(const GetLastStateCallback& callback) override; |
30 | 38 |
31 private: | 39 private: |
32 mojo::StrongBinding<mojom::ChildMemoryCoordinator> binding_; | 40 mojo::StrongBinding<mojom::ChildMemoryCoordinator> binding_; |
33 scoped_refptr<ClientList> clients_; | 41 scoped_refptr<ClientList> clients_; |
| 42 mojom::MemoryState state_ = mojom::MemoryState::UNKNOWN; |
| 43 |
| 44 std::unique_ptr<BlinkMemoryCoordinatorClient> blink_client_; |
34 | 45 |
35 DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImpl); | 46 DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImpl); |
36 }; | 47 }; |
37 | 48 |
38 } // namespace content | 49 } // namespace content |
39 | 50 |
40 #endif // COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ | 51 #endif // COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ |
OLD | NEW |