| OLD | NEW |
| 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/processed_study.h" | 5 #include "components/variations/processed_study.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/version.h" | 10 #include "base/version.h" |
| 11 #include "components/variations/proto/study.pb.h" | 11 #include "components/variations/proto/study.pb.h" |
| 12 | 12 |
| 13 namespace variations { | 13 namespace variations { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Validates the sanity of |study| and computes the total probability and | 17 // Validates the sanity of |study| and computes the total probability and |
| 18 // whether all assignments are to a single group. | 18 // whether all assignments are to a single group. |
| 19 bool ValidateStudyAndComputeTotalProbability( | 19 bool ValidateStudyAndComputeTotalProbability( |
| 20 const Study& study, | 20 const Study& study, |
| 21 base::FieldTrial::Probability* total_probability, | 21 base::FieldTrial::Probability* total_probability, |
| 22 bool* all_assignments_to_one_group, | 22 bool* all_assignments_to_one_group, |
| 23 std::string* single_feature_name) { | 23 std::string* single_feature_name) { |
| 24 // At the moment, a missing default_experiment_name makes the study invalid. | 24 // At the moment, a missing default_experiment_name makes the study invalid. |
| 25 if (study.default_experiment_name().empty()) { | 25 if (study.default_experiment_name().empty()) { |
| 26 DVLOG(1) << study.name() << " has no default experiment defined."; | 26 DVLOG(1) << study.name() << " has no default experiment defined."; |
| 27 return false; | 27 return false; |
| 28 } | 28 } |
| 29 if (study.filter().has_min_version() && | 29 if (study.filter().has_min_version() && |
| 30 !Version::IsValidWildcardString(study.filter().min_version())) { | 30 !base::Version::IsValidWildcardString(study.filter().min_version())) { |
| 31 DVLOG(1) << study.name() << " has invalid min version: " | 31 DVLOG(1) << study.name() << " has invalid min version: " |
| 32 << study.filter().min_version(); | 32 << study.filter().min_version(); |
| 33 return false; | 33 return false; |
| 34 } | 34 } |
| 35 if (study.filter().has_max_version() && | 35 if (study.filter().has_max_version() && |
| 36 !Version::IsValidWildcardString(study.filter().max_version())) { | 36 !base::Version::IsValidWildcardString(study.filter().max_version())) { |
| 37 DVLOG(1) << study.name() << " has invalid max version: " | 37 DVLOG(1) << study.name() << " has invalid max version: " |
| 38 << study.filter().max_version(); | 38 << study.filter().max_version(); |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 | 41 |
| 42 const std::string& default_group_name = study.default_experiment_name(); | 42 const std::string& default_group_name = study.default_experiment_name(); |
| 43 base::FieldTrial::Probability divisor = 0; | 43 base::FieldTrial::Probability divisor = 0; |
| 44 | 44 |
| 45 bool multiple_assigned_groups = false; | 45 bool multiple_assigned_groups = false; |
| 46 bool found_default_group = false; | 46 bool found_default_group = false; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 std::vector<ProcessedStudy>* processed_studies) { | 157 std::vector<ProcessedStudy>* processed_studies) { |
| 158 ProcessedStudy processed_study; | 158 ProcessedStudy processed_study; |
| 159 if (processed_study.Init(study, is_expired)) { | 159 if (processed_study.Init(study, is_expired)) { |
| 160 processed_studies->push_back(processed_study); | 160 processed_studies->push_back(processed_study); |
| 161 return true; | 161 return true; |
| 162 } | 162 } |
| 163 return false; | 163 return false; |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace variations | 166 } // namespace variations |
| OLD | NEW |