| 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 "components/variations/variations_associated_data.h" | 5 #include "components/variations/variations_associated_data.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 bool AssociateVariationParams(const std::string& trial_name, | 122 bool AssociateVariationParams(const std::string& trial_name, |
| 123 const std::string& group_name, | 123 const std::string& group_name, |
| 124 const VariationParams& params) { | 124 const VariationParams& params) { |
| 125 base::AutoLock scoped_lock(lock_); | 125 base::AutoLock scoped_lock(lock_); |
| 126 | 126 |
| 127 if (base::FieldTrialList::IsTrialActive(trial_name)) | 127 if (base::FieldTrialList::IsTrialActive(trial_name)) |
| 128 return false; | 128 return false; |
| 129 | 129 |
| 130 const VariationKey key(trial_name, group_name); | 130 const VariationKey key(trial_name, group_name); |
| 131 if (ContainsKey(variation_params_, key)) | 131 if (base::ContainsKey(variation_params_, key)) |
| 132 return false; | 132 return false; |
| 133 | 133 |
| 134 variation_params_[key] = params; | 134 variation_params_[key] = params; |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool GetVariationParams(const std::string& trial_name, | 138 bool GetVariationParams(const std::string& trial_name, |
| 139 VariationParams* params) { | 139 VariationParams* params) { |
| 140 base::AutoLock scoped_lock(lock_); | 140 base::AutoLock scoped_lock(lock_); |
| 141 | 141 |
| 142 const std::string group_name = | 142 const std::string group_name = |
| 143 base::FieldTrialList::FindFullName(trial_name); | 143 base::FieldTrialList::FindFullName(trial_name); |
| 144 const VariationKey key(trial_name, group_name); | 144 const VariationKey key(trial_name, group_name); |
| 145 if (!ContainsKey(variation_params_, key)) | 145 if (!base::ContainsKey(variation_params_, key)) |
| 146 return false; | 146 return false; |
| 147 | 147 |
| 148 *params = variation_params_[key]; | 148 *params = variation_params_[key]; |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void ClearAllParamsForTesting() { | 152 void ClearAllParamsForTesting() { |
| 153 base::AutoLock scoped_lock(lock_); | 153 base::AutoLock scoped_lock(lock_); |
| 154 variation_params_.clear(); | 154 variation_params_.clear(); |
| 155 } | 155 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); | 280 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void ClearAllVariationParams() { | 283 void ClearAllVariationParams() { |
| 284 VariationsParamAssociator::GetInstance()->ClearAllParamsForTesting(); | 284 VariationsParamAssociator::GetInstance()->ClearAllParamsForTesting(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace testing | 287 } // namespace testing |
| 288 | 288 |
| 289 } // namespace variations | 289 } // namespace variations |
| OLD | NEW |