Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: content/browser/memory/memory_coordinator.cc

Issue 2550623002: Add MemoryCoordinator::GetGlobalMemoryState() (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "content/public/browser/content_browser_client.h" 9 #include "content/public/browser/content_browser_client.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 mojom::MemoryState MemoryCoordinator::GetChildMemoryState( 115 mojom::MemoryState MemoryCoordinator::GetChildMemoryState(
116 int render_process_id) const { 116 int render_process_id) const {
117 auto iter = children_.find(render_process_id); 117 auto iter = children_.find(render_process_id);
118 if (iter == children_.end()) 118 if (iter == children_.end())
119 return mojom::MemoryState::UNKNOWN; 119 return mojom::MemoryState::UNKNOWN;
120 return iter->second.memory_state; 120 return iter->second.memory_state;
121 } 121 }
122 122
123 void MemoryCoordinator::RecordMemoryPressure( 123 void MemoryCoordinator::RecordMemoryPressure(
124 base::MemoryPressureMonitor::MemoryPressureLevel level) { 124 base::MemoryPressureMonitor::MemoryPressureLevel level) {
125 int state = static_cast<int>(GetCurrentMemoryState()); 125 DCHECK(GetGlobalMemoryState() != base::MemoryState::UNKNOWN);
126 int state = static_cast<int>(GetGlobalMemoryState());
126 switch (level) { 127 switch (level) {
127 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: 128 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE:
128 UMA_HISTOGRAM_ENUMERATION( 129 UMA_HISTOGRAM_ENUMERATION(
129 "Memory.Coordinator.StateOnModerateNotificationReceived", 130 "Memory.Coordinator.StateOnModerateNotificationReceived",
130 state, base::kMemoryStateMax); 131 state, base::kMemoryStateMax);
131 break; 132 break;
132 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: 133 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
133 UMA_HISTOGRAM_ENUMERATION( 134 UMA_HISTOGRAM_ENUMERATION(
134 "Memory.Coordinator.StateOnCriticalNotificationReceived", 135 "Memory.Coordinator.StateOnCriticalNotificationReceived",
135 state, base::kMemoryStateMax); 136 state, base::kMemoryStateMax);
136 break; 137 break;
137 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: 138 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE:
138 NOTREACHED(); 139 NOTREACHED();
139 } 140 }
140 } 141 }
141 142
143 base::MemoryState MemoryCoordinator::GetGlobalMemoryState() const {
144 return base::MemoryState::UNKNOWN;
145 }
146
142 base::MemoryState MemoryCoordinator::GetCurrentMemoryState() const { 147 base::MemoryState MemoryCoordinator::GetCurrentMemoryState() const {
143 return base::MemoryState::UNKNOWN; 148 return base::MemoryState::UNKNOWN;
144 } 149 }
145 150
146 void MemoryCoordinator::SetCurrentMemoryStateForTesting( 151 void MemoryCoordinator::SetCurrentMemoryStateForTesting(
147 base::MemoryState memory_state) { 152 base::MemoryState memory_state) {
148 } 153 }
149 154
150 void MemoryCoordinator::AddChildForTesting( 155 void MemoryCoordinator::AddChildForTesting(
151 int dummy_render_process_id, mojom::ChildMemoryCoordinatorPtr child) { 156 int dummy_render_process_id, mojom::ChildMemoryCoordinatorPtr child) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 201
197 MemoryCoordinator::ChildInfo::ChildInfo() {} 202 MemoryCoordinator::ChildInfo::ChildInfo() {}
198 203
199 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) { 204 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) {
200 // This is a nop, but exists for compatibility with STL containers. 205 // This is a nop, but exists for compatibility with STL containers.
201 } 206 }
202 207
203 MemoryCoordinator::ChildInfo::~ChildInfo() {} 208 MemoryCoordinator::ChildInfo::~ChildInfo() {}
204 209
205 } // namespace content 210 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/memory/memory_coordinator.h ('k') | content/browser/memory/memory_coordinator_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698