Chromium Code Reviews| Index: base/metrics/field_trial_param_associator.cc |
| diff --git a/base/metrics/field_trial_param_associator.cc b/base/metrics/field_trial_param_associator.cc |
| index b96cc396df874689af034691d9479a780ae78417..9531e13afb78a7f6f560fe465717a0f368f2c8eb 100644 |
| --- a/base/metrics/field_trial_param_associator.cc |
| +++ b/base/metrics/field_trial_param_associator.cc |
| @@ -37,9 +37,28 @@ bool FieldTrialParamAssociator::AssociateFieldTrialParams( |
| bool FieldTrialParamAssociator::GetFieldTrialParams( |
| const std::string& trial_name, |
| FieldTrialParams* params) { |
| + FieldTrial* field_trial = FieldTrialList::Find(trial_name); |
| + if (!field_trial) |
| + return false; |
| + |
| + // We try looking for the params in field_trial_params_ via |
| + // GetFieldTrialParamsWithoutFallback. If it's not there, then try to look it |
|
Alexei Svitkine (slow)
2016/11/24 17:56:32
Nit: The first sentence doesn't add much to the co
lawrencewu
2016/11/24 21:50:36
Done.
|
| + // up in shared memory. |
| + if (GetFieldTrialParamsWithoutFallback(trial_name, field_trial->group_name(), |
| + params)) { |
| + return true; |
| + } |
| + |
| + // TODO(lawrencewu): add the params to field_trial_params_ for next time. |
| + return FieldTrialList::GetParamsFromSharedMemory(field_trial, params); |
| +} |
| + |
| +bool FieldTrialParamAssociator::GetFieldTrialParamsWithoutFallback( |
| + const std::string& trial_name, |
| + const std::string& group_name, |
| + FieldTrialParams* params) { |
| AutoLock scoped_lock(lock_); |
| - const std::string group_name = FieldTrialList::FindFullName(trial_name); |
| const FieldTrialKey key(trial_name, group_name); |
| if (!ContainsKey(field_trial_params_, key)) |
| return false; |
| @@ -51,6 +70,12 @@ bool FieldTrialParamAssociator::GetFieldTrialParams( |
| void FieldTrialParamAssociator::ClearAllParamsForTesting() { |
| AutoLock scoped_lock(lock_); |
| field_trial_params_.clear(); |
| + FieldTrialList::ClearParamsFromSharedMemoryForTesting(); |
| +} |
| + |
| +void FieldTrialParamAssociator::ClearAllCachedParamsForTesting() { |
| + AutoLock scoped_lock(lock_); |
| + field_trial_params_.clear(); |
| } |
| } // namespace base |