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 <string> | 9 #include <string> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 const std::string& trial_name, | 75 const std::string& trial_name, |
76 const std::string& group_name, | 76 const std::string& group_name, |
77 VariationID id); | 77 VariationID id); |
78 | 78 |
79 // As above, but overwrites any previously set id. Thread safe. | 79 // As above, but overwrites any previously set id. Thread safe. |
80 void AssociateGoogleVariationIDForce(IDCollectionKey key, | 80 void AssociateGoogleVariationIDForce(IDCollectionKey key, |
81 const std::string& trial_name, | 81 const std::string& trial_name, |
82 const std::string& group_name, | 82 const std::string& group_name, |
83 VariationID id); | 83 VariationID id); |
84 | 84 |
| 85 // As above, but takes an ActiveGroupId hash pair, rather than the string names. |
| 86 void AssociateGoogleVariationIDForceHashes(IDCollectionKey key, |
| 87 const ActiveGroupId& active_group, |
| 88 VariationID id); |
| 89 |
85 // Retrieve the variations::VariationID associated with a FieldTrial group for | 90 // Retrieve the variations::VariationID associated with a FieldTrial group for |
86 // collection |key|. The group is denoted by |trial_name| and |group_name|. | 91 // collection |key|. The group is denoted by |trial_name| and |group_name|. |
87 // This will return variations::kEmptyID if there is currently no associated ID | 92 // This will return variations::kEmptyID if there is currently no associated ID |
88 // for the named group. This API can be nicely combined with | 93 // for the named group. This API can be nicely combined with |
89 // FieldTrial::GetActiveFieldTrialGroups() to enumerate the variation IDs for | 94 // FieldTrial::GetActiveFieldTrialGroups() to enumerate the variation IDs for |
90 // all active FieldTrial groups. Thread safe. | 95 // all active FieldTrial groups. Thread safe. |
91 VariationID GetGoogleVariationID(IDCollectionKey key, | 96 VariationID GetGoogleVariationID(IDCollectionKey key, |
92 const std::string& trial_name, | 97 const std::string& trial_name, |
93 const std::string& group_name); | 98 const std::string& group_name); |
94 | 99 |
| 100 // Same as GetGoogleVariationID(), but takes in a hashed |active_group| rather |
| 101 // than the string trial and group name. |
| 102 VariationID GetGoogleVariationIDFromHashes(IDCollectionKey key, |
| 103 const ActiveGroupId& active_group); |
| 104 |
95 // Associates the specified set of key-value |params| with the variation | 105 // Associates the specified set of key-value |params| with the variation |
96 // specified by |trial_name| and |group_name|. Fails and returns false if the | 106 // specified by |trial_name| and |group_name|. Fails and returns false if the |
97 // specified variation already has params associated with it or the field trial | 107 // specified variation already has params associated with it or the field trial |
98 // is already active (group() has been called on it). Thread safe. | 108 // is already active (group() has been called on it). Thread safe. |
99 bool AssociateVariationParams(const std::string& trial_name, | 109 bool AssociateVariationParams(const std::string& trial_name, |
100 const std::string& group_name, | 110 const std::string& group_name, |
101 const std::map<std::string, std::string>& params); | 111 const std::map<std::string, std::string>& params); |
102 | 112 |
103 // Retrieves the set of key-value |params| for the variation associated with | 113 // Retrieves the set of key-value |params| for the variation associated with |
104 // the specified field trial, based on its selected group. If the field trial | 114 // the specified field trial, based on its selected group. If the field trial |
(...skipping 22 matching lines...) Expand all Loading... |
127 void ClearAllVariationIDs(); | 137 void ClearAllVariationIDs(); |
128 | 138 |
129 // Clears all of the associated params. | 139 // Clears all of the associated params. |
130 void ClearAllVariationParams(); | 140 void ClearAllVariationParams(); |
131 | 141 |
132 } // namespace testing | 142 } // namespace testing |
133 | 143 |
134 } // namespace variations | 144 } // namespace variations |
135 | 145 |
136 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ | 146 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ |
OLD | NEW |