| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 // Singleton helper class that keeps track of the parameters of all variations | 103 // Singleton helper class that keeps track of the parameters of all variations |
| 104 // and ensures access to these is thread-safe. | 104 // and ensures access to these is thread-safe. |
| 105 class VariationsParamAssociator { | 105 class VariationsParamAssociator { |
| 106 public: | 106 public: |
| 107 typedef std::pair<std::string, std::string> VariationKey; | 107 typedef std::pair<std::string, std::string> VariationKey; |
| 108 typedef std::map<std::string, std::string> VariationParams; | 108 typedef std::map<std::string, std::string> VariationParams; |
| 109 | 109 |
| 110 // Retrieve the singleton. | 110 // Retrieve the singleton. |
| 111 static VariationsParamAssociator* GetInstance() { | 111 static VariationsParamAssociator* GetInstance() { |
| 112 return base::Singleton<VariationsParamAssociator>::get(); | 112 return base::Singleton< |
| 113 VariationsParamAssociator, |
| 114 base::LeakySingletonTraits<VariationsParamAssociator>>::get(); |
| 113 } | 115 } |
| 114 | 116 |
| 115 bool AssociateVariationParams(const std::string& trial_name, | 117 bool AssociateVariationParams(const std::string& trial_name, |
| 116 const std::string& group_name, | 118 const std::string& group_name, |
| 117 const VariationParams& params) { | 119 const VariationParams& params) { |
| 118 base::AutoLock scoped_lock(lock_); | 120 base::AutoLock scoped_lock(lock_); |
| 119 | 121 |
| 120 if (base::FieldTrialList::IsTrialActive(trial_name)) | 122 if (base::FieldTrialList::IsTrialActive(trial_name)) |
| 121 return false; | 123 return false; |
| 122 | 124 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); | 231 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); |
| 230 } | 232 } |
| 231 | 233 |
| 232 void ClearAllVariationParams() { | 234 void ClearAllVariationParams() { |
| 233 VariationsParamAssociator::GetInstance()->ClearAllParamsForTesting(); | 235 VariationsParamAssociator::GetInstance()->ClearAllParamsForTesting(); |
| 234 } | 236 } |
| 235 | 237 |
| 236 } // namespace testing | 238 } // namespace testing |
| 237 | 239 |
| 238 } // namespace variations | 240 } // namespace variations |
| OLD | NEW |