| OLD | NEW |
| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // Helper class to instantiate field trials from a variations seed. | 32 // Helper class to instantiate field trials from a variations seed. |
| 33 class VariationsSeedProcessor { | 33 class VariationsSeedProcessor { |
| 34 public: | 34 public: |
| 35 typedef base::Callback<void(uint32_t, const base::string16&)> | 35 typedef base::Callback<void(uint32_t, const base::string16&)> |
| 36 UIStringOverrideCallback; | 36 UIStringOverrideCallback; |
| 37 | 37 |
| 38 VariationsSeedProcessor(); | 38 VariationsSeedProcessor(); |
| 39 virtual ~VariationsSeedProcessor(); | 39 virtual ~VariationsSeedProcessor(); |
| 40 | 40 |
| 41 // Creates field trials from the specified variations |seed|, based on the | 41 // Creates field trials from the specified variations |seed|, based on the |
| 42 // specified configuration, as specified in the parameters. | 42 // specified configuration, as specified in the parameters. Any study that |
| 43 void CreateTrialsFromSeed(const VariationsSeed& seed, | 43 // should use low entropy will use |low_entropy_provider| for group |
| 44 const std::string& locale, | 44 // selection. These studies are defined by ShouldStudyUseLowEntropy; |
| 45 const base::Time& reference_date, | 45 void CreateTrialsFromSeed( |
| 46 const base::Version& version, | 46 const VariationsSeed& seed, |
| 47 Study_Channel channel, | 47 const std::string& locale, |
| 48 Study_FormFactor form_factor, | 48 const base::Time& reference_date, |
| 49 const std::string& hardware_class, | 49 const base::Version& version, |
| 50 const std::string& session_consistency_country, | 50 Study_Channel channel, |
| 51 const std::string& permanent_consistency_country, | 51 Study_FormFactor form_factor, |
| 52 const UIStringOverrideCallback& override_callback, | 52 const std::string& hardware_class, |
| 53 base::FeatureList* feature_list); | 53 const std::string& session_consistency_country, |
| 54 const std::string& permanent_consistency_country, |
| 55 const UIStringOverrideCallback& override_callback, |
| 56 const base::FieldTrial::EntropyProvider* low_entropy_provider, |
| 57 base::FeatureList* feature_list); |
| 58 |
| 59 // If the given |study| should alwoys use low entropy. This is true for any |
| 60 // study that can send data to other Google properties. |
| 61 static bool ShouldStudyUseLowEntropy(const Study& study); |
| 54 | 62 |
| 55 private: | 63 private: |
| 56 friend class VariationsSeedProcessorTest; | 64 friend class VariationsSeedProcessorTest; |
| 57 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, | 65 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, |
| 58 AllowForceGroupAndVariationId); | 66 AllowForceGroupAndVariationId); |
| 59 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, | 67 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, |
| 60 AllowVariationIdWithForcingFlag); | 68 AllowVariationIdWithForcingFlag); |
| 61 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, | 69 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, |
| 62 ForbidForceGroupWithVariationId); | 70 ForbidForceGroupWithVariationId); |
| 63 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1); | 71 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1); |
| 64 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2); | 72 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2); |
| 65 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, | 73 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, |
| 66 ForceGroup_ChooseFirstGroupWithFlag); | 74 ForceGroup_ChooseFirstGroupWithFlag); |
| 67 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, | 75 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, |
| 68 ForceGroup_DontChooseGroupWithFlag); | 76 ForceGroup_DontChooseGroupWithFlag); |
| 69 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired); | 77 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired); |
| 70 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams); | 78 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams); |
| 71 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, | 79 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, |
| 72 VariationParamsWithForcingFlag); | 80 VariationParamsWithForcingFlag); |
| 73 | 81 |
| 74 // Check if the |study| is only associated with platform Android/iOS and | 82 // Check if the |study| is only associated with platform Android/iOS and |
| 75 // channel dev/canary. If so, forcing flag and variation id can both be set. | 83 // channel dev/canary. If so, forcing flag and variation id can both be set. |
| 76 // (Otherwise, forcing_flag and variation_id are mutually exclusive.) | 84 // (Otherwise, forcing_flag and variation_id are mutually exclusive.) |
| 77 bool AllowVariationIdWithForcingFlag(const Study& study); | 85 bool AllowVariationIdWithForcingFlag(const Study& study); |
| 78 | 86 |
| 79 // Creates and registers a field trial from the |processed_study| data. | 87 // Creates and registers a field trial from the |processed_study| data. |
| 80 // Disables the trial if |processed_study.is_expired| is true. | 88 // Disables the trial if |processed_study.is_expired| is true. Uses |
| 81 void CreateTrialFromStudy(const ProcessedStudy& processed_study, | 89 // |low_entropy_provider| if ShouldStudyUseLowEntropy returns true for the |
| 82 const UIStringOverrideCallback& override_callback, | 90 // study. |
| 83 base::FeatureList* feature_list); | 91 void CreateTrialFromStudy( |
| 92 const ProcessedStudy& processed_study, |
| 93 const UIStringOverrideCallback& override_callback, |
| 94 const base::FieldTrial::EntropyProvider* low_entropy_provider, |
| 95 base::FeatureList* feature_list); |
| 84 | 96 |
| 85 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor); | 97 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor); |
| 86 }; | 98 }; |
| 87 | 99 |
| 88 } // namespace variations | 100 } // namespace variations |
| 89 | 101 |
| 90 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_ | 102 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_ |
| OLD | NEW |