Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / variations / processed_study.h
blobc9650fd20371732fde380917e0a2544701d142b0
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 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(
43 const Study* study,
44 bool is_expired,
45 std::vector<ProcessedStudy>* processed_studies);
47 private:
48 // Corresponding Study object. Weak reference.
49 const Study* study_;
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.
58 bool is_expired_;
61 } // namespace variations
63 #endif // COMPONENTS_VARIATIONS_PROCESSED_STUDY_H_