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

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

Issue 2854893003: Adding an Android about:flags feature for offline previews (Closed)
Patch Set: rebase on enums.xml 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> 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 const std::string& param_name, 70 const std::string& param_name,
69 net::EffectiveConnectionType default_value) { 71 net::EffectiveConnectionType default_value) {
70 net::EffectiveConnectionType value; 72 net::EffectiveConnectionType value;
71 if (!net::GetEffectiveConnectionTypeForName( 73 if (!net::GetEffectiveConnectionTypeForName(
72 base::GetFieldTrialParamValue(trial_name, param_name), &value)) { 74 base::GetFieldTrialParamValue(trial_name, param_name), &value)) {
73 return default_value; 75 return default_value;
74 } 76 }
75 return value; 77 return value;
76 } 78 }
77 79
80 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
81 // By convention, an experiment in the client-side previews study enables use
82 // of at least one client-side previews optimization if its name begins with
83 // "Enabled."
84 return base::StartsWith(
85 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial),
86 kEnabled, base::CompareCase::SENSITIVE);
87 }
88
78 } // namespace 89 } // namespace
79 90
80 namespace params { 91 namespace params {
81 92
82 size_t MaxStoredHistoryLengthForPerHostBlackList() { 93 size_t MaxStoredHistoryLengthForPerHostBlackList() {
83 return GetParamValueAsSizeT(kClientSidePreviewsFieldTrial, 94 return GetParamValueAsSizeT(kClientSidePreviewsFieldTrial,
84 "per_host_max_stored_history_length", 4); 95 "per_host_max_stored_history_length", 4);
85 } 96 }
86 97
87 size_t MaxStoredHistoryLengthForHostIndifferentBlackList() { 98 size_t MaxStoredHistoryLengthForHostIndifferentBlackList() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 140 }
130 141
131 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForOffline() { 142 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForOffline() {
132 return GetParamValueAsECT(kClientSidePreviewsFieldTrial, 143 return GetParamValueAsECT(kClientSidePreviewsFieldTrial,
133 kEffectiveConnectionTypeThreshold, 144 kEffectiveConnectionTypeThreshold,
134 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); 145 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G);
135 } 146 }
136 147
137 bool IsOfflinePreviewsEnabled() { 148 bool IsOfflinePreviewsEnabled() {
138 // Check if "show_offline_pages" is set to "true". 149 // Check if "show_offline_pages" is set to "true".
139 return IsIncludedInClientSidePreviewsExperimentsFieldTrial() && 150 return base::FeatureList::IsEnabled(features::kOfflinePreviews) ||
140 base::GetFieldTrialParamValue(kClientSidePreviewsFieldTrial, 151 (IsIncludedInClientSidePreviewsExperimentsFieldTrial() &&
141 kOfflinePagesSlowNetwork) == 152 base::GetFieldTrialParamValue(kClientSidePreviewsFieldTrial,
142 kExperimentEnabled; 153 kOfflinePagesSlowNetwork) ==
154 kExperimentEnabled);
143 } 155 }
144 156
145 int OfflinePreviewsVersion() { 157 int OfflinePreviewsVersion() {
146 return GetParamValueAsInt(kClientSidePreviewsFieldTrial, kVersion, 0); 158 return GetParamValueAsInt(kClientSidePreviewsFieldTrial, kVersion, 0);
147 } 159 }
148 160
149 bool IsClientLoFiEnabled() { 161 bool IsClientLoFiEnabled() {
150 return base::StartsWith( 162 return base::StartsWith(
151 base::FieldTrialList::FindFullName(kClientLoFiExperimentName), kEnabled, 163 base::FieldTrialList::FindFullName(kClientLoFiExperimentName), kEnabled,
152 base::CompareCase::SENSITIVE); 164 base::CompareCase::SENSITIVE);
153 } 165 }
154 166
155 int ClientLoFiVersion() { 167 int ClientLoFiVersion() {
156 return GetParamValueAsInt(kClientLoFiExperimentName, kVersion, 0); 168 return GetParamValueAsInt(kClientLoFiExperimentName, kVersion, 0);
157 } 169 }
158 170
159 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForClientLoFi() { 171 net::EffectiveConnectionType EffectiveConnectionTypeThresholdForClientLoFi() {
160 return GetParamValueAsECT(kClientLoFiExperimentName, 172 return GetParamValueAsECT(kClientLoFiExperimentName,
161 kEffectiveConnectionTypeThreshold, 173 kEffectiveConnectionTypeThreshold,
162 net::EFFECTIVE_CONNECTION_TYPE_2G); 174 net::EFFECTIVE_CONNECTION_TYPE_2G);
163 } 175 }
164 176
165 } // namespace params 177 } // namespace params
166 178
167 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
168 // 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
170 // "Enabled."
171 return base::StartsWith(
172 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial),
173 kEnabled, base::CompareCase::SENSITIVE);
174 }
175
176 } // namespace previews 179 } // 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