Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: components/previews/core/previews_experiments.cc

Issue 2760063002: Add support to previews/ for Server LoFi and LitePages (Closed)
Patch Set: comment fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
8
9 #include "base/feature_list.h" 7 #include "base/feature_list.h"
10 #include "base/logging.h" 8 #include "base/logging.h"
11 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
12 #include "base/metrics/field_trial_params.h" 10 #include "base/metrics/field_trial_params.h"
13 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
15 #include "components/previews/core/previews_features.h" 13 #include "components/previews/core/previews_features.h"
16 14
17 namespace previews { 15 namespace previews {
18 16
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 GetParamValueAsInt(kClientSidePreviewsFieldTrial, 130 GetParamValueAsInt(kClientSidePreviewsFieldTrial,
133 "single_opt_out_duration_in_seconds", 60 * 5)); 131 "single_opt_out_duration_in_seconds", 60 * 5));
134 } 132 }
135 133
136 base::TimeDelta OfflinePreviewFreshnessDuration() { 134 base::TimeDelta OfflinePreviewFreshnessDuration() {
137 return base::TimeDelta::FromDays( 135 return base::TimeDelta::FromDays(
138 GetParamValueAsInt(kClientSidePreviewsFieldTrial, 136 GetParamValueAsInt(kClientSidePreviewsFieldTrial,
139 "offline_preview_freshness_duration_in_days", 7)); 137 "offline_preview_freshness_duration_in_days", 7));
140 } 138 }
141 139
142 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForOffline() { 140 net::EffectiveConnectionType DefaultEffectiveConnectionTypeThreshold() {
143 return GetParamValueAsECT(kClientSidePreviewsFieldTrial, 141 return GetParamValueAsECT(kClientSidePreviewsFieldTrial,
144 kEffectiveConnectionTypeThreshold, 142 kEffectiveConnectionTypeThreshold,
145 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); 143 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G);
146 } 144 }
147 145
148 bool IsOfflinePreviewsEnabled() { 146 bool IsOfflinePreviewsEnabled() {
149 // Check if "show_offline_pages" is set to "true". 147 // Check if "show_offline_pages" is set to "true".
150 return base::FeatureList::IsEnabled(features::kOfflinePreviews) || 148 return base::FeatureList::IsEnabled(features::kOfflinePreviews) ||
151 (IsIncludedInClientSidePreviewsExperimentsFieldTrial() && 149 (IsIncludedInClientSidePreviewsExperimentsFieldTrial() &&
152 base::GetFieldTrialParamValue(kClientSidePreviewsFieldTrial, 150 base::GetFieldTrialParamValue(kClientSidePreviewsFieldTrial,
(...skipping 16 matching lines...) Expand all
169 } 167 }
170 168
171 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForClientLoFi() { 169 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForClientLoFi() {
172 return GetParamValueAsECT(kClientLoFiExperimentName, 170 return GetParamValueAsECT(kClientLoFiExperimentName,
173 kEffectiveConnectionTypeThreshold, 171 kEffectiveConnectionTypeThreshold,
174 net::EFFECTIVE_CONNECTION_TYPE_2G); 172 net::EFFECTIVE_CONNECTION_TYPE_2G);
175 } 173 }
176 174
177 } // namespace params 175 } // namespace params
178 176
177 std::string GetStringNameForType(PreviewsType type) {
178 switch (type) {
179 case PreviewsType::OFFLINE:
180 return "Offline";
181 case PreviewsType::LOFI:
182 return "LoFi";
183 case PreviewsType::LITE_PAGE:
184 return "LitePage";
185 case PreviewsType::NONE:
186 case PreviewsType::LAST:
187 break;
188 }
189 NOTREACHED();
190 return std::string();
191 }
192
179 } // namespace previews 193 } // namespace previews
OLDNEW
« no previous file with comments | « components/previews/core/previews_experiments.h ('k') | components/previews/core/previews_experiments_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698