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

Unified Diff: components/ntp_snippets/remote/json_request.cc

Issue 2804633003: Add base::FeatureParam<> struct (Closed)
Patch Set: rebase Created 3 years, 4 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/ntp_snippets/remote/json_request.cc
diff --git a/components/ntp_snippets/remote/json_request.cc b/components/ntp_snippets/remote/json_request.cc
index 8627c49c57320983066e2e8a8a5064165790e00d..5ede74f917791f35ea8c032443e0196736e5f030 100644
--- a/components/ntp_snippets/remote/json_request.cc
+++ b/components/ntp_snippets/remote/json_request.cc
@@ -49,34 +49,23 @@ namespace internal {
namespace {
-// Variation parameter for disabling the retry.
-const char kBackground5xxRetriesName[] = "background_5xx_retries_count";
+constexpr base::FeatureParam<int> kBackground5xxRetries{
+ &ntp_snippets::kArticleSuggestionsFeature, "background_5xx_retries_count",
+ 0};
// Variation parameter for sending UrlLanguageHistogram info to the server.
-const char kSendTopLanguagesName[] = "send_top_languages";
+constexpr base::FeatureParam<bool> kSendTopLanguages{
+ &ntp_snippets::kArticleSuggestionsFeature, "send_top_languages", false};
// Variation parameter for sending UserClassifier info to the server.
-const char kSendUserClassName[] = "send_user_class";
+constexpr base::FeatureParam<bool> kSendUserClassNameParam{
+ &kArticleSuggestionsFeature, "send_user_class", false};
int Get5xxRetryCount(bool interactive_request) {
if (interactive_request) {
return 2;
}
- return std::max(0, variations::GetVariationParamByFeatureAsInt(
- ntp_snippets::kArticleSuggestionsFeature,
- kBackground5xxRetriesName, 0));
-}
-
-bool IsSendingTopLanguagesEnabled() {
- return variations::GetVariationParamByFeatureAsBool(
- ntp_snippets::kArticleSuggestionsFeature, kSendTopLanguagesName,
- /*default_value=*/true);
-}
-
-bool IsSendingUserClassEnabled() {
- return variations::GetVariationParamByFeatureAsBool(
- ntp_snippets::kArticleSuggestionsFeature, kSendUserClassName,
- /*default_value=*/false);
+ return std::max(0, kBackground5xxRetries.Get());
}
// Translate the BCP 47 |language_code| into a posix locale string.
@@ -282,7 +271,7 @@ JsonRequest::Builder& JsonRequest::Builder::SetUrlRequestContextGetter(
JsonRequest::Builder& JsonRequest::Builder::SetUserClassifier(
const UserClassifier& user_classifier) {
- if (IsSendingUserClassEnabled()) {
+ if (kSendUserClassNameParam.Get()) {
user_class_ = GetUserClassString(user_classifier.GetUserClass());
}
return *this;
@@ -407,7 +396,7 @@ void JsonRequest::Builder::PrepareLanguages(
// TODO(jkrcal): Add language model factory for iOS and add fakes to tests so
// that |language_histogram| is never nullptr. Remove this check and add a
// DCHECK into the constructor.
- if (!language_histogram_ || !IsSendingTopLanguagesEnabled()) {
+ if (!language_histogram_ || !kSendTopLanguages.Get()) {
return;
}

Powered by Google App Engine
This is Rietveld 408576698