Upstream isClosing() and setClosing() to Tab.
[chromium-blink-merge.git] / components / variations / variations_seed_simulator.h
blob3ecec98d30da1be1c9aff41b82ce032628b44527
1 // Copyright 2014 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_VARIATIONS_SEED_SIMULATOR_H_
6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_SIMULATOR_H_
8 #include <string>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/metrics/field_trial.h"
15 namespace chrome_variations {
17 class ProcessedStudy;
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();
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);
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);
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);
50 const base::FieldTrial::EntropyProvider& entropy_provider_;
52 DISALLOW_COPY_AND_ASSIGN(VariationsSeedSimulator);
55 } // namespace chrome_variations
57 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_SIMULATOR_H_