OLD | NEW |
(Empty) | |
| 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_VARIATIONS_SEED_SIMULATOR_H_ |
| 6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_SIMULATOR_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/metrics/field_trial.h" |
| 14 |
| 15 namespace chrome_variations { |
| 16 |
| 17 class ProcessedStudy; |
| 18 |
| 19 // VariationsSeedSimulator simulates the result of creating a set of studies |
| 20 // and detecting which studies would result in group changes. |
| 21 class VariationsSeedSimulator { |
| 22 public: |
| 23 // Creates the simulator with the given entropy |provider|. |
| 24 explicit VariationsSeedSimulator( |
| 25 const base::FieldTrial::EntropyProvider& provider); |
| 26 virtual ~VariationsSeedSimulator(); |
| 27 |
| 28 // Computes differences between the current process' field trial state and |
| 29 // the result of evaluating the |processed_studies| list. It is expected that |
| 30 // |processed_studies| have already been filtered and only contain studies |
| 31 // that apply to the configuration being simulated. Returns a lower bound on |
| 32 // the number of studies that are expected to change groups (lower bound due |
| 33 // to session randomized studies). |
| 34 int ComputeDifferences( |
| 35 const std::vector<ProcessedStudy>& processed_studies); |
| 36 |
| 37 private: |
| 38 // For the given |processed_study| with PERMANENT consistency, simulates group |
| 39 // assignment and returns true if the result differs from that study's group |
| 40 // in the current process. |
| 41 bool PermanentStudyGroupChanged(const ProcessedStudy& processed_study, |
| 42 const std::string& selected_group); |
| 43 |
| 44 // For the given |processed_study| with SESSION consistency, determines if |
| 45 // there are enough changes in the study config that restarting will result |
| 46 // in a guaranteed different group assignment (or different params). |
| 47 bool SessionStudyGroupChanged(const ProcessedStudy& filtered_study, |
| 48 const std::string& selected_group); |
| 49 |
| 50 const base::FieldTrial::EntropyProvider& entropy_provider_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(VariationsSeedSimulator); |
| 53 }; |
| 54 |
| 55 } // namespace chrome_variations |
| 56 |
| 57 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_SIMULATOR_H_ |
OLD | NEW |