Chromium Code Reviews| 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 d8ca50902d94038d5d08f33d7b35d85b6716b5f6..6211c4d42afaa0fca40f0f72f862272dd495c292 100644 |
| --- a/components/ntp_snippets/ntp_snippets_fetcher.cc |
| +++ b/components/ntp_snippets/ntp_snippets_fetcher.cc |
| @@ -232,6 +232,7 @@ void NTPSnippetsFetcher::FetchSnippetsFromHosts( |
| if (use_authentication && signin_manager_->IsAuthenticated()) { |
| // Signed-in: get OAuth token --> fetch snippets. |
| + oauth_token_retried_ = false; |
|
Marc Treib
2016/08/11 09:35:17
You should also initialize this in the ctor
jkrcal
2016/08/11 10:03:56
Done.
I was wondering about it. In the current c
Marc Treib
2016/08/11 10:11:03
Yes. I'm not sure if the style guide has a rule ab
jkrcal
2016/08/11 12:31:48
Makes sense. Thanks.
|
| StartTokenRequest(); |
| } else if (use_authentication && signin_manager_->AuthInProgress()) { |
| // Currently signing in: wait for auth to finish (the refresh token) --> |
| @@ -436,8 +437,17 @@ void NTPSnippetsFetcher::OnGetTokenFailure( |
| const OAuth2TokenService::Request* request, |
| const GoogleServiceAuthError& error) { |
| oauth_request_.reset(); |
| - DLOG(ERROR) << "Unable to get token: " << error.ToString() |
| - << " - fetching the snippets without authentication."; |
|
Marc Treib
2016/08/11 09:35:17
Outdated documentation ftl :D
jkrcal
2016/08/11 10:03:56
:)
|
| + |
| + if (!oauth_token_retried_ && |
| + error.state() == GoogleServiceAuthError::State::REQUEST_CANCELED) { |
| + // The request (especially on startup) can get reset by loading the refresh |
| + // token - do it one more time. |
| + oauth_token_retried_ = true; |
| + StartTokenRequest(); |
| + return; |
| + } |
| + |
| + DLOG(ERROR) << "Unable to get token: " << error.ToString(); |
| FetchFinished( |
| OptionalSnippets(), FetchResult::OAUTH_TOKEN_ERROR, |
| /*extra_message=*/base::StringPrintf(" (%s)", error.ToString().c_str())); |
| @@ -453,6 +463,7 @@ void NTPSnippetsFetcher::OnRefreshTokenAvailable( |
| token_service_->RemoveObserver(this); |
| waiting_for_refresh_token_ = false; |
| + oauth_token_retried_ = false; |
| StartTokenRequest(); |
| } |