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

Side by Side Diff: components/variations/variations_seed_processor.cc

Issue 529183002: Fix crash with forcing variations when the trial exists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
« no previous file with comments | « no previous file | components/variations/variations_seed_processor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/variations/variations_seed_processor.h" 5 #include "components/variations/variations_seed_processor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Check if any experiments need to be forced due to a command line 104 // Check if any experiments need to be forced due to a command line
105 // flag. Force the first experiment with an existing flag. 105 // flag. Force the first experiment with an existing flag.
106 CommandLine* command_line = CommandLine::ForCurrentProcess(); 106 CommandLine* command_line = CommandLine::ForCurrentProcess();
107 for (int i = 0; i < study.experiment_size(); ++i) { 107 for (int i = 0; i < study.experiment_size(); ++i) {
108 const Study_Experiment& experiment = study.experiment(i); 108 const Study_Experiment& experiment = study.experiment(i);
109 if (experiment.has_forcing_flag() && 109 if (experiment.has_forcing_flag() &&
110 command_line->HasSwitch(experiment.forcing_flag())) { 110 command_line->HasSwitch(experiment.forcing_flag())) {
111 scoped_refptr<base::FieldTrial> trial( 111 scoped_refptr<base::FieldTrial> trial(
112 base::FieldTrialList::CreateFieldTrial(study.name(), 112 base::FieldTrialList::CreateFieldTrial(study.name(),
113 experiment.name())); 113 experiment.name()));
114 // If |trial| is NULL, then there might already be a trial forced to a
115 // different group (e.g. via --force-fieldtrials). Break out of the loop,
116 // but don't return, so that variation ids and params for the selected
117 // group will still be picked up.
118 if (!trial)
119 break;
120
114 RegisterExperimentParams(study, experiment); 121 RegisterExperimentParams(study, experiment);
115 RegisterVariationIds(experiment, study.name()); 122 RegisterVariationIds(experiment, study.name());
116 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) { 123 if (study.activation_type() == Study_ActivationType_ACTIVATION_AUTO) {
117 trial->group(); 124 trial->group();
118 // UI Strings can only be overridden from ACTIVATION_AUTO experiments. 125 // UI Strings can only be overridden from ACTIVATION_AUTO experiments.
119 ApplyUIStringOverrides(experiment, override_callback); 126 ApplyUIStringOverrides(experiment, override_callback);
120 } 127 }
121 128
122 DVLOG(1) << "Trial " << study.name() << " forced by flag: " 129 DVLOG(1) << "Trial " << study.name() << " forced by flag: "
123 << experiment.forcing_flag(); 130 << experiment.forcing_flag();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // The field trial was defined from |study|, so the active experiment's name 187 // The field trial was defined from |study|, so the active experiment's name
181 // must be in the |study|. 188 // must be in the |study|.
182 DCHECK_NE(-1, experiment_index); 189 DCHECK_NE(-1, experiment_index);
183 190
184 ApplyUIStringOverrides(study.experiment(experiment_index), 191 ApplyUIStringOverrides(study.experiment(experiment_index),
185 override_callback); 192 override_callback);
186 } 193 }
187 } 194 }
188 195
189 } // namespace variations 196 } // namespace variations
OLDNEW
« no previous file with comments | « no previous file | components/variations/variations_seed_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698