Chromium Code Reviews| Index: components/previews/previews_experiments.cc |
| diff --git a/components/previews/previews_experiments.cc b/components/previews/previews_experiments.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6dbde967b0caab5fcc39b6d5b44e3fc946b9ba4d |
| --- /dev/null |
| +++ b/components/previews/previews_experiments.cc |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/previews/previews_experiments.h" |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/metrics/field_trial.h" |
| +#include "components/variations/variations_associated_data.h" |
| + |
| +namespace { |
| + |
| +// The group of client side previews experiments. |
| +const char kClientSideExperimentsFieldTrial[] = |
| + "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.
|
| + |
| +const char kEnabled[] = "Enabled"; |
| + |
| +// Allow offline pages to show for prohibitively slow networks. |
| +const char kOfflinePagesSlowNetwork[] = "show_offline_pages"; |
| + |
| +} // namespace |
| + |
| +namespace previews { |
| + |
| +bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() { |
| + 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.
|
| + kEnabled; |
| +} |
| + |
| +bool IsIncludedInOfflinePagesSlowConnectionFieldTrial() { |
| + if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial()) |
| + return false; |
| + std::map<std::string, std::string> client_side_params; |
| + if (!variations::GetVariationParams(kClientSideExperimentsFieldTrial, |
| + &client_side_params)) |
|
tbansal1
2016/07/26 20:11:37
Add braces
RyanSturm
2016/07/26 21:56:52
Done.
|
| + return false; |
| + std::map<std::string, std::string>::const_iterator it = |
| + client_side_params.find(kOfflinePagesSlowNetwork); |
| + if (it == client_side_params.end()) |
| + return false; |
| + 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.
|
| +} |
| + |
| +} // namespace previews |