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

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.cc

Issue 1699143002: [NTP Snippets] Schedule periodic fetching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snippets_feature
Patch Set: Created 4 years, 10 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 f7c82fab41c6cf74a37108c0f03ca1f4dc24909c..00e2e871e67a8c0cd8cbca1250bf70001254b7e4 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher.cc
@@ -57,6 +57,7 @@ NTPSnippetsFetcher::NTPSnippetsFetcher(
url_request_context_getter_(url_request_context_getter),
signin_manager_(signin_manager),
token_service_(token_service),
+ waiting_for_refresh_token_(false),
weak_ptr_factory_(this) {}
NTPSnippetsFetcher::~NTPSnippetsFetcher() {}
@@ -89,9 +90,10 @@ void NTPSnippetsFetcher::OnFileExistsCheckDone(bool exists) {
void NTPSnippetsFetcher::StartFetch() {
if (signin_manager_->IsAuthenticated()) {
StartTokenRequest();
- } else {
+ } else if (!waiting_for_refresh_token_) {
// Wait until we get a refresh token.
token_service_->AddObserver(this);
+ waiting_for_refresh_token_ = true;
}
}
@@ -142,6 +144,7 @@ void NTPSnippetsFetcher::OnGetTokenFailure(
void NTPSnippetsFetcher::OnRefreshTokenAvailable(
const std::string& account_id) {
token_service_->RemoveObserver(this);
+ waiting_for_refresh_token_ = false;
StartTokenRequest();
}

Powered by Google App Engine
This is Rietveld 408576698