Demonstrate the basic functionality of the File System
[chromium-blink-merge.git] / components / variations / variations_seed_processor.h
blobdd4d0c81e6742951c6d863924188a12f3ca5356d
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/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/metrics/field_trial.h"
14 #include "base/time/time.h"
15 #include "base/version.h"
16 #include "components/variations/proto/study.pb.h"
17 #include "components/variations/proto/variations_seed.pb.h"
19 namespace chrome_variations {
21 class ProcessedStudy;
23 // Helper class to instantiate field trials from a variations seed.
24 class VariationsSeedProcessor {
25 public:
26 VariationsSeedProcessor();
27 virtual ~VariationsSeedProcessor();
29 // Creates field trials from the specified variations |seed|, based on the
30 // specified configuration (locale, current date, version, channel, form
31 // factor and hardware_class).
32 void CreateTrialsFromSeed(const VariationsSeed& seed,
33 const std::string& locale,
34 const base::Time& reference_date,
35 const base::Version& version,
36 Study_Channel channel,
37 Study_FormFactor form_factor,
38 const std::string& hardware_class);
40 private:
41 friend class VariationsSeedProcessorTest;
42 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
43 AllowForceGroupAndVariationId);
44 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
45 AllowVariationIdWithForcingFlag);
46 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
47 ForbidForceGroupWithVariationId);
48 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag1);
49 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, ForceGroupWithFlag2);
50 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
51 ForceGroup_ChooseFirstGroupWithFlag);
52 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
53 ForceGroup_DontChooseGroupWithFlag);
54 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, IsStudyExpired);
55 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest, VariationParams);
56 FRIEND_TEST_ALL_PREFIXES(VariationsSeedProcessorTest,
57 VariationParamsWithForcingFlag);
59 // Check if the |study| is only associated with platform Android/iOS and
60 // channel dev/canary. If so, forcing flag and variation id can both be set.
61 // (Otherwise, forcing_flag and variation_id are mutually exclusive.)
62 bool AllowVariationIdWithForcingFlag(const Study& study);
64 // Creates and registers a field trial from the |processed_study| data.
65 // Disables the trial if |processed_study.is_expired| is true.
66 void CreateTrialFromStudy(const ProcessedStudy& processed_study);
68 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessor);
71 } // namespace chrome_variations
73 #endif // COMPONENTS_VARIATIONS_VARIATIONS_SEED_PROCESSOR_H_