Deleted check for if Aes128Gcm12Encrypter::IsSupported or not beacuse we
[chromium-blink-merge.git] / components / variations / variations_seed_processor.h
blobcba26214af91d6d73af529a517203f4a229d9df5
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_VARIATIONS_SEED_PROCESSOR_H_
6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/metrics/field_trial.h"
13 #include "base/time/time.h"
14 #include "base/version.h"
15 #include "components/variations/proto/study.pb.h"
16 #include "components/variations/proto/variations_seed.pb.h"
18 namespace chrome_variations {
20 // Helper class to instantiate field trials from a variations seed.
21 class VariationsSeedProcessor {
22 public:
23 VariationsSeedProcessor();
24 virtual ~VariationsSeedProcessor();
26 // Creates field trials from the specified variations |seed|, based on the
27 // specified configuration (locale, current date, version and channel).
28 void CreateTrialsFromSeed(const VariationsSeed& seed,
29 const std::string& locale,
30 const base::Time& reference_date,
31 const base::Version& version,
32 Study_Channel channel);
34 private:
35 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, CheckStudyChannel);
36 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, CheckStudyLocale);
37 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, CheckStudyPlatform);
38 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, CheckStudyStartDate);
39 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, CheckStudyVersion);
40 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
41 CheckStudyVersionWildcards);
42 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1);
43 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2);
44 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
45 ForceGroup_ChooseFirstGroupWithFlag);
46 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
47 ForceGroup_DontChooseGroupWithFlag);
48 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired);
49 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ValidateStudy);
50 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams);
52 // Checks whether a study is applicable for the given |channel| per |filter|.
53 bool CheckStudyChannel(const Study_Filter& filter, Study_Channel channel);
55 // Checks whether a study is applicable for the given |locale| per |filter|.
56 bool CheckStudyLocale(const Study_Filter& filter, const std::string& locale);
58 // Checks whether a study is applicable for the given |platform| per |filter|.
59 bool CheckStudyPlatform(const Study_Filter& filter, Study_Platform platform);
61 // Checks whether a study is applicable for the given date/time per |filter|.
62 bool CheckStudyStartDate(const Study_Filter& filter,
63 const base::Time& date_time);
65 // Checks whether a study is applicable for the given version per |filter|.
66 bool CheckStudyVersion(const Study_Filter& filter,
67 const base::Version& version);
69 // Creates and registers a field trial from the |study| data. Disables the
70 // trial if |is_expired| is true.
71 void CreateTrialFromStudy(const Study& study, bool is_expired);
73 // Checks whether |study| is expired using the given date/time.
74 bool IsStudyExpired(const Study& study, const base::Time& date_time);
76 // Returns whether |study| should be disabled according to its restriction
77 // parameters. Uses |version_info| for min / max version checks,
78 // |reference_date| for the start date check and |channel| for channel
79 // checks.
80 bool ShouldAddStudy(const Study& study,
81 const std::string& locale,
82 const base::Time& reference_date,
83 const base::Version& version,
84 Study_Channel channel);
86 // Validates the sanity of |study| and computes the total probability.
87 bool ValidateStudyAndComputeTotalProbability(
88 const Study& study,
89 base::FieldTrial::Probability* total_probability);
91 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor);
94 } // namespace chrome_variations
96 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_