Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / components / variations / processed_study.h
blobf62297953d800de51d6c61399d0de57e81ba065f
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_
8 #include <string>
9 #include <vector>
11 #include "base/metrics/field_trial.h"
13 namespace variations {
15 class Study;
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 {
20 public:
21 ProcessedStudy();
22 ~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 is_expired() const { return is_expired_; }
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;
38 static bool ValidateAndAppendStudy(
39 const Study* study,
40 bool is_expired,
41 std::vector<ProcessedStudy>* processed_studies);
43 private:
44 // Corresponding Study object. Weak reference.
45 const Study* study_;
47 // Computed total group probability for the study.
48 base::FieldTrial::Probability total_probability_;
50 // Whether the study is expired.
51 bool is_expired_;
54 } // namespace variations
56 #endif // COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_