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/browser/memory_coordinator.h" | 5 #include "content/browser/memory/memory_coordinator.h" |
6 | 6 |
7 #include "base/memory/memory_coordinator_client_registry.h" | 7 #include "base/memory/memory_coordinator_client_registry.h" |
8 #include "components/memory_coordinator/common/memory_coordinator_features.h" | 8 #include "content/public/common/content_features.h" |
9 | 9 |
10 namespace memory_coordinator { | 10 namespace content { |
11 | 11 |
12 // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom | 12 // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom |
13 // for the role of this class. | 13 // for the role of this class. |
14 class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle { | 14 class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle { |
15 public: | 15 public: |
16 MemoryCoordinatorHandleImpl(mojom::MemoryCoordinatorHandleRequest request) | 16 MemoryCoordinatorHandleImpl(mojom::MemoryCoordinatorHandleRequest request) |
17 : binding_(this, std::move(request)) { | 17 : binding_(this, std::move(request)) { |
18 } | 18 } |
19 | 19 |
20 // mojom::MemoryCoordinatorHandle: | 20 // mojom::MemoryCoordinatorHandle: |
21 void AddChild(mojom::ChildMemoryCoordinatorPtr child) override { | 21 void AddChild(mojom::ChildMemoryCoordinatorPtr child) override { |
22 DCHECK(!child_.is_bound()); | 22 DCHECK(!child_.is_bound()); |
23 child_ = std::move(child); | 23 child_ = std::move(child); |
24 } | 24 } |
25 | 25 |
26 mojom::ChildMemoryCoordinatorPtr& child() { return child_; } | 26 mojom::ChildMemoryCoordinatorPtr& child() { return child_; } |
27 mojo::Binding<mojom::MemoryCoordinatorHandle>& binding() { return binding_; } | 27 mojo::Binding<mojom::MemoryCoordinatorHandle>& binding() { return binding_; } |
28 | 28 |
29 private: | 29 private: |
30 mojom::ChildMemoryCoordinatorPtr child_; | 30 mojom::ChildMemoryCoordinatorPtr child_; |
31 mojo::Binding<mojom::MemoryCoordinatorHandle> binding_; | 31 mojo::Binding<mojom::MemoryCoordinatorHandle> binding_; |
32 | 32 |
33 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorHandleImpl); | 33 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorHandleImpl); |
34 }; | 34 }; |
35 | 35 |
36 // static | 36 // static |
37 MemoryCoordinator* MemoryCoordinator::GetInstance() { | 37 MemoryCoordinator* MemoryCoordinator::GetInstance() { |
38 if (!IsEnabled()) | 38 if (!base::FeatureList::IsEnabled(features::kMemoryCoordinator)) |
39 return nullptr; | 39 return nullptr; |
40 return base::Singleton<MemoryCoordinator, | 40 return base::Singleton<MemoryCoordinator, |
41 base::LeakySingletonTraits<MemoryCoordinator>>::get(); | 41 base::LeakySingletonTraits<MemoryCoordinator>>::get(); |
42 } | 42 } |
43 | 43 |
44 MemoryCoordinator::MemoryCoordinator() {} | 44 MemoryCoordinator::MemoryCoordinator() {} |
45 | 45 |
46 MemoryCoordinator::~MemoryCoordinator() {} | 46 MemoryCoordinator::~MemoryCoordinator() {} |
47 | 47 |
48 void MemoryCoordinator::CreateHandle( | 48 void MemoryCoordinator::CreateHandle( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 | 116 |
117 MemoryCoordinator::ChildInfo::ChildInfo() {} | 117 MemoryCoordinator::ChildInfo::ChildInfo() {} |
118 | 118 |
119 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) { | 119 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) { |
120 // This is a nop, but exists for compatibility with STL containers. | 120 // This is a nop, but exists for compatibility with STL containers. |
121 } | 121 } |
122 | 122 |
123 MemoryCoordinator::ChildInfo::~ChildInfo() {} | 123 MemoryCoordinator::ChildInfo::~ChildInfo() {} |
124 | 124 |
125 } // namespace memory_coordinator | 125 } // namespace content |
OLD | NEW |