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 #include "chrome/common/metrics/variations/variations_associated_data.h" | 5 #include "chrome/common/metrics/variations/variations_associated_data.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 const std::string group_name = | 125 const std::string group_name = |
126 base::FieldTrialList::FindFullName(trial_name); | 126 base::FieldTrialList::FindFullName(trial_name); |
127 const VariationKey key(trial_name, group_name); | 127 const VariationKey key(trial_name, group_name); |
128 if (!ContainsKey(variation_params_, key)) | 128 if (!ContainsKey(variation_params_, key)) |
129 return false; | 129 return false; |
130 | 130 |
131 *params = variation_params_[key]; | 131 *params = variation_params_[key]; |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
| 135 void ClearAllParamsForTesting() { |
| 136 base::AutoLock scoped_lock(lock_); |
| 137 variation_params_.clear(); |
| 138 } |
| 139 |
135 private: | 140 private: |
136 friend struct DefaultSingletonTraits<VariationsParamAssociator>; | 141 friend struct DefaultSingletonTraits<VariationsParamAssociator>; |
137 | 142 |
138 VariationsParamAssociator() {} | 143 VariationsParamAssociator() {} |
139 ~VariationsParamAssociator() {} | 144 ~VariationsParamAssociator() {} |
140 | 145 |
141 // Tests whether a field trial is active (i.e. group() has been called on it). | 146 // Tests whether a field trial is active (i.e. group() has been called on it). |
142 // TODO(asvitkine): Expose this as an API on base::FieldTrial. | 147 // TODO(asvitkine): Expose this as an API on base::FieldTrial. |
143 bool IsFieldTrialActive(const std::string& trial_name) { | 148 bool IsFieldTrialActive(const std::string& trial_name) { |
144 base::FieldTrial::ActiveGroups active_groups; | 149 base::FieldTrial::ActiveGroups active_groups; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 220 } |
216 | 221 |
217 // Functions below are exposed for testing explicitly behind this namespace. | 222 // Functions below are exposed for testing explicitly behind this namespace. |
218 // They simply wrap existing functions in this file. | 223 // They simply wrap existing functions in this file. |
219 namespace testing { | 224 namespace testing { |
220 | 225 |
221 void ClearAllVariationIDs() { | 226 void ClearAllVariationIDs() { |
222 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); | 227 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); |
223 } | 228 } |
224 | 229 |
| 230 void ClearAllVariationParams() { |
| 231 VariationsParamAssociator::GetInstance()->ClearAllParamsForTesting(); |
| 232 } |
| 233 |
225 } // namespace testing | 234 } // namespace testing |
226 | 235 |
227 } // namespace chrome_variations | 236 } // namespace chrome_variations |
OLD | NEW |