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

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

Issue 2448313002: Adding unit tests for PreviewsOptOutStoreSQL (Closed)
Patch Set: ios issue 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
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..14a4436e9f19a53f5e10e3510367f40d5ab8553e 100644
--- a/components/previews/core/previews_experiments.cc
+++ b/components/previews/core/previews_experiments.cc
@@ -38,20 +38,32 @@ 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 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;
+// Command line switch to change the previews per row DB size.
tbansal1 2016/10/28 22:07:14 why is there a need to set this using command line
RyanSturm 2016/11/03 18:30:03 I moved this to previews_opt_out_store_sql.cc I w
+const char kMaxRowsPerHost[] = "previews-max-opt-out-rows-per-host";
+
+// Command line switch to change the previews DB size.
+const char kMaxRows[] = "previews-max-opt-out-rows";
+
+// The maximum number of entries allowed per host in the SQLite DB.
+const int kDefaultMaxRowsPerHost = 32;
+
+// The maximum number of entries allowed in the SQLite DB.
+const int kDefaultMaxRowsInDB = 3200;
+
// 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();
}
@@ -95,20 +107,35 @@ 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);
}
} // namespace params
+int MaxRowsPerHostInOptOutDB() {
+ std::string max_rows =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ kMaxRowsPerHost);
+ int value;
+ return base::StringToInt(max_rows, &value) ? value : kDefaultMaxRowsPerHost;
+}
+
+int MaxRowsInOptOutDB() {
+ std::string max_rows =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kMaxRows);
+ int value;
+ return base::StringToInt(max_rows, &value) ? value : kDefaultMaxRowsInDB;
+}
+
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);
}
bool IsPreviewsTypeEnabled(PreviewsType type) {

Powered by Google App Engine
This is Rietveld 408576698