Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: chrome/common/variations/child_process_field_trial_syncer.cc

Issue 2504163005: Fix getting initially active trials with shared memory. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« base/metrics/field_trial.cc ('K') | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/common/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"
(...skipping 13 matching lines...) Expand all
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 variations::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::GetInitiallyActiveFieldTrials(command_line,
35 command_line.GetSwitchValueASCII(switches::kForceFieldTrials), 35 &initially_active_trials);
36 &initially_active_trials);
37 std::set<std::string> initially_active_trials_set; 36 std::set<std::string> initially_active_trials_set;
38 for (const auto& entry : initially_active_trials) { 37 for (const auto& entry : initially_active_trials) {
39 initially_active_trials_set.insert(std::move(entry.trial_name)); 38 initially_active_trials_set.insert(std::move(entry.trial_name));
40 } 39 }
41 40
42 base::FieldTrial::ActiveGroups current_active_trials; 41 base::FieldTrial::ActiveGroups current_active_trials;
43 base::FieldTrialList::GetActiveFieldTrialGroups(&current_active_trials); 42 base::FieldTrialList::GetActiveFieldTrialGroups(&current_active_trials);
44 for (const auto& trial : current_active_trials) { 43 for (const auto& trial : current_active_trials) {
45 if (!base::ContainsKey(initially_active_trials_set, trial.trial_name)) 44 if (!base::ContainsKey(initially_active_trials_set, trial.trial_name))
46 observer_->OnFieldTrialGroupFinalized(trial.trial_name, trial.group_name); 45 observer_->OnFieldTrialGroupFinalized(trial.trial_name, trial.group_name);
47 } 46 }
48 } 47 }
49 48
50 void ChildProcessFieldTrialSyncer::OnSetFieldTrialGroup( 49 void ChildProcessFieldTrialSyncer::OnSetFieldTrialGroup(
51 const std::string& trial_name, 50 const std::string& trial_name,
52 const std::string& group_name) { 51 const std::string& group_name) {
53 base::FieldTrial* trial = 52 base::FieldTrial* trial =
54 base::FieldTrialList::CreateFieldTrial(trial_name, group_name); 53 base::FieldTrialList::CreateFieldTrial(trial_name, group_name);
55 // Ensure the trial is marked as "used" by calling group() on it if it is 54 // Ensure the trial is marked as "used" by calling group() on it if it is
56 // marked as activated. 55 // marked as activated.
57 trial->group(); 56 trial->group();
58 variations::SetVariationListCrashKeys(); 57 variations::SetVariationListCrashKeys();
59 } 58 }
60 59
61 } // namespace chrome_variations 60 } // namespace chrome_variations
OLDNEW
« base/metrics/field_trial.cc ('K') | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698