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

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

Issue 2439203002: Adding a short blacklist period after every previews opt out (Closed)
Patch Set: tbansal commetns Created 4 years, 2 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
« no previous file with comments | « components/previews/core/previews_experiments.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/previews/core/previews_experiments.cc
diff --git a/components/previews/core/previews_experiments.cc b/components/previews/core/previews_experiments.cc
index fa1fd2fe1b34e867f6a96c8b45adf8e846c5251e..9e55f510a50f46d0734d0bcfd2870cf30d37c0cb 100644
--- a/components/previews/core/previews_experiments.cc
+++ b/components/previews/core/previews_experiments.cc
@@ -32,25 +32,32 @@ const char kMaxStoredHistoryLength[] = "stored_history_length";
// The maximum number of hosts allowed in the in memory black list.
const char kMaxHostsInBlackList[] = "max_hosts_in_blacklist";
// The number of recent navigations that were opted out of that would trigger
// the host to be blacklisted.
const char kOptOutThreshold[] = "opt_out_threshold";
// The amount of time a host remains blacklisted due to opt outs.
const char kBlackListDurationInDays[] = "black_list_duration_in_days";
+// The amount of time after any opt out that no previews should be shown.
+const char kSingleOptOutDurationInSeconds[] =
+ "single_opt_out_duration_in_seconds";
+
// The string that corresponds to enabled for the variation param experiments.
const char kExperimentEnabled[] = "true";
// In seconds. Hosts are blacklisted for 30 days.
-constexpr int kDefaultBlackListDurationInDays = 30;
+const int kDefaultBlackListDurationInDays = 30;
+
+// In seconds. Previews are not shown for 5 minutes after an opt out.
+constexpr int kDefaultSingleOptOutDurationInSeconds = 60 * 5;
// Returns the parameter value of |param| as a string. If there is no value for
// |param|, returns an empty string.
std::string ParamValue(const std::string& param) {
if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial())
return std::string();
std::map<std::string, std::string> experiment_params;
if (!variations::GetVariationParams(kClientSidePreviewsFieldTrial,
&experiment_params)) {
return std::string();
@@ -93,20 +100,29 @@ int BlackListOptOutThreshold() {
base::TimeDelta BlackListDuration() {
std::string param_value = ParamValue(kBlackListDurationInDays);
int duration;
if (!base::StringToInt(param_value, &duration)) {
return base::TimeDelta::FromDays(kDefaultBlackListDurationInDays);
}
return base::TimeDelta::FromDays(duration);
}
+base::TimeDelta SingleOptOutDuration() {
+ std::string param_value = ParamValue(kSingleOptOutDurationInSeconds);
+ int duration;
+ if (!base::StringToInt(param_value, &duration)) {
+ return base::TimeDelta::FromSeconds(kDefaultSingleOptOutDurationInSeconds);
+ }
+ return base::TimeDelta::FromSeconds(duration);
+}
+
} // namespace params
bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() {
// By convention, an experiment in the client-side previews study enables use
// of at least one client-side previews optimization if its name begins with
// "Enabled."
return base::StartsWith(
base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial),
kEnabled, base::CompareCase::SENSITIVE);
}
« no previous file with comments | « components/previews/core/previews_experiments.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698