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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_
6 #define COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_
11 #include "base/metrics/field_trial.h"
13 namespace variations
{
17 // Wrapper over Study with extra information computed during pre-processing,
18 // such as whether the study is expired and its total probability.
19 class ProcessedStudy
{
24 bool Init(const Study
* study
, bool is_expired
);
26 const Study
* study() const { return study_
; }
28 base::FieldTrial::Probability
total_probability() const {
29 return total_probability_
;
32 bool all_assignments_to_one_group() const {
33 return all_assignments_to_one_group_
;
36 bool is_expired() const { return is_expired_
; }
38 // Gets the index of the experiment with the given |name|. Returns -1 if no
39 // experiment is found.
40 int GetExperimentIndexByName(const std::string
& name
) const;
42 static bool ValidateAndAppendStudy(
45 std::vector
<ProcessedStudy
>* processed_studies
);
48 // Corresponding Study object. Weak reference.
51 // Computed total group probability for the study.
52 base::FieldTrial::Probability total_probability_
;
54 // Whether all assignments are to a single group.
55 bool all_assignments_to_one_group_
;
57 // Whether the study is expired.
61 } // namespace variations
63 #endif // COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_