Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/metrics/field_trial_params.h" | 5 #include "base/metrics/field_trial_params.h" |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/field_trial_param_associator.h" | 9 #include "base/metrics/field_trial_param_associator.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 if (!value_as_string.empty()) { | 111 if (!value_as_string.empty()) { |
| 112 DLOG(WARNING) << "Failed to parse field trial param " << param_name | 112 DLOG(WARNING) << "Failed to parse field trial param " << param_name |
| 113 << " with string value " << value_as_string | 113 << " with string value " << value_as_string |
| 114 << " under feature " << feature.name | 114 << " under feature " << feature.name |
| 115 << " into a bool. Falling back to default value of " | 115 << " into a bool. Falling back to default value of " |
| 116 << default_value; | 116 << default_value; |
| 117 } | 117 } |
| 118 return default_value; | 118 return default_value; |
| 119 } | 119 } |
| 120 | 120 |
| 121 std::string FeatureParam<std::string>::Get() const { | |
| 122 const std::string value = GetFieldTrialParamValueByFeature(*feature, name); | |
| 123 return value.empty() ? default_value : value; | |
| 124 } | |
| 125 | |
| 126 double FeatureParam<double>::Get() const { | |
| 127 return GetFieldTrialParamByFeatureAsDouble(*feature, name, default_value); | |
| 128 } | |
| 129 | |
| 130 int FeatureParam<int>::Get() const { | |
|
Alexei Svitkine (slow)
2017/04/24 18:35:47
What happens if someone tries to use a type that w
sfiera
2017/04/28 16:07:04
Yes, a compile error.
| |
| 131 return GetFieldTrialParamByFeatureAsInt(*feature, name, default_value); | |
| 132 } | |
| 133 | |
| 134 bool FeatureParam<bool>::Get() const { | |
| 135 return GetFieldTrialParamByFeatureAsBool(*feature, name, default_value); | |
| 136 } | |
| 137 | |
| 138 void LogInvalidEnumValue(const base::Feature& feature, | |
| 139 const std::string& param_name, | |
| 140 const std::string& value_as_string, | |
| 141 int default_value_as_int) { | |
| 142 DLOG(WARNING) << "Failed to parse field trial param " << param_name | |
| 143 << " with string value " << value_as_string << " under feature " | |
| 144 << feature.name | |
| 145 << " into an enum. Falling back to default value of " | |
| 146 << default_value_as_int; | |
| 147 } | |
| 148 | |
| 121 } // namespace base | 149 } // namespace base |
| OLD | NEW |