Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/metrics/variations/variations_seed_processor.h

Issue 23097007: Create variations target that depends on base. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
6 #define CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
7
8 #include <string>
9
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 "chrome/browser/metrics/proto/study.pb.h"
16 #include "chrome/browser/metrics/proto/trials_seed.pb.h"
17
18 namespace chrome_variations {
19
20 // Helper class to instantiate field trials from a variations seed.
21 class VariationsSeedProcessor {
22 public:
23 VariationsSeedProcessor();
24 virtual ~VariationsSeedProcessor();
25
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 TrialsSeed& seed,
29 const std::string& locale,
30 const base::Time& reference_date,
31 const base::Version& version,
32 Study_Channel channel);
33
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);
51
52 // Checks whether a study is applicable for the given |channel| per |filter|.
53 bool CheckStudyChannel(const Study_Filter& filter, Study_Channel channel);
54
55 // Checks whether a study is applicable for the given |locale| per |filter|.
56 bool CheckStudyLocale(const Study_Filter& filter, const std::string& locale);
57
58 // Checks whether a study is applicable for the given |platform| per |filter|.
59 bool CheckStudyPlatform(const Study_Filter& filter, Study_Platform platform);
60
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);
64
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);
68
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);
72
73 // Checks whether |study| is expired using the given date/time.
74 bool IsStudyExpired(const Study& study, const base::Time& date_time);
75
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);
85
86 // Validates the sanity of |study| and computes the total probability.
87 bool ValidateStudyAndComputeTotalProbability(
88 const Study& study,
89 base::FieldTrial::Probability* total_probability);
90
91 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor);
92 };
93
94 } // namespace chrome_variations
95
96 #endif // CHROME_BROWSER_METRICS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698