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

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

Issue 2548343002: NTPSnippets: Set MaxRetriesOn5xx only for interactive requests. (Closed)
Patch Set: Rebased. Created 4 years 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/ntp_snippets_fetcher.cc
diff --git a/components/ntp_snippets/remote/ntp_snippets_fetcher.cc b/components/ntp_snippets/remote/ntp_snippets_fetcher.cc
index 76ec5f1e74585dcc93d1db4bacd49745612ecec3..360d4764d079f064895b53f462cb47b7dbd0c706 100644
--- a/components/ntp_snippets/remote/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/remote/ntp_snippets_fetcher.cc
@@ -4,6 +4,7 @@
#include "components/ntp_snippets/remote/ntp_snippets_fetcher.h"
+#include <algorithm>
#include <cstdlib>
#include <utility>
@@ -61,6 +62,9 @@ const char kAuthorizationRequestHeaderFormat[] = "Bearer %s";
// Variation parameter for personalizing fetching of snippets.
const char kPersonalizationName[] = "fetching_personalization";
+// Variation parameter for disabling the retry.
+const char kBackground5xxRetriesName[] = "background_5xx_retries_count";
+
// Variation parameter for chrome-content-suggestions backend.
const char kContentSuggestionsBackend[] = "content_suggestions_backend";
@@ -132,6 +136,15 @@ bool IsBooleanParameterEnabled(const std::string& param_name,
return default_value;
}
+int Get5xxRetryCount(bool interactive_request) {
+ if (interactive_request) {
+ return 2;
+ }
+ return std::max(0, variations::GetVariationParamByFeatureAsInt(
+ ntp_snippets::kArticleSuggestionsFeature,
+ kBackground5xxRetriesName, 0));
+}
+
bool UsesChromeContentSuggestionsAPI(const GURL& endpoint) {
if (endpoint == kChromeReaderServer) {
return false;
@@ -812,8 +825,8 @@ NTPSnippetsFetcher::RequestBuilder::BuildURLFetcher(
// Fetchers are sometimes cancelled because a network change was detected.
url_fetcher->SetAutomaticallyRetryOnNetworkChanges(3);
- // Try to make fetching the files bit more robust even with poor connection.
- url_fetcher->SetMaxRetriesOn5xx(3);
+ url_fetcher->SetMaxRetriesOn5xx(
+ Get5xxRetryCount(params_.interactive_request));
return url_fetcher;
}

Powered by Google App Engine
This is Rietveld 408576698