Update ResourceConstraints::ConfigureDefaults invocation
[chromium-blink-merge.git] / components / variations / variations_seed_processor.h
blobe8c6829be75850f335776da56c7754495cb6362a
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 (locale, current date, version, channel, form
36 // factor and hardware_class).
37 void CreateTrialsFromSeed(const VariationsSeed& seed,
38 const std::string& locale,
39 const base::Time& reference_date,
40 const base::Version& version,
41 Study_Channel channel,
42 Study_FormFactor form_factor,
43 const std::string& hardware_class,
44 const UIStringOverrideCallback& override_callback);
46 private:
47 friend class VariationsSeedProcessorTest;
48 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
49 AllowForceGroupAndVariationId);
50 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
51 AllowVariationIdWithForcingFlag);
52 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
53 ForbidForceGroupWithVariationId);
54 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1);
55 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2);
56 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
57 ForceGroup_ChooseFirstGroupWithFlag);
58 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
59 ForceGroup_DontChooseGroupWithFlag);
60 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired);
61 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams);
62 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
63 VariationParamsWithForcingFlag);
65 // Check if the |study| is only associated with platform Android/iOS and
66 // channel dev/canary. If so, forcing flag and variation id can both be set.
67 // (Otherwise, forcing_flag and variation_id are mutually exclusive.)
68 bool AllowVariationIdWithForcingFlag(const Study& study);
70 // Creates and registers a field trial from the |processed_study| data.
71 // Disables the trial if |processed_study.is_expired| is true.
72 void CreateTrialFromStudy(const ProcessedStudy& processed_study,
73 const UIStringOverrideCallback& override_callback);
75 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor);
78 } // namespace variations
80 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_