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

Unified Diff: components/previews/core/previews_experiments.cc

Issue 2640023007: Adds PreviewsType version mechanism for clearing blacklist entries. (Closed)
Patch Set: Missed a change in last upload Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
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;
« no previous file with comments | « components/previews/core/previews_experiments.h ('k') | components/previews/core/previews_opt_out_store_sql.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698