Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "base/strings/string_util.h" | |
| 12 #include "components/variations/variations_associated_data.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 // The group of client side previews experiments. | |
| 17 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.
| |
| 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::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.
| |
| 30 base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), | |
| 31 kEnabled, base::CompareCase::SENSITIVE); | |
| 32 } | |
| 33 | |
| 34 bool IsIncludedInOfflinePagesSlowConnectionFieldTrial() { | |
|
bengr
2016/07/26 23:54:21
Change the name to IsOfflinePreviewsEnabled()
RyanSturm
2016/07/27 16:27:48
Done.
| |
| 35 if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial()) | |
| 36 return false; | |
| 37 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.
| |
| 38 if (!variations::GetVariationParams(kClientSidePreviewsFieldTrial, | |
| 39 &client_side_params)) { | |
| 40 return false; | |
| 41 } | |
| 42 std::map<std::string, std::string>::const_iterator it = | |
| 43 client_side_params.find(kOfflinePagesSlowNetwork); | |
| 44 return it != client_side_params.end() && it->second == "true"; | |
| 45 } | |
| 46 | |
| 47 } // namespace previews | |
| OLD | NEW |