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

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

Issue 2877403002: Refactoring: Use const-refs (Closed)
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_condition_observer.h" 5 #include "content/browser/memory/memory_condition_observer.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "components/variations/variations_associated_data.h" 9 #include "components/variations/variations_associated_data.h"
10 #include "content/browser/memory/memory_monitor.h" 10 #include "content/browser/memory/memory_monitor.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 namespace { 14 namespace {
15 15
16 // A expected renderer size. These values come from the median of appropriate 16 // An expected renderer size. These values come from the median of appropriate
17 // UMA stats. 17 // UMA stats.
18 #if defined(OS_ANDROID) || defined(OS_IOS) 18 #if defined(OS_ANDROID) || defined(OS_IOS)
19 const int kDefaultExpectedRendererSizeMB = 40; 19 const int kDefaultExpectedRendererSizeMB = 40;
20 #elif defined(OS_WIN) 20 #elif defined(OS_WIN)
21 const int kDefaultExpectedRendererSizeMB = 70; 21 const int kDefaultExpectedRendererSizeMB = 70;
22 #else // Mac, Linux, and ChromeOS 22 #else // Mac, Linux, and ChromeOS
23 const int kDefaultExpectedRendererSizeMB = 120; 23 const int kDefaultExpectedRendererSizeMB = 120;
24 #endif 24 #endif
25 25
26 // Default values for parameters to determine the global state. 26 // Default values for parameters to determine the global state.
27 const int kDefaultNewRenderersUntilWarning = 4; 27 const int kDefaultNewRenderersUntilWarning = 4;
28 const int kDefaultNewRenderersUntilCritical = 2; 28 const int kDefaultNewRenderersUntilCritical = 2;
29 const int kDefaultNewRenderersBackToNormal = 5; 29 const int kDefaultNewRenderersBackToNormal = 5;
30 const int kDefaultNewRenderersBackToWarning = 3; 30 const int kDefaultNewRenderersBackToWarning = 3;
31 const int kDefaultMonitoringIntervalSeconds = 1; 31 const int kDefaultMonitoringIntervalSeconds = 1;
32 const int kMonitoringIntervalBackgroundedSeconds = 120; 32 const int kMonitoringIntervalBackgroundedSeconds = 120;
33 33
34 void SetIntVariationParameter(const std::map<std::string, std::string> params, 34 void SetIntVariationParameter(const std::map<std::string, std::string>& params,
35 const char* name, 35 const char* name,
36 int* target) { 36 int* target) {
37 const auto& iter = params.find(name); 37 const auto& iter = params.find(name);
38 if (iter == params.end()) 38 if (iter == params.end())
39 return; 39 return;
40 int value; 40 int value;
41 if (!iter->second.empty() && base::StringToInt(iter->second, &value)) { 41 if (!iter->second.empty() && base::StringToInt(iter->second, &value)) {
42 DCHECK(value > 0); 42 DCHECK(value > 0);
43 *target = value; 43 *target = value;
44 } 44 }
45 } 45 }
46 46
47 void SetSecondsVariationParameter( 47 void SetSecondsVariationParameter(
48 const std::map<std::string, std::string> params, 48 const std::map<std::string, std::string>& params,
49 const char* name, 49 const char* name,
50 base::TimeDelta* target) { 50 base::TimeDelta* target) {
51 const auto& iter = params.find(name); 51 const auto& iter = params.find(name);
52 if (iter == params.end()) 52 if (iter == params.end())
53 return; 53 return;
54 int value; 54 int value;
55 if (!iter->second.empty() && base::StringToInt(iter->second, &value)) { 55 if (!iter->second.empty() && base::StringToInt(iter->second, &value)) {
56 DCHECK(value > 0); 56 DCHECK(value > 0);
57 *target = base::TimeDelta::FromSeconds(value); 57 *target = base::TimeDelta::FromSeconds(value);
58 } 58 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 bool MemoryConditionObserver::ValidateParameters() { 177 bool MemoryConditionObserver::ValidateParameters() {
178 return (new_renderers_until_warning_ > new_renderers_until_critical_) && 178 return (new_renderers_until_warning_ > new_renderers_until_critical_) &&
179 (new_renderers_back_to_normal_ > new_renderers_back_to_warning_) && 179 (new_renderers_back_to_normal_ > new_renderers_back_to_warning_) &&
180 (new_renderers_back_to_normal_ > new_renderers_until_warning_) && 180 (new_renderers_back_to_normal_ > new_renderers_until_warning_) &&
181 (new_renderers_back_to_warning_ > new_renderers_until_critical_); 181 (new_renderers_back_to_warning_ > new_renderers_until_critical_);
182 } 182 }
183 183
184 } // namespace content 184 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698