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

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

Issue 2482783002: Add StateOn{Moderate,Critical}NotificationReceived metrics (Closed)
Patch Set: Wrap -> Make Created 4 years, 1 month 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 "content/public/browser/content_browser_client.h" 9 #include "content/public/browser/content_browser_client.h"
9 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
10 #include "content/public/common/content_client.h" 11 #include "content/public/common/content_client.h"
11 #include "content/public/common/content_features.h" 12 #include "content/public/common/content_features.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom 16 // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom
16 // for the role of this class. 17 // for the role of this class.
17 class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle { 18 class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 114 }
114 115
115 mojom::MemoryState MemoryCoordinator::GetMemoryState( 116 mojom::MemoryState MemoryCoordinator::GetMemoryState(
116 int render_process_id) const { 117 int render_process_id) const {
117 auto iter = children_.find(render_process_id); 118 auto iter = children_.find(render_process_id);
118 if (iter == children_.end()) 119 if (iter == children_.end())
119 return mojom::MemoryState::UNKNOWN; 120 return mojom::MemoryState::UNKNOWN;
120 return iter->second.memory_state; 121 return iter->second.memory_state;
121 } 122 }
122 123
124 void MemoryCoordinator::RecordMemoryPressure(
125 base::MemoryPressureMonitor::MemoryPressureLevel level) {
126 int state = static_cast<int>(GetCurrentMemoryState());
127 switch (level) {
128 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE:
129 UMA_HISTOGRAM_ENUMERATION(
130 "Memory.Coordinator.StateOnModerateNotificationReceived",
131 state, base::kMemoryStateMax);
132 break;
133 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
134 UMA_HISTOGRAM_ENUMERATION(
135 "Memory.Coordinator.StateOnCriticalNotificationReceived",
136 state, base::kMemoryStateMax);
137 break;
138 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE:
139 // Fall through
140 default:
Ilya Sherman 2016/11/07 19:28:52 nit: It's generally best to omit the default case,
bashi 2016/11/08 00:33:35 Done.
141 NOTREACHED();
142 }
143 }
144
123 void MemoryCoordinator::EnableFeaturesForTesting() { 145 void MemoryCoordinator::EnableFeaturesForTesting() {
124 base::FeatureList::ClearInstanceForTesting(); 146 base::FeatureList::ClearInstanceForTesting();
125 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 147 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
126 feature_list->InitializeFromCommandLine(features::kMemoryCoordinator.name, 148 feature_list->InitializeFromCommandLine(features::kMemoryCoordinator.name,
127 ""); 149 "");
128 base::FeatureList::SetInstance(std::move(feature_list)); 150 base::FeatureList::SetInstance(std::move(feature_list));
129 } 151 }
130 152
131 base::MemoryState MemoryCoordinator::GetCurrentMemoryState() const { 153 base::MemoryState MemoryCoordinator::GetCurrentMemoryState() const {
132 return base::MemoryState::UNKNOWN; 154 return base::MemoryState::UNKNOWN;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 206
185 MemoryCoordinator::ChildInfo::ChildInfo() {} 207 MemoryCoordinator::ChildInfo::ChildInfo() {}
186 208
187 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) { 209 MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) {
188 // This is a nop, but exists for compatibility with STL containers. 210 // This is a nop, but exists for compatibility with STL containers.
189 } 211 }
190 212
191 MemoryCoordinator::ChildInfo::~ChildInfo() {} 213 MemoryCoordinator::ChildInfo::~ChildInfo() {}
192 214
193 } // namespace content 215 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698