Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/feature_list.h" | |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 11 #include "base/metrics/field_trial_params.h" | 12 #include "base/metrics/field_trial_params.h" |
| 12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "components/previews/core/previews_features.h" | |
| 14 | 16 |
| 15 namespace previews { | 17 namespace previews { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // The group of client-side previews experiments. Actually, this group is only | 21 // The group of client-side previews experiments. Actually, this group is only |
| 20 // expected to control one PreviewsType (OFFLINE) as well as the blacklist. | 22 // expected to control one PreviewsType (OFFLINE) as well as the blacklist. |
| 21 // Other PreviewsType's will be control by different field trial groups. | 23 // Other PreviewsType's will be control by different field trial groups. |
| 22 const char kClientSidePreviewsFieldTrial[] = "ClientSidePreviews"; | 24 const char kClientSidePreviewsFieldTrial[] = "ClientSidePreviews"; |
| 23 | 25 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 } | 131 } |
| 130 | 132 |
| 131 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForOffline() { | 133 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForOffline() { |
| 132 return GetParamValueAsECT(kClientSidePreviewsFieldTrial, | 134 return GetParamValueAsECT(kClientSidePreviewsFieldTrial, |
| 133 kEffectiveConnectionTypeThreshold, | 135 kEffectiveConnectionTypeThreshold, |
| 134 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); | 136 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); |
| 135 } | 137 } |
| 136 | 138 |
| 137 bool IsOfflinePreviewsEnabled() { | 139 bool IsOfflinePreviewsEnabled() { |
| 138 // Check if "show_offline_pages" is set to "true". | 140 // Check if "show_offline_pages" is set to "true". |
| 139 return IsIncludedInClientSidePreviewsExperimentsFieldTrial() && | 141 return base::FeatureList::IsEnabled(features::kOfflinePreviews) || |
| 140 base::GetFieldTrialParamValue(kClientSidePreviewsFieldTrial, | 142 (IsIncludedInClientSidePreviewsExperimentsFieldTrial() && |
|
tbansal1
2017/05/03 17:35:19
IIUC, this is not required anymore. Can we delete
RyanSturm
2017/05/03 21:26:25
Not sure what you mean. I have to adjust the finch
tbansal1
2017/05/03 22:54:04
Got it. In that case, should IsIncludedInClientSid
| |
| 141 kOfflinePagesSlowNetwork) == | 143 base::GetFieldTrialParamValue(kClientSidePreviewsFieldTrial, |
| 142 kExperimentEnabled; | 144 kOfflinePagesSlowNetwork) == |
| 145 kExperimentEnabled); | |
| 143 } | 146 } |
| 144 | 147 |
| 145 int OfflinePreviewsVersion() { | 148 int OfflinePreviewsVersion() { |
| 146 return GetParamValueAsInt(kClientSidePreviewsFieldTrial, kVersion, 0); | 149 return GetParamValueAsInt(kClientSidePreviewsFieldTrial, kVersion, 0); |
| 147 } | 150 } |
| 148 | 151 |
| 149 bool IsClientLoFiEnabled() { | 152 bool IsClientLoFiEnabled() { |
| 150 return base::StartsWith( | 153 return base::StartsWith( |
| 151 base::FieldTrialList::FindFullName(kClientLoFiExperimentName), kEnabled, | 154 base::FieldTrialList::FindFullName(kClientLoFiExperimentName), kEnabled, |
| 152 base::CompareCase::SENSITIVE); | 155 base::CompareCase::SENSITIVE); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 167 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() { | 170 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() { |
| 168 // By convention, an experiment in the client-side previews study enables use | 171 // By convention, an experiment in the client-side previews study enables use |
| 169 // of at least one client-side previews optimization if its name begins with | 172 // of at least one client-side previews optimization if its name begins with |
| 170 // "Enabled." | 173 // "Enabled." |
| 171 return base::StartsWith( | 174 return base::StartsWith( |
| 172 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), | 175 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), |
| 173 kEnabled, base::CompareCase::SENSITIVE); | 176 kEnabled, base::CompareCase::SENSITIVE); |
| 174 } | 177 } |
| 175 | 178 |
| 176 } // namespace previews | 179 } // namespace previews |
| OLD | NEW |