1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ios/chrome/browser/metrics/field_trial_synchronizer.h"
9 #include "base/logging.h"
10 #include "components/crash_keys/crash_keys.h"
11 #include "components/variations/active_field_trials.h"
15 FieldTrialSynchronizer::FieldTrialSynchronizer() {
16 base::FieldTrialList::AddObserver(this);
17 SynchronizeCrashKeyExperimentList();
20 FieldTrialSynchronizer::~FieldTrialSynchronizer() {
21 base::FieldTrialList::RemoveObserver(this);
24 void FieldTrialSynchronizer::OnFieldTrialGroupFinalized(
25 const std::string
& field_trial_name
,
26 const std::string
& group_name
) {
27 CHECK(!field_trial_name
.empty() && !group_name
.empty());
28 SynchronizeCrashKeyExperimentList();
31 void FieldTrialSynchronizer::SynchronizeCrashKeyExperimentList() {
32 // TODO(sdefresne): uses variations::SetVariationsListCrashKeys once it is
33 // componentized and remove this code duplication. http://crbug.com/520070
34 // tracks the componentization effort.
35 std::vector
<std::string
> experiment_strings
;
36 variations::GetFieldTrialActiveGroupIdsAsStrings(&experiment_strings
);
37 crash_keys::SetVariationsList(experiment_strings
);