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

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

Issue 2179863003: Adding a new component, Previews. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: macro change Created 4 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/previews/previews_experiments.h"
6
7 #include <map>
8 #include <string>
9
10 #include "base/metrics/field_trial.h"
11 #include "components/variations/variations_associated_data.h"
12
13 namespace {
14
15 // The group of client side previews experiments.
16 const char kClientSideExperimentsFieldTrial[] =
17 "DataReductionProxyClientSideExperimentsFieldTrial";
tbansal1 2016/07/26 20:11:37 I do not think that the field trial name should co
RyanSturm 2016/07/26 21:56:52 Done.
18
19 const char kEnabled[] = "Enabled";
20
21 // Allow offline pages to show for prohibitively slow networks.
22 const char kOfflinePagesSlowNetwork[] = "show_offline_pages";
23
24 } // namespace
25
26 namespace previews {
27
28 bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
29 return base::FieldTrialList::FindFullName(kClientSideExperimentsFieldTrial) ==
tbansal1 2016/07/26 20:11:37 Check if prefix is kEnabled (instead of exact matc
RyanSturm 2016/07/26 21:56:52 Done.
30 kEnabled;
31 }
32
33 bool IsIncludedInOfflinePagesSlowConnectionFieldTrial() {
34 if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial())
35 return false;
36 std::map<std::string, std::string> client_side_params;
37 if (!variations::GetVariationParams(kClientSideExperimentsFieldTrial,
38 &client_side_params))
tbansal1 2016/07/26 20:11:37 Add braces
RyanSturm 2016/07/26 21:56:52 Done.
39 return false;
40 std::map<std::string, std::string>::const_iterator it =
41 client_side_params.find(kOfflinePagesSlowNetwork);
42 if (it == client_side_params.end())
43 return false;
44 return it->second == "1";
tbansal1 2016/07/26 20:11:37 s/"1"/"true"/
tbansal1 2016/07/26 20:11:37 nit: May be combine with above: return it != ..end
RyanSturm 2016/07/26 21:56:52 Done.
RyanSturm 2016/07/26 21:56:52 Done.
45 }
46
47 } // namespace previews
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698