| 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 #include "content/public/common/content_switches.h" | |
| 14 | 13 |
| 15 namespace chrome_variations { | 14 namespace variations { |
| 16 | 15 |
| 17 ChildProcessFieldTrialSyncer::ChildProcessFieldTrialSyncer( | 16 ChildProcessFieldTrialSyncer::ChildProcessFieldTrialSyncer( |
| 18 base::FieldTrialList::Observer* observer) | 17 base::FieldTrialList::Observer* observer) |
| 19 : observer_(observer) {} | 18 : observer_(observer) {} |
| 20 | 19 |
| 21 ChildProcessFieldTrialSyncer::~ChildProcessFieldTrialSyncer() {} | 20 ChildProcessFieldTrialSyncer::~ChildProcessFieldTrialSyncer() {} |
| 22 | 21 |
| 23 void ChildProcessFieldTrialSyncer::InitFieldTrialObserving( | 22 void ChildProcessFieldTrialSyncer::InitFieldTrialObserving( |
| 24 const base::CommandLine& command_line) { | 23 const base::CommandLine& command_line, |
| 24 const char* single_process_switch_name) { |
| 25 // In single-process mode, there is no need to synchronize trials to the | 25 // In single-process mode, there is no need to synchronize trials to the |
| 26 // browser process (because it's the same process), so this class is a no-op. | 26 // browser process (because it's the same process), so this class is a no-op. |
| 27 if (command_line.HasSwitch(switches::kSingleProcess)) | 27 if (command_line.HasSwitch(single_process_switch_name)) |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 // Set up initial set of crash dump data for field trials in this process. | 30 // Set up initial set of crash dump data for field trials in this process. |
| 31 variations::SetVariationListCrashKeys(); | 31 SetVariationListCrashKeys(); |
| 32 | 32 |
| 33 // Listen for field trial activations to report them to the browser. | 33 // Listen for field trial activations to report them to the browser. |
| 34 base::FieldTrialList::AddObserver(observer_); | 34 base::FieldTrialList::AddObserver(observer_); |
| 35 | 35 |
| 36 // Some field trials may have been activated before this point. Notify the | 36 // Some field trials may have been activated before this point. Notify the |
| 37 // browser of these activations now. To detect these, take the set difference | 37 // browser of these activations now. To detect these, take the set difference |
| 38 // of currently active trials with the initially active trials. | 38 // of currently active trials with the initially active trials. |
| 39 base::FieldTrial::ActiveGroups initially_active_trials; | 39 base::FieldTrial::ActiveGroups initially_active_trials; |
| 40 base::FieldTrialList::GetInitiallyActiveFieldTrials(command_line, | 40 base::FieldTrialList::GetInitiallyActiveFieldTrials(command_line, |
| 41 &initially_active_trials); | 41 &initially_active_trials); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ChildProcessFieldTrialSyncer::OnSetFieldTrialGroup( | 55 void ChildProcessFieldTrialSyncer::OnSetFieldTrialGroup( |
| 56 const std::string& trial_name, | 56 const std::string& trial_name, |
| 57 const std::string& group_name) { | 57 const std::string& group_name) { |
| 58 base::FieldTrial* trial = | 58 base::FieldTrial* trial = |
| 59 base::FieldTrialList::CreateFieldTrial(trial_name, group_name); | 59 base::FieldTrialList::CreateFieldTrial(trial_name, group_name); |
| 60 // Ensure the trial is marked as "used" by calling group() on it if it is | 60 // Ensure the trial is marked as "used" by calling group() on it if it is |
| 61 // marked as activated. | 61 // marked as activated. |
| 62 trial->group(); | 62 trial->group(); |
| 63 variations::SetVariationListCrashKeys(); | 63 SetVariationListCrashKeys(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace chrome_variations | 66 } // namespace variations |
| OLD | NEW |