Chromium Code Reviews| Index: base/metrics/field_trial.cc |
| diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc |
| index 7efca7a3ef53cdaa8093b880b44d7e469bebc27d..a1ba5172857e20310481f5b1e0c6cf75d6d3beb2 100644 |
| --- a/base/metrics/field_trial.cc |
| +++ b/base/metrics/field_trial.cc |
| @@ -223,6 +223,15 @@ bool FieldTrial::GetActiveGroup(ActiveGroup* active_group) const { |
| return true; |
| } |
| +bool FieldTrial::GetFieldTrialState(FieldTrialState* field_trial_state) const { |
| + if (!enable_field_trial_) |
| + return false; |
| + field_trial_state->trial_name = trial_name_; |
| + field_trial_state->group_name = group_name_; |
| + field_trial_state->activated = group_reported_; |
| + return true; |
| +} |
| + |
| //------------------------------------------------------------------------------ |
| // FieldTrialList methods and members. |
| @@ -387,6 +396,24 @@ void FieldTrialList::StatesToString(std::string* output) { |
| } |
| // static |
| +void FieldTrialList::AllStatesToString(std::string* output) { |
| + FieldTrial::AllGroups all_groups; |
| + GetAllFieldTrialGroups(&all_groups); |
| + for (const FieldTrial::FieldTrialState& trial : all_groups) { |
| + DCHECK_EQ(std::string::npos, |
| + trial.trial_name.find(kPersistentStringSeparator)); |
| + DCHECK_EQ(std::string::npos, |
| + trial.group_name.find(kPersistentStringSeparator)); |
| + if (trial.activated) |
| + output->append(1, kActivationMarker); |
| + output->append(trial.trial_name); |
| + output->append(1, kPersistentStringSeparator); |
| + output->append(trial.group_name); |
| + output->append(1, kPersistentStringSeparator); |
| + } |
| +} |
| + |
| +// static |
| void FieldTrialList::GetActiveFieldTrialGroups( |
| FieldTrial::ActiveGroups* active_groups) { |
| DCHECK(active_groups->empty()); |
| @@ -403,6 +430,21 @@ void FieldTrialList::GetActiveFieldTrialGroups( |
| } |
| // static |
| +void FieldTrialList::GetAllFieldTrialGroups( |
|
Alexei Svitkine (slow)
2014/11/05 22:50:53
Hmm, actually if this method is private, I suggest
Georges Khalil
2014/11/06 18:36:28
Done.
|
| + FieldTrial::AllGroups* all_groups) { |
| + DCHECK(all_groups->empty()); |
| + if (!global_) |
| + return; |
| + AutoLock auto_lock(global_->lock_); |
| + |
| + for (const auto& it : global_->registered_) { |
|
Alexei Svitkine (slow)
2014/11/05 22:50:53
Nit: I prefer to explicitly name the type for clar
Georges Khalil
2014/11/06 18:36:28
Type is std::pair<string, base::FieldTrial *> and
|
| + FieldTrial::FieldTrialState field_trial_state; |
| + if (it.second->GetFieldTrialState(&field_trial_state)) |
| + all_groups->push_back(field_trial_state); |
| + } |
| +} |
| + |
| +// static |
| bool FieldTrialList::CreateTrialsFromString( |
| const std::string& trials_string, |
| FieldTrialActivationMode mode, |