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

Unified Diff: components/previews/previews_experiments.cc

Issue 2166363003: Offline pages using NQE 2G Slow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: thestig comments Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/previews/previews_experiments.h ('k') | components/previews/previews_experiments_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/previews/previews_experiments.cc
diff --git a/components/previews/previews_experiments.cc b/components/previews/previews_experiments.cc
index be52481299417fb64c5707dd8699600edce6e8f9..35abce728d98247e689e9e0d1fdcf9072d672928 100644
--- a/components/previews/previews_experiments.cc
+++ b/components/previews/previews_experiments.cc
@@ -14,20 +14,23 @@
namespace {
// The group of client-side previews experiments.
const char kClientSidePreviewsFieldTrial[] = "ClientSidePreviews";
const char kEnabled[] = "Enabled";
// Allow offline pages to show for prohibitively slow networks.
const char kOfflinePagesSlowNetwork[] = "show_offline_pages";
+// The string that corresponds to enabled for the variation param experiments.
+const char kExperimentEnabled[] = "true";
+
} // namespace
namespace previews {
bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
// By convention, an experiment in the client-side previews study enables use
// of at least one client-side previews optimization if its name begins with
// "Enabled."
return base::StartsWith(
base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial),
@@ -37,14 +40,23 @@ bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
bool IsOfflinePreviewsEnabled() {
if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial())
return false;
std::map<std::string, std::string> experiment_params;
if (!variations::GetVariationParams(kClientSidePreviewsFieldTrial,
&experiment_params)) {
return false;
}
std::map<std::string, std::string>::const_iterator it =
experiment_params.find(kOfflinePagesSlowNetwork);
- return it != experiment_params.end() && it->second == "true";
+ return it != experiment_params.end() && it->second == kExperimentEnabled;
+}
+
+bool EnableOfflinePreviewsForTesting() {
+ std::map<std::string, std::string> params;
+ params[kOfflinePagesSlowNetwork] = kExperimentEnabled;
+ return variations::AssociateVariationParams(kClientSidePreviewsFieldTrial,
+ kEnabled, params) &&
+ base::FieldTrialList::CreateFieldTrial(kClientSidePreviewsFieldTrial,
+ kEnabled);
}
} // namespace previews
« no previous file with comments | « components/previews/previews_experiments.h ('k') | components/previews/previews_experiments_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698