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

Unified Diff: components/variations/variations_seed_processor.cc

Issue 2919143002: Fix variations crashes when the chosen trial group is not in study. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/variations/variations_seed_processor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/variations_seed_processor.cc
diff --git a/components/variations/variations_seed_processor.cc b/components/variations/variations_seed_processor.cc
index 5c88264c00a807dbab1afd8594a0fbfaeab4af81..c1bb22f5762577aa305ac5f06eafbcf13e33255c 100644
--- a/components/variations/variations_seed_processor.cc
+++ b/components/variations/variations_seed_processor.cc
@@ -101,9 +101,11 @@ void RegisterFeatureOverrides(const ProcessedStudy& processed_study,
base::FeatureList* feature_list) {
const std::string& group_name = trial->GetGroupNameWithoutActivation();
int experiment_index = processed_study.GetExperimentIndexByName(group_name);
- // The field trial was defined from |study|, so the active experiment's name
- // must be in the |study|.
- DCHECK_NE(-1, experiment_index);
+ // If the chosen experiment was not found in the study, simply return.
+ // Although not normally expected, but could happen in exception cases, see
+ // tests: ExpiredStudy_NoDefaultGroup, ExistingFieldTrial_ExpiredByConfig
+ if (experiment_index == -1)
+ return;
const Study& study = *processed_study.study();
const Study_Experiment& experiment = study.experiment(experiment_index);
@@ -325,13 +327,13 @@ void VariationsSeedProcessor::CreateTrialFromStudy(
// UI Strings can only be overridden from ACTIVATION_AUTO experiments.
int experiment_index = processed_study.GetExperimentIndexByName(group_name);
-
- // The field trial was defined from |study|, so the active experiment's name
- // must be in the |study|.
- DCHECK_NE(-1, experiment_index);
-
- ApplyUIStringOverrides(study.experiment(experiment_index),
- override_callback);
+ // If the chosen experiment was not found in the study, simply return.
+ // Although not normally expected, but could happen in exception cases, see
+ // tests: ExpiredStudy_NoDefaultGroup, ExistingFieldTrial_ExpiredByConfig
+ if (experiment_index != -1) {
+ ApplyUIStringOverrides(study.experiment(experiment_index),
+ override_callback);
+ }
}
}
« 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