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