Index: components/variations/processed_study.cc |
diff --git a/components/variations/processed_study.cc b/components/variations/processed_study.cc |
index 8c1f8d0f8a1cd6852cd2fb234dbec9267b4f8710..28f5453f5e0bbb58facf1f4b0504451c142c7e97 100644 |
--- a/components/variations/processed_study.cc |
+++ b/components/variations/processed_study.cc |
@@ -21,11 +21,6 @@ bool ValidateStudyAndComputeTotalProbability( |
base::FieldTrial::Probability* total_probability, |
bool* all_assignments_to_one_group, |
std::string* single_feature_name) { |
- // At the moment, a missing default_experiment_name makes the study invalid. |
- if (study.default_experiment_name().empty()) { |
- DVLOG(1) << study.name() << " has no default experiment defined."; |
- return false; |
- } |
if (study.filter().has_min_version() && |
!base::Version::IsValidWildcardString(study.filter().min_version())) { |
DVLOG(1) << study.name() << " has invalid min version: " |
@@ -92,7 +87,9 @@ bool ValidateStudyAndComputeTotalProbability( |
found_default_group = true; |
} |
- if (!found_default_group) { |
+ // Specifying a default experiment is optional, so finding it in the |
+ // experiment list is only required when it is specified. |
+ if (!study.default_experiment_name().empty() && !found_default_group) { |
DVLOG(1) << study.name() << " is missing default experiment in its " |
rkaplow
2017/01/04 15:58:25
optional, could add default_group_name to the DVLO
jwd
2017/01/04 21:10:22
Done.
|
<< "experiment list"; |
// The default group was not found in the list of groups. This study is not |
@@ -113,6 +110,10 @@ bool ValidateStudyAndComputeTotalProbability( |
} // namespace |
+// static |
+const std::string ProcessedStudy::kGenericDefaultExperimentName = |
+ "VariationsDefaultExperiment"; |
+ |
ProcessedStudy::ProcessedStudy() |
: study_(NULL), |
total_probability_(0), |
@@ -150,6 +151,13 @@ int ProcessedStudy::GetExperimentIndexByName(const std::string& name) const { |
return -1; |
} |
+const std::string& ProcessedStudy::GetDefaultExperimentName() const { |
+ if (study_->default_experiment_name().empty()) |
+ return kGenericDefaultExperimentName; |
+ |
+ return study_->default_experiment_name(); |
+} |
+ |
// static |
bool ProcessedStudy::ValidateAndAppendStudy( |
const Study* study, |