Chromium Code Reviews| Index: components/previews/core/previews_experiments.cc |
| diff --git a/components/previews/core/previews_experiments.cc b/components/previews/core/previews_experiments.cc |
| index 3806bc9c8e8f6084023175e7ff2c222bed53c99f..fdd1d4ebcd2167ad374b7d07f57fa4a67d55d9ad 100644 |
| --- a/components/previews/core/previews_experiments.cc |
| +++ b/components/previews/core/previews_experiments.cc |
| @@ -25,6 +25,9 @@ const char kEnabled[] = "Enabled"; |
| // Allow offline pages to show for prohibitively slow networks. |
| const char kOfflinePagesSlowNetwork[] = "show_offline_pages"; |
| +// Version of treatment for showing offline pages, if enabled. |
| +const char kOfflinePagesSlowNetworkVersion[] = "show_offline_pages.version"; |
| + |
| // The maximum number of recent previews navigations the black list looks at to |
| // determine if a host is blacklisted. |
| const char kMaxStoredHistoryLengthPerHost[] = |
| @@ -179,6 +182,31 @@ bool IsPreviewsTypeEnabled(PreviewsType type) { |
| } |
| } |
| +bool GetPreviewsTypeVersion(PreviewsType type) { |
| + DCHECK(IsPreviewsTypeEnabled(type)); |
| + int version = 0; // default |
| + switch (type) { |
| + case PreviewsType::OFFLINE: |
| + base::StringToInt(ParamValue(kOfflinePagesSlowNetworkVersion), &version); |
| + return version; |
|
tbansal1
2017/01/26 00:59:14
I think the switch-case can be rewritten to get co
dougarnett
2017/02/07 21:15:02
Done.
|
| + default: |
| + NOTREACHED(); |
| + } |
| + return version; |
| +} |
| + |
| +std::unique_ptr<std::vector<std::pair<PreviewsType, int>>> |
| +GetEnabledPreviews() { |
| + std::unique_ptr<std::vector<std::pair<PreviewsType, int>>> enabled_previews( |
| + new std::vector<std::pair<PreviewsType, int>>()); |
| + |
| + if (IsPreviewsTypeEnabled(PreviewsType::OFFLINE)) { |
| + enabled_previews->push_back( |
| + {PreviewsType::OFFLINE, GetPreviewsTypeVersion(PreviewsType::OFFLINE)}); |
| + } |
| + return enabled_previews; |
| +} |
| + |
| bool EnableOfflinePreviewsForTesting() { |
| std::map<std::string, std::string> params; |
| params[kOfflinePagesSlowNetwork] = kExperimentEnabled; |