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

Side by Side Diff: components/variations/variations_seed_processor.h

Issue 1306653004: Expand FeatureList to support FieldTrial association. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_ 5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_ 6 #define COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/version.h" 17 #include "base/version.h"
18 #include "components/variations/proto/study.pb.h" 18 #include "components/variations/proto/study.pb.h"
19 #include "components/variations/proto/variations_seed.pb.h" 19 #include "components/variations/proto/variations_seed.pb.h"
20 20
21 namespace base {
22 class FeatureList;
23 }
24
21 namespace variations { 25 namespace variations {
22 26
23 class ProcessedStudy; 27 class ProcessedStudy;
24 28
25 // Helper class to instantiate field trials from a variations seed. 29 // Helper class to instantiate field trials from a variations seed.
26 class VariationsSeedProcessor { 30 class VariationsSeedProcessor {
27 public: 31 public:
28 typedef base::Callback<void(uint32_t, const base::string16&)> 32 typedef base::Callback<void(uint32_t, const base::string16&)>
29 UIStringOverrideCallback; 33 UIStringOverrideCallback;
30 34
31 VariationsSeedProcessor(); 35 VariationsSeedProcessor();
32 virtual ~VariationsSeedProcessor(); 36 virtual ~VariationsSeedProcessor();
33 37
34 // Creates field trials from the specified variations |seed|, based on the 38 // Creates field trials from the specified variations |seed|, based on the
35 // specified configuration, as specified in the parameters. 39 // specified configuration, as specified in the parameters.
36 void CreateTrialsFromSeed(const VariationsSeed& seed, 40 void CreateTrialsFromSeed(const VariationsSeed& seed,
37 const std::string& locale, 41 const std::string& locale,
38 const base::Time& reference_date, 42 const base::Time& reference_date,
39 const base::Version& version, 43 const base::Version& version,
40 Study_Channel channel, 44 Study_Channel channel,
41 Study_FormFactor form_factor, 45 Study_FormFactor form_factor,
42 const std::string& hardware_class, 46 const std::string& hardware_class,
43 const std::string& session_consistency_country, 47 const std::string& session_consistency_country,
44 const std::string& permanent_consistency_country, 48 const std::string& permanent_consistency_country,
45 const UIStringOverrideCallback& override_callback); 49 const UIStringOverrideCallback& override_callback,
50 base::FeatureList* feature_list);
46 51
47 private: 52 private:
48 friend class VariationsSeedProcessorTest; 53 friend class VariationsSeedProcessorTest;
49 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 54 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
50 AllowForceGroupAndVariationId); 55 AllowForceGroupAndVariationId);
51 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 56 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
52 AllowVariationIdWithForcingFlag); 57 AllowVariationIdWithForcingFlag);
53 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 58 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
54 ForbidForceGroupWithVariationId); 59 ForbidForceGroupWithVariationId);
55 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1); 60 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1);
56 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2); 61 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2);
57 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 62 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
58 ForceGroup_ChooseFirstGroupWithFlag); 63 ForceGroup_ChooseFirstGroupWithFlag);
59 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 64 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
60 ForceGroup_DontChooseGroupWithFlag); 65 ForceGroup_DontChooseGroupWithFlag);
61 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired); 66 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired);
62 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams); 67 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams);
63 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, 68 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
64 VariationParamsWithForcingFlag); 69 VariationParamsWithForcingFlag);
65 70
66 // Check if the |study| is only associated with platform Android/iOS and 71 // Check if the |study| is only associated with platform Android/iOS and
67 // channel dev/canary. If so, forcing flag and variation id can both be set. 72 // channel dev/canary. If so, forcing flag and variation id can both be set.
68 // (Otherwise, forcing_flag and variation_id are mutually exclusive.) 73 // (Otherwise, forcing_flag and variation_id are mutually exclusive.)
69 bool AllowVariationIdWithForcingFlag(const Study& study); 74 bool AllowVariationIdWithForcingFlag(const Study& study);
70 75
71 // Creates and registers a field trial from the |processed_study| data. 76 // Creates and registers a field trial from the |processed_study| data.
72 // Disables the trial if |processed_study.is_expired| is true. 77 // Disables the trial if |processed_study.is_expired| is true.
73 void CreateTrialFromStudy(const ProcessedStudy& processed_study, 78 void CreateTrialFromStudy(const ProcessedStudy& processed_study,
74 const UIStringOverrideCallback& override_callback); 79 const UIStringOverrideCallback& override_callback,
80 base::FeatureList* feature_list);
75 81
76 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor); 82 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor);
77 }; 83 };
78 84
79 } // namespace variations 85 } // namespace variations
80 86
81 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_ 87 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_
OLDNEW
« no previous file with comments | « components/variations/service/variations_service.cc ('k') | components/variations/variations_seed_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698