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 "chrome/common/variations/child_process_field_trial_syncer.h" | 5 #include "components/variations/child_process_field_trial_syncer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "components/variations/variations_util.h" | 12 #include "components/variations/variations_util.h" |
13 | 13 |
14 namespace chrome_variations { | 14 namespace variations { |
15 | 15 |
16 ChildProcessFieldTrialSyncer::ChildProcessFieldTrialSyncer( | 16 ChildProcessFieldTrialSyncer::ChildProcessFieldTrialSyncer( |
17 base::FieldTrialList::Observer* observer) | 17 base::FieldTrialList::Observer* observer) |
18 : observer_(observer) {} | 18 : observer_(observer) {} |
19 | 19 |
20 ChildProcessFieldTrialSyncer::~ChildProcessFieldTrialSyncer() {} | 20 ChildProcessFieldTrialSyncer::~ChildProcessFieldTrialSyncer() {} |
21 | 21 |
22 void ChildProcessFieldTrialSyncer::InitFieldTrialObserving( | 22 void ChildProcessFieldTrialSyncer::InitFieldTrialObserving( |
23 const base::CommandLine& command_line) { | 23 const base::CommandLine& command_line) { |
24 // Set up initial set of crash dump data for field trials in this process. | 24 // Set up initial set of crash dump data for field trials in this process. |
25 variations::SetVariationListCrashKeys(); | 25 SetVariationListCrashKeys(); |
26 | 26 |
27 // Listen for field trial activations to report them to the browser. | 27 // Listen for field trial activations to report them to the browser. |
28 base::FieldTrialList::AddObserver(observer_); | 28 base::FieldTrialList::AddObserver(observer_); |
29 | 29 |
30 // Some field trials may have been activated before this point. Notify the | 30 // Some field trials may have been activated before this point. Notify the |
31 // browser of these activations now. To detect these, take the set difference | 31 // browser of these activations now. To detect these, take the set difference |
32 // of currently active trials with the initially active trials. | 32 // of currently active trials with the initially active trials. |
33 base::FieldTrial::ActiveGroups initially_active_trials; | 33 base::FieldTrial::ActiveGroups initially_active_trials; |
34 base::FieldTrialList::GetActiveFieldTrialGroupsFromString( | 34 base::FieldTrialList::GetActiveFieldTrialGroupsFromString( |
35 command_line.GetSwitchValueASCII(switches::kForceFieldTrials), | 35 command_line.GetSwitchValueASCII(switches::kForceFieldTrials), |
(...skipping 12 matching lines...) Expand all Loading... |
48 } | 48 } |
49 | 49 |
50 void ChildProcessFieldTrialSyncer::OnSetFieldTrialGroup( | 50 void ChildProcessFieldTrialSyncer::OnSetFieldTrialGroup( |
51 const std::string& trial_name, | 51 const std::string& trial_name, |
52 const std::string& group_name) { | 52 const std::string& group_name) { |
53 base::FieldTrial* trial = | 53 base::FieldTrial* trial = |
54 base::FieldTrialList::CreateFieldTrial(trial_name, group_name); | 54 base::FieldTrialList::CreateFieldTrial(trial_name, group_name); |
55 // Ensure the trial is marked as "used" by calling group() on it if it is | 55 // Ensure the trial is marked as "used" by calling group() on it if it is |
56 // marked as activated. | 56 // marked as activated. |
57 trial->group(); | 57 trial->group(); |
58 variations::SetVariationListCrashKeys(); | 58 SetVariationListCrashKeys(); |
59 } | 59 } |
60 | 60 |
61 } // namespace chrome_variations | 61 } // namespace variations |
OLD | NEW |