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 #ifndef COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_ | 5 #ifndef COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_ |
6 #define COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_ | 6 #define COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_ |
7 | 7 |
| 8 #include <string> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
11 | 12 |
12 namespace chrome_variations { | 13 namespace chrome_variations { |
13 | 14 |
14 class Study; | 15 class Study; |
15 | 16 |
16 // Wrapper over Study with extra information computed during pre-processing, | 17 // Wrapper over Study with extra information computed during pre-processing, |
17 // such as whether the study is expired and its total probability. | 18 // such as whether the study is expired and its total probability. |
18 class ProcessedStudy { | 19 class ProcessedStudy { |
19 public: | 20 public: |
20 ProcessedStudy(); | 21 ProcessedStudy(); |
21 ~ProcessedStudy(); | 22 ~ProcessedStudy(); |
22 | 23 |
23 bool Init(const Study* study, bool is_expired); | 24 bool Init(const Study* study, bool is_expired); |
24 | 25 |
25 const Study* study() const { return study_; } | 26 const Study* study() const { return study_; } |
26 | 27 |
27 base::FieldTrial::Probability total_probability() const { | 28 base::FieldTrial::Probability total_probability() const { |
28 return total_probability_; | 29 return total_probability_; |
29 } | 30 } |
30 | 31 |
31 bool is_expired() const { return is_expired_; } | 32 bool is_expired() const { return is_expired_; } |
32 | 33 |
| 34 // Gets the index of the experiment with the given |name|. Returns -1 if no |
| 35 // experiment is found. |
| 36 int GetExperimentIndexByName(const std::string& name) const; |
| 37 |
33 static bool ValidateAndAppendStudy( | 38 static bool ValidateAndAppendStudy( |
34 const Study* study, | 39 const Study* study, |
35 bool is_expired, | 40 bool is_expired, |
36 std::vector<ProcessedStudy>* processed_studies); | 41 std::vector<ProcessedStudy>* processed_studies); |
37 | 42 |
38 private: | 43 private: |
39 // Corresponding Study object. Weak reference. | 44 // Corresponding Study object. Weak reference. |
40 const Study* study_; | 45 const Study* study_; |
41 | 46 |
42 // Computed total group probability for the study. | 47 // Computed total group probability for the study. |
43 base::FieldTrial::Probability total_probability_; | 48 base::FieldTrial::Probability total_probability_; |
44 | 49 |
45 // Whether the study is expired. | 50 // Whether the study is expired. |
46 bool is_expired_; | 51 bool is_expired_; |
47 }; | 52 }; |
48 | 53 |
49 } // namespace chrome_variations | 54 } // namespace chrome_variations |
50 | 55 |
51 #endif // COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_ | 56 #endif // COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_ |
OLD | NEW |