Chromium Code Reviews| Index: base/metrics/field_trial_params.cc |
| diff --git a/base/metrics/field_trial_params.cc b/base/metrics/field_trial_params.cc |
| index bcefa8944fb7bd79aca79d90b916bcd0e796e3f2..7195f4a813e18611fb5bca23f2e3c6e79fa8c24c 100644 |
| --- a/base/metrics/field_trial_params.cc |
| +++ b/base/metrics/field_trial_params.cc |
| @@ -118,4 +118,32 @@ bool GetFieldTrialParamByFeatureAsBool(const base::Feature& feature, |
| return default_value; |
| } |
| +std::string FeatureParam<std::string>::Get() const { |
| + const std::string value = GetFieldTrialParamValueByFeature(*feature, name); |
| + return value.empty() ? default_value : value; |
| +} |
| + |
| +double FeatureParam<double>::Get() const { |
| + return GetFieldTrialParamByFeatureAsDouble(*feature, name, default_value); |
| +} |
| + |
| +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.
|
| + return GetFieldTrialParamByFeatureAsInt(*feature, name, default_value); |
| +} |
| + |
| +bool FeatureParam<bool>::Get() const { |
| + return GetFieldTrialParamByFeatureAsBool(*feature, name, default_value); |
| +} |
| + |
| +void LogInvalidEnumValue(const base::Feature& feature, |
| + const std::string& param_name, |
| + const std::string& value_as_string, |
| + int default_value_as_int) { |
| + DLOG(WARNING) << "Failed to parse field trial param " << param_name |
| + << " with string value " << value_as_string << " under feature " |
| + << feature.name |
| + << " into an enum. Falling back to default value of " |
| + << default_value_as_int; |
| +} |
| + |
| } // namespace base |