Chromium Code Reviews| 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" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 base::FieldTrial::Probability total_probability = 0; | 84 base::FieldTrial::Probability total_probability = 0; |
| 85 if (!ValidateStudyAndComputeTotalProbability(*study, &total_probability)) | 85 if (!ValidateStudyAndComputeTotalProbability(*study, &total_probability)) |
| 86 return false; | 86 return false; |
| 87 | 87 |
| 88 study_ = study; | 88 study_ = study; |
| 89 is_expired_ = is_expired; | 89 is_expired_ = is_expired; |
| 90 total_probability_ = total_probability; | 90 total_probability_ = total_probability; |
| 91 return true; | 91 return true; |
| 92 } | 92 } |
| 93 | 93 |
| 94 int ProcessedStudy::GetExperimentIndexByName( | |
| 95 const std::string& name) const { | |
| 96 for (int i = 0; i < study_->experiment_size(); ++i) { | |
| 97 if (study_->experiment(i).name() == name) { | |
|
Alexei Svitkine (slow)
2014/07/03 17:54:40
Nit: No need for {}'s.
jwd
2014/07/07 15:52:20
Done.
| |
| 98 return i; | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 return -1; | |
| 103 } | |
| 104 | |
| 94 // static | 105 // static |
| 95 bool ProcessedStudy::ValidateAndAppendStudy( | 106 bool ProcessedStudy::ValidateAndAppendStudy( |
| 96 const Study* study, | 107 const Study* study, |
| 97 bool is_expired, | 108 bool is_expired, |
| 98 std::vector<ProcessedStudy>* processed_studies) { | 109 std::vector<ProcessedStudy>* processed_studies) { |
| 99 ProcessedStudy processed_study; | 110 ProcessedStudy processed_study; |
| 100 if (processed_study.Init(study, is_expired)) { | 111 if (processed_study.Init(study, is_expired)) { |
| 101 processed_studies->push_back(processed_study); | 112 processed_studies->push_back(processed_study); |
| 102 return true; | 113 return true; |
| 103 } | 114 } |
| 104 return false; | 115 return false; |
| 105 } | 116 } |
| 106 | 117 |
| 107 } // namespace chrome_variations | 118 } // namespace chrome_variations |
| OLD | NEW |