OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "components/previews/core/previews_experiments.h" | 5 #include "components/previews/core/previews_experiments.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() { | 104 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() { |
105 // By convention, an experiment in the client-side previews study enables use | 105 // By convention, an experiment in the client-side previews study enables use |
106 // of at least one client-side previews optimization if its name begins with | 106 // of at least one client-side previews optimization if its name begins with |
107 // "Enabled." | 107 // "Enabled." |
108 return base::StartsWith( | 108 return base::StartsWith( |
109 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), | 109 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), |
110 kEnabled, base::CompareCase::SENSITIVE); | 110 kEnabled, base::CompareCase::SENSITIVE); |
111 } | 111 } |
112 | 112 |
113 bool IsOfflinePreviewsEnabled() { | 113 bool IsPreviewsTypeEnabled(PreviewsType type) { |
114 return ParamValue(kOfflinePagesSlowNetwork) == kExperimentEnabled; | 114 switch (type) { |
115 case PreviewsType::OFFLINE: | |
116 return ParamValue(kOfflinePagesSlowNetwork) == kExperimentEnabled; | |
117 default: | |
118 return false; | |
tbansal1
2016/10/21 16:17:19
Add NOTREACHED() in default?
| |
119 } | |
115 } | 120 } |
116 | 121 |
117 bool EnableOfflinePreviewsForTesting() { | 122 bool EnableOfflinePreviewsForTesting() { |
118 std::map<std::string, std::string> params; | 123 std::map<std::string, std::string> params; |
119 params[kOfflinePagesSlowNetwork] = kExperimentEnabled; | 124 params[kOfflinePagesSlowNetwork] = kExperimentEnabled; |
120 return variations::AssociateVariationParams(kClientSidePreviewsFieldTrial, | 125 return variations::AssociateVariationParams(kClientSidePreviewsFieldTrial, |
121 kEnabled, params) && | 126 kEnabled, params) && |
122 base::FieldTrialList::CreateFieldTrial(kClientSidePreviewsFieldTrial, | 127 base::FieldTrialList::CreateFieldTrial(kClientSidePreviewsFieldTrial, |
123 kEnabled); | 128 kEnabled); |
124 } | 129 } |
125 | 130 |
126 } // namespace previews | 131 } // namespace previews |
OLD | NEW |