| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/metrics/field_trial_param_associator.h" | 5 #include "base/metrics/field_trial_param_associator.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 field_trial_params_[key] = params; | 33 field_trial_params_[key] = params; |
| 34 return true; | 34 return true; |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool FieldTrialParamAssociator::GetFieldTrialParams( | 37 bool FieldTrialParamAssociator::GetFieldTrialParams( |
| 38 const std::string& trial_name, | 38 const std::string& trial_name, |
| 39 FieldTrialParams* params) { | 39 FieldTrialParams* params) { |
| 40 AutoLock scoped_lock(lock_); | 40 AutoLock scoped_lock(lock_); |
| 41 | 41 |
| 42 const std::string group_name = FieldTrialList::FindFullName(trial_name); | 42 const std::string group_name = FieldTrialList::FindFullName(trial_name); |
| 43 return GetFieldTrialParamsWhileLocked(trial_name, group_name, params); |
| 44 } |
| 45 |
| 46 bool FieldTrialParamAssociator::GetFieldTrialParamsWhileLocked( |
| 47 const std::string& trial_name, |
| 48 const std::string& group_name, |
| 49 FieldTrialParams* params) { |
| 43 const FieldTrialKey key(trial_name, group_name); | 50 const FieldTrialKey key(trial_name, group_name); |
| 44 if (!ContainsKey(field_trial_params_, key)) | 51 if (!ContainsKey(field_trial_params_, key)) |
| 45 return false; | 52 return false; |
| 46 | 53 |
| 47 *params = field_trial_params_[key]; | 54 *params = field_trial_params_[key]; |
| 48 return true; | 55 return true; |
| 49 } | 56 } |
| 50 | 57 |
| 51 void FieldTrialParamAssociator::ClearAllParamsForTesting() { | 58 void FieldTrialParamAssociator::ClearAllParamsForTesting() { |
| 52 AutoLock scoped_lock(lock_); | 59 AutoLock scoped_lock(lock_); |
| 53 field_trial_params_.clear(); | 60 field_trial_params_.clear(); |
| 54 } | 61 } |
| 55 | 62 |
| 56 } // namespace base | 63 } // namespace base |
| OLD | NEW |