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..64ded70b3fc21272ccce42641668aef5f6ef018b |
| --- /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 "base/strings/string_util.h" |
| +#include "components/variations/variations_associated_data.h" |
| + |
| +namespace { |
| + |
| +// The group of client side previews experiments. |
| +const char kClientSidePreviewsFieldTrial[] = "ClientSidePreviewsFieldTrial"; |
|
bengr
2016/07/26 23:54:21
I would use the string "ClientSidePreviews" instea
RyanSturm
2016/07/27 16:27:48
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::StartsWith( |
|
bengr
2016/07/26 23:54:21
Add a comment that says:
// By convention, an expe
RyanSturm
2016/07/27 16:27:48
Done.
|
| + base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), |
| + kEnabled, base::CompareCase::SENSITIVE); |
| +} |
| + |
| +bool IsIncludedInOfflinePagesSlowConnectionFieldTrial() { |
|
bengr
2016/07/26 23:54:21
Change the name to IsOfflinePreviewsEnabled()
RyanSturm
2016/07/27 16:27:48
Done.
|
| + if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial()) |
| + return false; |
| + std::map<std::string, std::string> client_side_params; |
|
bengr
2016/07/26 23:54:21
client_side_params -> experiment_params
RyanSturm
2016/07/27 16:27:48
Done.
|
| + if (!variations::GetVariationParams(kClientSidePreviewsFieldTrial, |
| + &client_side_params)) { |
| + return false; |
| + } |
| + std::map<std::string, std::string>::const_iterator it = |
| + client_side_params.find(kOfflinePagesSlowNetwork); |
| + return it != client_side_params.end() && it->second == "true"; |
| +} |
| + |
| +} // namespace previews |