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 // At the moment, a missing default_experiment_name makes the study invalid. | 23 // At the moment, a missing default_experiment_name makes the study invalid. |
24 if (study.default_experiment_name().empty()) { | 24 if (study.default_experiment_name().empty()) { |
25 DVLOG(1) << study.name() << " has no default experiment defined."; | 25 DVLOG(1) << study.name() << " has no default experiment defined."; |
26 return false; | 26 return false; |
27 } | 27 } |
28 if (study.filter().has_min_version() && | 28 if (study.filter().has_min_version() && |
29 !base::Version::IsValidWildcardString(study.filter().min_version())) { | 29 !Version::IsValidWildcardString(study.filter().min_version())) { |
30 DVLOG(1) << study.name() << " has invalid min version: " | 30 DVLOG(1) << study.name() << " has invalid min version: " |
31 << study.filter().min_version(); | 31 << study.filter().min_version(); |
32 return false; | 32 return false; |
33 } | 33 } |
34 if (study.filter().has_max_version() && | 34 if (study.filter().has_max_version() && |
35 !base::Version::IsValidWildcardString(study.filter().max_version())) { | 35 !Version::IsValidWildcardString(study.filter().max_version())) { |
36 DVLOG(1) << study.name() << " has invalid max version: " | 36 DVLOG(1) << study.name() << " has invalid max version: " |
37 << study.filter().max_version(); | 37 << study.filter().max_version(); |
38 return false; | 38 return false; |
39 } | 39 } |
40 | 40 |
41 const std::string& default_group_name = study.default_experiment_name(); | 41 const std::string& default_group_name = study.default_experiment_name(); |
42 base::FieldTrial::Probability divisor = 0; | 42 base::FieldTrial::Probability divisor = 0; |
43 | 43 |
44 bool multiple_assigned_groups = false; | 44 bool multiple_assigned_groups = false; |
45 bool found_default_group = false; | 45 bool found_default_group = false; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 std::vector<ProcessedStudy>* processed_studies) { | 123 std::vector<ProcessedStudy>* processed_studies) { |
124 ProcessedStudy processed_study; | 124 ProcessedStudy processed_study; |
125 if (processed_study.Init(study, is_expired)) { | 125 if (processed_study.Init(study, is_expired)) { |
126 processed_studies->push_back(processed_study); | 126 processed_studies->push_back(processed_study); |
127 return true; | 127 return true; |
128 } | 128 } |
129 return false; | 129 return false; |
130 } | 130 } |
131 | 131 |
132 } // namespace variations | 132 } // namespace variations |
OLD | NEW |