| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // all active FieldTrial groups. Thread safe. | 103 // all active FieldTrial groups. Thread safe. |
| 104 VariationID GetGoogleVariationID(IDCollectionKey key, | 104 VariationID GetGoogleVariationID(IDCollectionKey key, |
| 105 const std::string& trial_name, | 105 const std::string& trial_name, |
| 106 const std::string& group_name); | 106 const std::string& group_name); |
| 107 | 107 |
| 108 // Same as GetGoogleVariationID(), but takes in a hashed |active_group| rather | 108 // Same as GetGoogleVariationID(), but takes in a hashed |active_group| rather |
| 109 // than the string trial and group name. | 109 // than the string trial and group name. |
| 110 VariationID GetGoogleVariationIDFromHashes(IDCollectionKey key, | 110 VariationID GetGoogleVariationIDFromHashes(IDCollectionKey key, |
| 111 const ActiveGroupId& active_group); | 111 const ActiveGroupId& active_group); |
| 112 | 112 |
| 113 // Associates the specified set of key-value |params| with the variation | 113 // Deprecated. Use base::AssociateFieldTrialParams() instead. |
| 114 // specified by |trial_name| and |group_name|. Fails and returns false if the | |
| 115 // specified variation already has params associated with it or the field trial | |
| 116 // is already active (group() has been called on it). Thread safe. | |
| 117 bool AssociateVariationParams(const std::string& trial_name, | 114 bool AssociateVariationParams(const std::string& trial_name, |
| 118 const std::string& group_name, | 115 const std::string& group_name, |
| 119 const std::map<std::string, std::string>& params); | 116 const std::map<std::string, std::string>& params); |
| 120 | 117 |
| 121 // Retrieves the set of key-value |params| for the variation associated with | 118 // Deprecated. Use base::GetFieldTrialParams() instead. |
| 122 // the specified field trial, based on its selected group. If the field trial | |
| 123 // does not exist or its selected group does not have any parameters associated | |
| 124 // with it, returns false and does not modify |params|. Calling this function | |
| 125 // will result in the field trial being marked as active if found (i.e. group() | |
| 126 // will be called on it), if it wasn't already. Currently, this information is | |
| 127 // only available from the browser process. Thread safe. | |
| 128 bool GetVariationParams(const std::string& trial_name, | 119 bool GetVariationParams(const std::string& trial_name, |
| 129 std::map<std::string, std::string>* params); | 120 std::map<std::string, std::string>* params); |
| 130 | 121 |
| 131 // Retrieves the set of key-value |params| for the variation associated with the | 122 // Deprecated. Use base::GetFieldTrialParamsByFeature() instead. |
| 132 // specified |feature|. A feature is associated with at most one variation, | |
| 133 // through the variation's associated field trial, and selected group. See | |
| 134 // base/feature_list.h for more information on features. If the feature is not | |
| 135 // enabled, or if there's no associated variation params, returns false and does | |
| 136 // not modify |params|. Calling this function will result in the associated | |
| 137 // field trial being marked as active if found (i.e. group() will be called on | |
| 138 // it), if it wasn't already. Currently, this information is only available from | |
| 139 // the browser process. Thread safe. | |
| 140 bool GetVariationParamsByFeature(const base::Feature& feature, | 123 bool GetVariationParamsByFeature(const base::Feature& feature, |
| 141 std::map<std::string, std::string>* params); | 124 std::map<std::string, std::string>* params); |
| 142 | 125 |
| 143 // Retrieves a specific parameter value corresponding to |param_name| for the | 126 // Deprecated. Use base::GetFieldTrialParamValue() instead. |
| 144 // variation associated with the specified field trial, based on its selected | |
| 145 // group. If the field trial does not exist or the specified parameter does not | |
| 146 // exist, returns an empty string. Calling this function will result in the | |
| 147 // field trial being marked as active if found (i.e. group() will be called on | |
| 148 // it), if it wasn't already. Currently, this information is only available from | |
| 149 // the browser process. Thread safe. | |
| 150 std::string GetVariationParamValue(const std::string& trial_name, | 127 std::string GetVariationParamValue(const std::string& trial_name, |
| 151 const std::string& param_name); | 128 const std::string& param_name); |
| 152 | 129 |
| 153 // Retrieves a specific parameter value corresponding to |param_name| for the | 130 // Deprecated. Use base::GetFieldTrialParamValueByFeature() instead. |
| 154 // variation associated with the specified |feature|. A feature is associated | |
| 155 // with at most one variation, through the variation's associated field trial, | |
| 156 // and selected group. See base/feature_list.h for more information on | |
| 157 // features. If the feature is not enabled, or the specified parameter does not | |
| 158 // exist, returns an empty string. Calling this function will result in the | |
| 159 // associated field trial being marked as active if found (i.e. group() will be | |
| 160 // called on it), if it wasn't already. Currently, this information is only | |
| 161 // available from the browser process. Thread safe. | |
| 162 std::string GetVariationParamValueByFeature(const base::Feature& feature, | 131 std::string GetVariationParamValueByFeature(const base::Feature& feature, |
| 163 const std::string& param_name); | 132 const std::string& param_name); |
| 164 | 133 |
| 165 // Same as GetVariationParamValueByFeature(). On top of that, it converts the | 134 // Deprecated. Use base::GetFieldTrialParamByFeatureAsInt() instead. |
| 166 // string value into an int using base::StringToInt() and returns it, if | |
| 167 // successful. Otherwise, it returns |default_value|. If the string value is not | |
| 168 // empty and the conversion does not succeed, it produces a warning to LOG. | |
| 169 int GetVariationParamByFeatureAsInt(const base::Feature& feature, | 135 int GetVariationParamByFeatureAsInt(const base::Feature& feature, |
| 170 const std::string& param_name, | 136 const std::string& param_name, |
| 171 int default_value); | 137 int default_value); |
| 172 | 138 |
| 173 // Same as GetVariationParamValueByFeature(). On top of that, it converts the | 139 // Deprecated. Use base::GetFieldTrialParamByFeatureAsDouble() instead. |
| 174 // string value into a double using base::StringToDouble() and returns it, if | |
| 175 // successful. Otherwise, it returns |default_value|. If the string value is not | |
| 176 // empty and the conversion does not succeed, it produces a warning to LOG. | |
| 177 double GetVariationParamByFeatureAsDouble(const base::Feature& feature, | 140 double GetVariationParamByFeatureAsDouble(const base::Feature& feature, |
| 178 const std::string& param_name, | 141 const std::string& param_name, |
| 179 double default_value); | 142 double default_value); |
| 180 | 143 |
| 181 // Same as GetVariationParamValueByFeature(). On top of that, it converts the | 144 // Deprecated. Use base::GetFieldTrialParamByFeatureAsBool() instead. |
| 182 // string value into a boolean and returns it, if successful. Otherwise, it | |
| 183 // returns |default_value|. The only string representations accepted here are | |
| 184 // "true" and "false". If the string value is not empty and the conversion does | |
| 185 // not succeed, it produces a warning to LOG. | |
| 186 bool GetVariationParamByFeatureAsBool(const base::Feature& feature, | 145 bool GetVariationParamByFeatureAsBool(const base::Feature& feature, |
| 187 const std::string& param_name, | 146 const std::string& param_name, |
| 188 bool default_value); | 147 bool default_value); |
| 189 | 148 |
| 190 // Expose some functions for testing. | 149 // Expose some functions for testing. |
| 191 namespace testing { | 150 namespace testing { |
| 192 | 151 |
| 193 // Clears all of the mapped associations. Deprecated, try to use | 152 // Clears all of the mapped associations. Deprecated, try to use |
| 194 // VariationParamsManager instead as it does a lot of work for you | 153 // VariationParamsManager instead as it does a lot of work for you |
| 195 // automatically. | 154 // automatically. |
| 196 void ClearAllVariationIDs(); | 155 void ClearAllVariationIDs(); |
| 197 | 156 |
| 198 // Clears all of the associated params. Deprecated, try to use | 157 // Clears all of the associated params. Deprecated, try to use |
| 199 // VariationParamsManager instead as it does a lot of work for you | 158 // VariationParamsManager instead as it does a lot of work for you |
| 200 // automatically. | 159 // automatically. |
| 201 void ClearAllVariationParams(); | 160 void ClearAllVariationParams(); |
| 202 | 161 |
| 203 } // namespace testing | 162 } // namespace testing |
| 204 | 163 |
| 205 } // namespace variations | 164 } // namespace variations |
| 206 | 165 |
| 207 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 166 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
| OLD | NEW |