| 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 "content/browser/memory/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 "content/public/browser/content_browser_client.h" | 8 #include "content/public/browser/content_browser_client.h" |
| 9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
| 11 #include "content/public/common/content_features.h" | |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 | 13 |
| 15 // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom | 14 // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom |
| 16 // for the role of this class. | 15 // for the role of this class. |
| 17 class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle { | 16 class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle { |
| 18 public: | 17 public: |
| 19 MemoryCoordinatorHandleImpl(mojom::MemoryCoordinatorHandleRequest request, | 18 MemoryCoordinatorHandleImpl(mojom::MemoryCoordinatorHandleRequest request, |
| 20 MemoryCoordinator* coordinator, | 19 MemoryCoordinator* coordinator, |
| 21 int render_process_id); | 20 int render_process_id); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 112 } |
| 114 | 113 |
| 115 mojom::MemoryState MemoryCoordinator::GetMemoryState( | 114 mojom::MemoryState MemoryCoordinator::GetMemoryState( |
| 116 int render_process_id) const { | 115 int render_process_id) const { |
| 117 auto iter = children_.find(render_process_id); | 116 auto iter = children_.find(render_process_id); |
| 118 if (iter == children_.end()) | 117 if (iter == children_.end()) |
| 119 return mojom::MemoryState::UNKNOWN; | 118 return mojom::MemoryState::UNKNOWN; |
| 120 return iter->second.memory_state; | 119 return iter->second.memory_state; |
| 121 } | 120 } |
| 122 | 121 |
| 123 void MemoryCoordinator::EnableFeaturesForTesting() { | |
| 124 base::FeatureList::ClearInstanceForTesting(); | |
| 125 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | |
| 126 feature_list->InitializeFromCommandLine(features::kMemoryCoordinator.name, | |
| 127 ""); | |
| 128 base::FeatureList::SetInstance(std::move(feature_list)); | |
| 129 } | |
| 130 | |
| 131 base::MemoryState MemoryCoordinator::GetCurrentMemoryState() const { | 122 base::MemoryState MemoryCoordinator::GetCurrentMemoryState() const { |
| 132 return base::MemoryState::UNKNOWN; | 123 return base::MemoryState::UNKNOWN; |
| 133 } | 124 } |
| 134 | 125 |
| 135 void MemoryCoordinator::SetCurrentMemoryStateForTesting( | 126 void MemoryCoordinator::SetCurrentMemoryStateForTesting( |
| 136 base::MemoryState memory_state) { | 127 base::MemoryState memory_state) { |
| 137 } | 128 } |
| 138 | 129 |
| 139 void MemoryCoordinator::AddChildForTesting( | 130 void MemoryCoordinator::AddChildForTesting( |
| 140 int dummy_render_process_id, mojom::ChildMemoryCoordinatorPtr child) { | 131 int dummy_render_process_id, mojom::ChildMemoryCoordinatorPtr child) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 175 |
| 185 MemoryCoordinator::ChildInfo::ChildInfo() {} | 176 MemoryCoordinator::ChildInfo::ChildInfo() {} |
| 186 | 177 |
| 187 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) { | 178 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) { |
| 188 // This is a nop, but exists for compatibility with STL containers. | 179 // This is a nop, but exists for compatibility with STL containers. |
| 189 } | 180 } |
| 190 | 181 |
| 191 MemoryCoordinator::ChildInfo::~ChildInfo() {} | 182 MemoryCoordinator::ChildInfo::~ChildInfo() {} |
| 192 | 183 |
| 193 } // namespace content | 184 } // namespace content |
| OLD | NEW |