OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
6 #define COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 6 #define COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // it), if it wasn't already. Currently, this information is only available from | 145 // it), if it wasn't already. Currently, this information is only available from |
146 // the browser process. Thread safe. | 146 // the browser process. Thread safe. |
147 std::string GetVariationParamValue(const std::string& trial_name, | 147 std::string GetVariationParamValue(const std::string& trial_name, |
148 const std::string& param_name); | 148 const std::string& param_name); |
149 | 149 |
150 // Retrieves a specific parameter value corresponding to |param_name| for the | 150 // Retrieves a specific parameter value corresponding to |param_name| for the |
151 // variation associated with the specified |feature|. A feature is associated | 151 // variation associated with the specified |feature|. A feature is associated |
152 // with at most one variation, through the variation's associated field trial, | 152 // with at most one variation, through the variation's associated field trial, |
153 // and selected group. See base/feature_list.h for more information on | 153 // and selected group. See base/feature_list.h for more information on |
154 // features. If the feature is not enabled, or the specified parameter does not | 154 // features. If the feature is not enabled, or the specified parameter does not |
155 // exist, returns an empty string.Calling this function will result in the | 155 // exist, returns an empty string. Calling this function will result in the |
156 // associated field trial being marked as active if found (i.e. group() will be | 156 // associated field trial being marked as active if found (i.e. group() will be |
157 // called on it), if it wasn't already. Currently, this information is only | 157 // called on it), if it wasn't already. Currently, this information is only |
158 // available from the browser process. Thread safe. | 158 // available from the browser process. Thread safe. |
159 std::string GetVariationParamValueByFeature(const base::Feature& feature, | 159 std::string GetVariationParamValueByFeature(const base::Feature& feature, |
160 const std::string& param_name); | 160 const std::string& param_name); |
161 | 161 |
| 162 // Same as GetVariationParamValueByFeature(). On top of that, it converts the |
| 163 // string value into an int using base::StringToInt() and returns it, if |
| 164 // successful. Otherwise, it returns |default_value|. If the string value is not |
| 165 // empty and the conversion does not succeed, it produces a warning to LOG. |
| 166 int GetVariationParamByFeatureAsInt(const base::Feature& feature, |
| 167 const std::string& param_name, |
| 168 int default_value); |
| 169 |
| 170 // Same as GetVariationParamValueByFeature(). On top of that, it converts the |
| 171 // string value into a double using base::StringToDouble() and returns it, if |
| 172 // successful. Otherwise, it returns |default_value|. If the string value is not |
| 173 // empty and the conversion does not succeed, it produces a warning to LOG. |
| 174 double GetVariationParamByFeatureAsDouble(const base::Feature& feature, |
| 175 const std::string& param_name, |
| 176 double default_value); |
| 177 |
| 178 // Same as GetVariationParamValueByFeature(). On top of that, it converts the |
| 179 // string value into a boolean and returns it, if successful. Otherwise, it |
| 180 // returns |default_value|. The only string representations accepted here are |
| 181 // "true" and "false". If the string value is not empty and the conversion does |
| 182 // not succeed, it produces a warning to LOG. |
| 183 bool GetVariationParamByFeatureAsBool(const base::Feature& feature, |
| 184 const std::string& param_name, |
| 185 bool default_value); |
| 186 |
162 // Expose some functions for testing. | 187 // Expose some functions for testing. |
163 namespace testing { | 188 namespace testing { |
164 | 189 |
165 // Clears all of the mapped associations. Deprecated, try to use | 190 // Clears all of the mapped associations. Deprecated, try to use |
166 // VariationParamsManager instead as it does a lot of work for you | 191 // VariationParamsManager instead as it does a lot of work for you |
167 // automatically. | 192 // automatically. |
168 void ClearAllVariationIDs(); | 193 void ClearAllVariationIDs(); |
169 | 194 |
170 // Clears all of the associated params. Deprecated, try to use | 195 // Clears all of the associated params. Deprecated, try to use |
171 // VariationParamsManager instead as it does a lot of work for you | 196 // VariationParamsManager instead as it does a lot of work for you |
172 // automatically. | 197 // automatically. |
173 void ClearAllVariationParams(); | 198 void ClearAllVariationParams(); |
174 | 199 |
175 } // namespace testing | 200 } // namespace testing |
176 | 201 |
177 } // namespace variations | 202 } // namespace variations |
178 | 203 |
179 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 204 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
OLD | NEW |