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 | 8 |
9 #include "base/version.h" | 9 #include "base/version.h" |
10 #include "components/variations/proto/study.pb.h" | 10 #include "components/variations/proto/study.pb.h" |
11 | 11 |
12 namespace chrome_variations { | 12 namespace chrome_variations { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Validates the sanity of |study| and computes the total probability. | 16 // Validates the sanity of |study| and computes the total probability. |
17 bool ValidateStudyAndComputeTotalProbability( | 17 bool ValidateStudyAndComputeTotalProbability( |
18 const Study& study, | 18 const Study& study, |
19 base::FieldTrial::Probability* total_probability) { | 19 base::FieldTrial::Probability* total_probability) { |
20 // At the moment, a missing default_experiment_name makes the study invalid. | 20 // At the moment, a missing default_experiment_name makes the study invalid. |
21 if (study.default_experiment_name().empty()) { | 21 if (study.default_experiment_name().empty()) { |
22 DVLOG(1) << study.name() << " has no default experiment defined."; | 22 DVLOG(1) << study.name() << " has no default experiment defined."; |
23 return false; | 23 return false; |
24 } | 24 } |
25 if (study.filter().has_min_version() && | 25 if (study.filter().has_min_version() && |
26 !Version::IsValidWildcardString(study.filter().min_version())) { | 26 !base::Version::IsValidWildcardString(study.filter().min_version())) { |
27 DVLOG(1) << study.name() << " has invalid min version: " | 27 DVLOG(1) << study.name() << " has invalid min version: " |
28 << study.filter().min_version(); | 28 << study.filter().min_version(); |
29 return false; | 29 return false; |
30 } | 30 } |
31 if (study.filter().has_max_version() && | 31 if (study.filter().has_max_version() && |
32 !Version::IsValidWildcardString(study.filter().max_version())) { | 32 !base::Version::IsValidWildcardString(study.filter().max_version())) { |
33 DVLOG(1) << study.name() << " has invalid max version: " | 33 DVLOG(1) << study.name() << " has invalid max version: " |
34 << study.filter().max_version(); | 34 << study.filter().max_version(); |
35 return false; | 35 return false; |
36 } | 36 } |
37 | 37 |
38 const std::string& default_group_name = study.default_experiment_name(); | 38 const std::string& default_group_name = study.default_experiment_name(); |
39 base::FieldTrial::Probability divisor = 0; | 39 base::FieldTrial::Probability divisor = 0; |
40 | 40 |
41 bool found_default_group = false; | 41 bool found_default_group = false; |
42 std::set<std::string> experiment_names; | 42 std::set<std::string> experiment_names; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 std::vector<ProcessedStudy>* processed_studies) { | 98 std::vector<ProcessedStudy>* processed_studies) { |
99 ProcessedStudy processed_study; | 99 ProcessedStudy processed_study; |
100 if (processed_study.Init(study, is_expired)) { | 100 if (processed_study.Init(study, is_expired)) { |
101 processed_studies->push_back(processed_study); | 101 processed_studies->push_back(processed_study); |
102 return true; | 102 return true; |
103 } | 103 } |
104 return false; | 104 return false; |
105 } | 105 } |
106 | 106 |
107 } // namespace chrome_variations | 107 } // namespace chrome_variations |
OLD | NEW |