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

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

Issue 2433793003: Generalize Previews Type code (Closed)
Patch Set: tbansal comment Created 4 years, 2 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 <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h"
10 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "components/variations/variations_associated_data.h" 14 #include "components/variations/variations_associated_data.h"
14 15
15 namespace previews { 16 namespace previews {
16 17
17 namespace { 18 namespace {
18 19
19 // The group of client-side previews experiments. 20 // The group of client-side previews experiments.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() { 105 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
105 // By convention, an experiment in the client-side previews study enables use 106 // 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 107 // of at least one client-side previews optimization if its name begins with
107 // "Enabled." 108 // "Enabled."
108 return base::StartsWith( 109 return base::StartsWith(
109 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), 110 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial),
110 kEnabled, base::CompareCase::SENSITIVE); 111 kEnabled, base::CompareCase::SENSITIVE);
111 } 112 }
112 113
113 bool IsOfflinePreviewsEnabled() { 114 bool IsPreviewsTypeEnabled(PreviewsType type) {
114 return ParamValue(kOfflinePagesSlowNetwork) == kExperimentEnabled; 115 switch (type) {
116 case PreviewsType::OFFLINE:
117 return ParamValue(kOfflinePagesSlowNetwork) == kExperimentEnabled;
118 default:
119 NOTREACHED();
120 return false;
121 }
115 } 122 }
116 123
117 bool EnableOfflinePreviewsForTesting() { 124 bool EnableOfflinePreviewsForTesting() {
118 std::map<std::string, std::string> params; 125 std::map<std::string, std::string> params;
119 params[kOfflinePagesSlowNetwork] = kExperimentEnabled; 126 params[kOfflinePagesSlowNetwork] = kExperimentEnabled;
120 return variations::AssociateVariationParams(kClientSidePreviewsFieldTrial, 127 return variations::AssociateVariationParams(kClientSidePreviewsFieldTrial,
121 kEnabled, params) && 128 kEnabled, params) &&
122 base::FieldTrialList::CreateFieldTrial(kClientSidePreviewsFieldTrial, 129 base::FieldTrialList::CreateFieldTrial(kClientSidePreviewsFieldTrial,
123 kEnabled); 130 kEnabled);
124 } 131 }
125 132
126 } // namespace previews 133 } // 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