Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef BASE_METRICS_FIELD_TRIAL_PARAMS_H_ |
| 6 | #define BASE_METRICS_FIELD_TRIAL_PARAMS_H_ |
| 7 | |
danakj | e75c6c81 | 2024-07-26 20:37:47 | [diff] [blame] | 8 | #include <array> |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 9 | #include <map> |
| 10 | #include <string> |
| 11 | |
| 12 | #include "base/base_export.h" |
Tom Sepez | e6f11a55 | 2025-02-18 19:01:51 | [diff] [blame] | 13 | #include "base/compiler_specific.h" |
Anthony Vallee-Dubois | 9dbbbda3 | 2022-08-26 01:25:31 | [diff] [blame] | 14 | #include "base/feature_list.h" |
Keishi Hattori | 8a7e15d | 2023-01-19 07:16:29 | [diff] [blame] | 15 | #include "base/memory/raw_ptr_exclusion.h" |
Takashi Toyoshima | 8a54cdf | 2024-11-21 02:38:40 | [diff] [blame] | 16 | #include "base/no_destructor.h" |
Hans Wennborg | afeb390 | 2020-06-17 14:42:29 | [diff] [blame] | 17 | #include "base/notreached.h" |
Tal Pressman | 3e91d6fd | 2020-07-02 04:38:01 | [diff] [blame] | 18 | #include "base/time/time.h" |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 19 | |
| 20 | namespace base { |
| 21 | |
Takashi Toyoshima | 03c3a4d | 2024-09-06 06:32:02 | [diff] [blame] | 22 | namespace internal { |
| 23 | |
Takashi Toyoshima | 5e7b2515 | 2024-08-23 04:48:03 | [diff] [blame] | 24 | BASE_EXPORT bool IsFeatureParamWithCacheEnabled(); |
Takashi Toyoshima | 03c3a4d | 2024-09-06 06:32:02 | [diff] [blame] | 25 | |
| 26 | // A traits struct to manage the type for the default value in the following |
| 27 | // FeatureParam<> template. `std::string` needs to use a string literal instead |
| 28 | // of `std::string` to realize compile time construction. |
| 29 | template <typename T> |
| 30 | struct FeatureParamTraits { |
| 31 | using DefaultValueType = T; |
Takashi Toyoshima | 8a54cdf | 2024-11-21 02:38:40 | [diff] [blame] | 32 | using CacheStorageType = T; |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 33 | static CacheStorageType ToCacheStorageType(const T& value) { return value; } |
Takashi Toyoshima | 8a54cdf | 2024-11-21 02:38:40 | [diff] [blame] | 34 | static constexpr T FromCacheStorageType(const CacheStorageType& storage) { |
| 35 | return storage; |
| 36 | } |
Takashi Toyoshima | 03c3a4d | 2024-09-06 06:32:02 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | template <> |
| 40 | struct FeatureParamTraits<std::string> { |
| 41 | using DefaultValueType = const char*; |
Takashi Toyoshima | 8a54cdf | 2024-11-21 02:38:40 | [diff] [blame] | 42 | using CacheStorageType = NoDestructor<std::string>; |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 43 | static CacheStorageType ToCacheStorageType(const std::string& value) { |
Takashi Toyoshima | 8a54cdf | 2024-11-21 02:38:40 | [diff] [blame] | 44 | return CacheStorageType(value); |
| 45 | } |
| 46 | static constexpr std::string FromCacheStorageType( |
| 47 | const CacheStorageType& storage) { |
| 48 | return *storage; |
| 49 | } |
Takashi Toyoshima | 03c3a4d | 2024-09-06 06:32:02 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | } // namespace internal |
Takashi Toyoshima | 5e7b2515 | 2024-08-23 04:48:03 | [diff] [blame] | 53 | |
Miyoung Shin | b5ad87f | 2019-05-13 20:12:45 | [diff] [blame] | 54 | // Key-value mapping type for field trial parameters. |
| 55 | typedef std::map<std::string, std::string> FieldTrialParams; |
| 56 | |
Alexei Svitkine | 8724ea50 | 2019-06-14 21:51:46 | [diff] [blame] | 57 | // Param string decoding function for AssociateFieldTrialParamsFromString(). |
| 58 | typedef std::string (*FieldTrialParamsDecodeStringFunc)(const std::string& str); |
| 59 | |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 60 | // Shared declaration for various FeatureParam<T> types. |
| 61 | // |
| 62 | // This template is defined for the following types T: |
| 63 | // bool |
| 64 | // int |
| 65 | // size_t |
| 66 | // double |
| 67 | // std::string |
| 68 | // enum types |
| 69 | // base::TimeDelta |
| 70 | // |
| 71 | // Attempting to use it with any other type is a compile error. |
| 72 | // |
| 73 | // Getting a param value from a FeatureParam<T> will have the same semantics as |
| 74 | // GetFieldTrialParamValueByFeature(), see that function's comments for details. |
Trevor Perrier | 3666dee | 2025-01-16 15:09:05 | [diff] [blame] | 75 | // `cache_getter` is used to provide a dedicated getter that is used to give a |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 76 | // local cache to the FeatureParam. Usually, this is automatically generated and |
| 77 | // provided via BASE_FEATURE_PARAM() or BASE_FEATURE_ENUM_PARAM() macro. |
| 78 | // |
| 79 | // Example to declares a double-valued parameter. |
| 80 | // |
| 81 | // constexpr FeatureParam<double> kAssistantTriggerThreshold = { |
| 82 | // &kAssistantFeature, "trigger_threshold", 0.10}; |
| 83 | // |
Joe Mason | 05f944d | 2025-03-20 14:29:47 | [diff] [blame] | 84 | // Equivalent using the caching macro (see base/feature_list.h): |
| 85 | // |
| 86 | // BASE_FEATURE_PARAM(double, kAssistantTriggerThreshold, |
| 87 | // &kAssistantFeature, "trigger_threshold", 0.10); |
| 88 | // |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 89 | // If the feature is not enabled, the parameter is not set, or set to an invalid |
| 90 | // value, then Get() will return the default value. |
| 91 | template <typename T, bool IsEnum = std::is_enum_v<T>> |
| 92 | struct FeatureParam { |
| 93 | using DefaultValueType = |
| 94 | typename internal::FeatureParamTraits<T>::DefaultValueType; |
| 95 | |
| 96 | // Prevent use of FeatureParam<> with unsupported types (e.g. void*). Uses T |
| 97 | // in its definition so that evaluation is deferred until the template is |
| 98 | // instantiated. |
| 99 | static_assert(std::is_same_v<bool, T> || std::is_same_v<int, T> || |
| 100 | std::is_same_v<size_t, T> || std::is_same_v<double, T> || |
| 101 | std::is_same_v<std::string, T> || |
| 102 | std::is_same_v<base::TimeDelta, T>, |
| 103 | "Unsupported FeatureParam<> type"); |
| 104 | |
| 105 | constexpr FeatureParam(const Feature* feature, |
| 106 | const char* name, |
| 107 | DefaultValueType default_value, |
| 108 | T (*cache_getter)(const FeatureParam<T>*) = nullptr) |
| 109 | : feature(feature), |
| 110 | name(name), |
| 111 | default_value(default_value), |
| 112 | cache_getter(cache_getter) {} |
| 113 | |
| 114 | // Calling Get() or GetWithoutCache() will activate the field trial associated |
| 115 | // with |feature|. See GetFieldTrialParamValueByFeature() for more details. |
| 116 | BASE_EXPORT T Get() const { |
| 117 | if (internal::IsFeatureParamWithCacheEnabled() && cache_getter) { |
| 118 | return cache_getter(this); |
| 119 | } |
| 120 | return GetWithoutCache(); |
| 121 | } |
| 122 | BASE_EXPORT T GetWithoutCache() const; |
| 123 | |
Jayson Adams | 6bd0011 | 2025-01-15 21:01:41 | [diff] [blame] | 124 | // RAW_PTR_EXCLUSION: Using raw_ptr here would make FeatureParam lose its |
| 125 | // trivial destructor, causing it to be classified as a non-trivial class |
| 126 | // member in contexts where it's included. This can complicate code and |
| 127 | // impact performance. base::Features are expected to be globals with |
| 128 | // static lifetime, so this is pretty much always safe. |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 129 | RAW_PTR_EXCLUSION const Feature* const feature; |
| 130 | const char* const name; |
| 131 | const DefaultValueType default_value; |
| 132 | T (*const cache_getter)(const FeatureParam<T>*); |
| 133 | }; |
| 134 | |
| 135 | // Declarations for GetWithoutCache() specializations and explicit |
| 136 | // instantiations for the FeatureParam<> to ensure instantiating them |
| 137 | // in the base components to export them. |
| 138 | template <> |
| 139 | bool FeatureParam<bool>::GetWithoutCache() const; |
| 140 | template struct FeatureParam<bool>; |
| 141 | template struct internal::FeatureParamTraits<bool>; |
| 142 | |
| 143 | template <> |
| 144 | int FeatureParam<int>::GetWithoutCache() const; |
| 145 | template struct FeatureParam<int>; |
| 146 | template struct internal::FeatureParamTraits<int>; |
| 147 | |
| 148 | template <> |
| 149 | size_t FeatureParam<size_t>::GetWithoutCache() const; |
| 150 | template struct FeatureParam<size_t>; |
| 151 | template struct internal::FeatureParamTraits<size_t>; |
| 152 | |
| 153 | template <> |
| 154 | double FeatureParam<double>::GetWithoutCache() const; |
| 155 | template struct FeatureParam<double>; |
| 156 | template struct internal::FeatureParamTraits<double>; |
| 157 | |
| 158 | template <> |
| 159 | std::string FeatureParam<std::string>::GetWithoutCache() const; |
| 160 | template struct FeatureParam<std::string>; |
| 161 | |
| 162 | template <> |
| 163 | TimeDelta FeatureParam<TimeDelta>::GetWithoutCache() const; |
| 164 | template struct FeatureParam<TimeDelta>; |
| 165 | template struct internal::FeatureParamTraits<TimeDelta>; |
| 166 | |
| 167 | // Feature param declaration for an enum, with associated options. Example: |
| 168 | // |
| 169 | // constexpr FeatureParam<ShapeEnum>::Option kShapeParamOptions[] = { |
| 170 | // {SHAPE_CIRCLE, "circle"}, |
| 171 | // {SHAPE_CYLINDER, "cylinder"}, |
| 172 | // {SHAPE_PAPERCLIP, "paperclip"}}; |
| 173 | // constexpr FeatureParam<ShapeEnum> kAssistantShapeParam = { |
| 174 | // &kAssistantFeature, "shape", SHAPE_CIRCLE, &kShapeParamOptions}; |
| 175 | // |
| 176 | // With this declaration, the parameter may be set to "circle", "cylinder", or |
| 177 | // "paperclip", and that will be translated to one of the three enum values. By |
| 178 | // default, or if the param is set to an unknown value, the parameter will be |
| 179 | // assumed to be SHAPE_CIRCLE. |
| 180 | template <typename Enum> |
| 181 | struct FeatureParam<Enum, true> { |
| 182 | struct Option { |
| 183 | constexpr Option(Enum value, const char* name) : value(value), name(name) {} |
| 184 | |
| 185 | const Enum value; |
| 186 | const char* const name; |
| 187 | }; |
| 188 | |
| 189 | template <size_t option_count> |
| 190 | constexpr FeatureParam( |
| 191 | const Feature* feature, |
| 192 | const char* name, |
| 193 | const Enum default_value, |
| 194 | const std::array<Option, option_count>& options, |
| 195 | Enum (*cache_getter)(const FeatureParam<Enum>*) = nullptr) |
| 196 | : feature(feature), |
| 197 | name(name), |
| 198 | default_value(default_value), |
| 199 | options(options.data()), |
| 200 | option_count(option_count), |
| 201 | cache_getter(cache_getter) { |
| 202 | static_assert(option_count >= 1, "FeatureParam<enum> has no options"); |
| 203 | } |
| 204 | |
| 205 | template <size_t option_count> |
| 206 | constexpr FeatureParam( |
| 207 | const Feature* feature, |
| 208 | const char* name, |
| 209 | const Enum default_value, |
| 210 | const Option (*options)[option_count], |
| 211 | Enum (*cache_getter)(const FeatureParam<Enum>*) = nullptr) |
| 212 | : feature(feature), |
| 213 | name(name), |
| 214 | default_value(default_value), |
| 215 | options(*options), |
| 216 | option_count(option_count), |
| 217 | cache_getter(cache_getter) { |
| 218 | static_assert(option_count >= 1, "FeatureParam<enum> has no options"); |
| 219 | } |
| 220 | |
| 221 | // Calling Get() or GetWithoutCache() will activate the field trial associated |
| 222 | // with |feature|. See GetFieldTrialParamValueByFeature() for more details. |
| 223 | Enum Get() const { |
| 224 | if (internal::IsFeatureParamWithCacheEnabled() && cache_getter) { |
| 225 | return cache_getter(this); |
| 226 | } |
| 227 | return GetWithoutCache(); |
| 228 | } |
| 229 | Enum GetWithoutCache() const { |
| 230 | return GetFieldTrialParamByFeatureAsEnum( |
Tom Sepez | e6f11a55 | 2025-02-18 19:01:51 | [diff] [blame] | 231 | *feature, name, default_value, |
| 232 | UNSAFE_TODO(base::span(&*options, option_count))); |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | // Returns the param-string for the given enum value. |
| 236 | std::string GetName(Enum value) const { |
| 237 | for (size_t i = 0; i < option_count; ++i) { |
| 238 | if (value == options[i].value) { |
| 239 | return options[i].name; |
| 240 | } |
| 241 | } |
| 242 | NOTREACHED(); |
| 243 | } |
| 244 | |
| 245 | const raw_ptr<const base::Feature> feature; |
| 246 | const char* const name; |
| 247 | const Enum default_value; |
| 248 | // TODO(crbug.com/40284755): Remove AllowPtrArithmetic if possible after |
| 249 | // unsafe buffers have been evaluated. |
| 250 | const raw_ptr<const Option, AllowPtrArithmetic> options; |
| 251 | const size_t option_count; |
| 252 | Enum (*const cache_getter)(const FeatureParam<Enum>*); |
| 253 | }; |
| 254 | |
Weilun Shi | 1cd8fb9 | 2020-07-17 23:31:00 | [diff] [blame] | 255 | // Unescapes special characters from the given string. Used in |
| 256 | // AssociateFieldTrialParamsFromString() as one of the feature params decoding |
| 257 | // functions. |
| 258 | BASE_EXPORT std::string UnescapeValue(const std::string& value); |
| 259 | |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 260 | // Logs a warning that a feature param expected to map to an enum was an unknown |
| 261 | // non-empty value. |
| 262 | BASE_EXPORT void LogInvalidEnumValue(const Feature& feature, |
| 263 | const std::string& param_name, |
| 264 | const std::string& value_as_string, |
| 265 | int default_value_as_int); |
| 266 | |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 267 | // Associates the specified set of key-value |params| with the field trial |
| 268 | // specified by |trial_name| and |group_name|. Fails and returns false if the |
| 269 | // specified field trial already has params associated with it or the trial |
| 270 | // is already active (group() has been called on it). Thread safe. |
Miyoung Shin | b5ad87f | 2019-05-13 20:12:45 | [diff] [blame] | 271 | BASE_EXPORT bool AssociateFieldTrialParams(const std::string& trial_name, |
| 272 | const std::string& group_name, |
| 273 | const FieldTrialParams& params); |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 274 | |
Alexei Svitkine | 8724ea50 | 2019-06-14 21:51:46 | [diff] [blame] | 275 | // Provides a mechanism to associate multiple set of params to multiple groups |
| 276 | // with a formatted string as returned by FieldTrialList::AllParamsToString(). |
| 277 | // |decode_data_func| allows specifying a custom decoding function. |
| 278 | BASE_EXPORT bool AssociateFieldTrialParamsFromString( |
| 279 | const std::string& params_string, |
| 280 | FieldTrialParamsDecodeStringFunc decode_data_func); |
| 281 | |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 282 | // Retrieves the set of key-value |params| for the specified field trial, based |
| 283 | // on its selected group. If the field trial does not exist or its selected |
| 284 | // group does not have any parameters associated with it, returns false and |
| 285 | // does not modify |params|. Calling this function will result in the field |
| 286 | // trial being marked as active if found (i.e. group() will be called on it), |
| 287 | // if it wasn't already. Thread safe. |
Miyoung Shin | b5ad87f | 2019-05-13 20:12:45 | [diff] [blame] | 288 | BASE_EXPORT bool GetFieldTrialParams(const std::string& trial_name, |
| 289 | FieldTrialParams* params); |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 290 | |
| 291 | // Retrieves the set of key-value |params| for the field trial associated with |
| 292 | // the specified |feature|. A feature is associated with at most one field |
| 293 | // trial and selected group. See base/feature_list.h for more information on |
| 294 | // features. If the feature is not enabled, or if there's no associated params, |
| 295 | // returns false and does not modify |params|. Calling this function will |
| 296 | // result in the associated field trial being marked as active if found (i.e. |
| 297 | // group() will be called on it), if it wasn't already. Thread safe. |
Miyoung Shin | b5ad87f | 2019-05-13 20:12:45 | [diff] [blame] | 298 | BASE_EXPORT bool GetFieldTrialParamsByFeature(const base::Feature& feature, |
| 299 | FieldTrialParams* params); |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 300 | |
| 301 | // Retrieves a specific parameter value corresponding to |param_name| for the |
| 302 | // specified field trial, based on its selected group. If the field trial does |
| 303 | // not exist or the specified parameter does not exist, returns an empty |
| 304 | // string. Calling this function will result in the field trial being marked as |
| 305 | // active if found (i.e. group() will be called on it), if it wasn't already. |
| 306 | // Thread safe. |
| 307 | BASE_EXPORT std::string GetFieldTrialParamValue(const std::string& trial_name, |
| 308 | const std::string& param_name); |
| 309 | |
| 310 | // Retrieves a specific parameter value corresponding to |param_name| for the |
| 311 | // field trial associated with the specified |feature|. A feature is associated |
| 312 | // with at most one field trial and selected group. See base/feature_list.h for |
| 313 | // more information on features. If the feature is not enabled, or the |
| 314 | // specified parameter does not exist, returns an empty string. Calling this |
| 315 | // function will result in the associated field trial being marked as active if |
| 316 | // found (i.e. group() will be called on it), if it wasn't already. Thread safe. |
| 317 | BASE_EXPORT std::string GetFieldTrialParamValueByFeature( |
| 318 | const base::Feature& feature, |
| 319 | const std::string& param_name); |
| 320 | |
Takashi Toyoshima | 267198895 | 2024-08-26 05:58:34 | [diff] [blame] | 321 | // Same as GetFieldTrialParamValueByFeature(). But internally relies on |
| 322 | // GetFieldTrialParamsByFeature to handle empty values in the map, and returns |
| 323 | // |default_value| only if |param_name| is not found in the map. |
| 324 | BASE_EXPORT std::string GetFieldTrialParamByFeatureAsString( |
| 325 | const base::Feature& feature, |
| 326 | const std::string& param_name, |
| 327 | const std::string& default_value); |
| 328 | |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 329 | // Same as GetFieldTrialParamValueByFeature(). On top of that, it converts the |
| 330 | // string value into an int using base::StringToInt() and returns it, if |
| 331 | // successful. Otherwise, it returns |default_value|. If the string value is not |
| 332 | // empty and the conversion does not succeed, it produces a warning to LOG. |
| 333 | BASE_EXPORT int GetFieldTrialParamByFeatureAsInt(const base::Feature& feature, |
| 334 | const std::string& param_name, |
| 335 | int default_value); |
| 336 | |
| 337 | // Same as GetFieldTrialParamValueByFeature(). On top of that, it converts the |
| 338 | // string value into a double using base::StringToDouble() and returns it, if |
| 339 | // successful. Otherwise, it returns |default_value|. If the string value is not |
| 340 | // empty and the conversion does not succeed, it produces a warning to LOG. |
| 341 | BASE_EXPORT double GetFieldTrialParamByFeatureAsDouble( |
| 342 | const base::Feature& feature, |
| 343 | const std::string& param_name, |
| 344 | double default_value); |
| 345 | |
| 346 | // Same as GetFieldTrialParamValueByFeature(). On top of that, it converts the |
| 347 | // string value into a boolean and returns it, if successful. Otherwise, it |
| 348 | // returns |default_value|. The only string representations accepted here are |
| 349 | // "true" and "false". If the string value is not empty and the conversion does |
| 350 | // not succeed, it produces a warning to LOG. |
| 351 | BASE_EXPORT bool GetFieldTrialParamByFeatureAsBool( |
| 352 | const base::Feature& feature, |
| 353 | const std::string& param_name, |
| 354 | bool default_value); |
| 355 | |
Minoru Chikamune | fedb827 | 2023-09-27 02:08:24 | [diff] [blame] | 356 | // Same as GetFieldTrialParamValueByFeature(). On top of that, it converts the |
| 357 | // string value into a base::TimeDelta and returns it, if successful. Otherwise, |
| 358 | // it returns `default_value`. If the string value is not empty and the |
| 359 | // conversion does not succeed, it produces a warning to LOG. |
| 360 | BASE_EXPORT base::TimeDelta GetFieldTrialParamByFeatureAsTimeDelta( |
| 361 | const Feature& feature, |
| 362 | const std::string& param_name, |
| 363 | base::TimeDelta default_value); |
| 364 | |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 365 | // Same as GetFieldTrialParamValueByFeature(). On top of that, it converts the |
| 366 | // string value into an Enum and returns it, if successful. Otherwise, it |
| 367 | // returns `default_value`. If the string value is not empty and the conversion |
| 368 | // does not succeed, it produces a warning to LOG. |
sfiera | 01757be6 | 2017-09-20 16:36:13 | [diff] [blame] | 369 | template <typename Enum> |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 370 | Enum GetFieldTrialParamByFeatureAsEnum( |
| 371 | const Feature& feature, |
| 372 | const std::string& param_name, |
| 373 | Enum default_value, |
| 374 | base::span<const typename FeatureParam<Enum, true>::Option> options) { |
| 375 | std::string value = GetFieldTrialParamValueByFeature(feature, param_name); |
| 376 | if (value.empty()) { |
sfiera | 01757be6 | 2017-09-20 16:36:13 | [diff] [blame] | 377 | return default_value; |
| 378 | } |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 379 | for (const auto& option : options) { |
| 380 | if (value == option.name) { |
| 381 | return option.value; |
Fergal Daly | bcac47a | 2020-03-27 01:54:21 | [diff] [blame] | 382 | } |
Fergal Daly | bcac47a | 2020-03-27 01:54:21 | [diff] [blame] | 383 | } |
Peter Kasting | 18e51f8 | 2025-01-14 16:02:38 | [diff] [blame] | 384 | LogInvalidEnumValue(feature, param_name, value, |
| 385 | static_cast<int>(default_value)); |
| 386 | return default_value; |
| 387 | } |
sfiera | 01757be6 | 2017-09-20 16:36:13 | [diff] [blame] | 388 | |
asvitkine | 79ab08c | 2017-01-30 23:27:05 | [diff] [blame] | 389 | } // namespace base |
| 390 | |
| 391 | #endif // BASE_METRICS_FIELD_TRIAL_PARAMS_H_ |