Rename GetIconID to GetIconId
[chromium-blink-merge.git] / components / variations / variations_seed_processor.h
blobedbe059524243dd2fe2584be9989c6363cb8fd5e
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>
9 #include <vector>
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/metrics/field_trial.h"
15 #include "base/strings/string16.h"
16 #include "base/time/time.h"
17 #include "base/version.h"
18 #include "components/variations/proto/study.pb.h"
19 #include "components/variations/proto/variations_seed.pb.h"
21 namespace variations {
23 class ProcessedStudy;
25 // Helper class to instantiate field trials from a variations seed.
26 class VariationsSeedProcessor {
27 public:
28 typedef base::Callback<void(uint32_t, const base::string16&)>
29 UIStringOverrideCallback;
31 VariationsSeedProcessor();
32 virtual ~VariationsSeedProcessor();
34 // Creates field trials from the specified variations |seed|, based on the
35 // specified configuration, as specified in the parameters.
36 void CreateTrialsFromSeed(const VariationsSeed& seed,
37 const std::string& locale,
38 const base::Time& reference_date,
39 const base::Version& version,
40 Study_Channel channel,
41 Study_FormFactor form_factor,
42 const std::string& hardware_class,
43 const std::string& session_consistency_country,
44 const std::string& permanent_consistency_country,
45 const UIStringOverrideCallback& override_callback);
47 private:
48 friend class VariationsSeedProcessorTest;
49 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
50 AllowForceGroupAndVariationId);
51 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
52 AllowVariationIdWithForcingFlag);
53 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
54 ForbidForceGroupWithVariationId);
55 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1);
56 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2);
57 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
58 ForceGroup_ChooseFirstGroupWithFlag);
59 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
60 ForceGroup_DontChooseGroupWithFlag);
61 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired);
62 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams);
63 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
64 VariationParamsWithForcingFlag);
66 // 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.
68 // (Otherwise, forcing_flag and variation_id are mutually exclusive.)
69 bool AllowVariationIdWithForcingFlag(const Study& study);
71 // Creates and registers a field trial from the |processed_study| data.
72 // Disables the trial if |processed_study.is_expired| is true.
73 void CreateTrialFromStudy(const ProcessedStudy& processed_study,
74 const UIStringOverrideCallback& override_callback);
76 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor);
79 } // namespace variations
81 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_