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

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.cc

Issue 2273323002: NTP Snippets: Added error codes for out of quota events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/ntp_snippets_fetcher.cc
diff --git a/components/ntp_snippets/ntp_snippets_fetcher.cc b/components/ntp_snippets/ntp_snippets_fetcher.cc
index c0018e7d816ad650ff06f25bdf664b5b64034e2e..c040af7b25f331ca4eccae7d55bc6217ba97c32b 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher.cc
@@ -86,6 +86,10 @@ std::string FetchResultToString(NTPSnippetsFetcher::FetchResult result) {
return "Invalid / empty list.";
case NTPSnippetsFetcher::FetchResult::OAUTH_TOKEN_ERROR:
return "Error in obtaining an OAuth2 access token.";
+ case NTPSnippetsFetcher::FetchResult::INTERACTIVE_QUOTA_ERROR:
+ return "Out of interactive quota.";
+ case NTPSnippetsFetcher::FetchResult::NON_INTERACTIVE_QUOTA_ERROR:
+ return "Out of non-interactive quota.";
case NTPSnippetsFetcher::FetchResult::RESULT_MAX:
break;
}
@@ -218,8 +222,15 @@ void NTPSnippetsFetcher::FetchSnippetsFromHosts(
const std::string& language_code,
int count,
bool interactive_request) {
- if (!request_throttler_.DemandQuotaForRequest(interactive_request))
+ if (!request_throttler_.DemandQuotaForRequest(interactive_request)) {
+ FetchFinished(
+ OptionalSnippets(),
+ interactive_request ?
+ FetchResult::INTERACTIVE_QUOTA_ERROR :
+ FetchResult::NON_INTERACTIVE_QUOTA_ERROR,
+ /*extra_message=*/std::string());
return;
+ }
hosts_ = hosts;
fetch_start_time_ = tick_clock_->NowTicks();

Powered by Google App Engine
This is Rietveld 408576698