OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h" | 5 #include "chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h" |
6 | 6 |
7 #include "base/profiler/scoped_tracker.h" | 7 #include "base/profiler/scoped_tracker.h" |
8 #include "components/signin/core/browser/signin_client.h" | 8 #include "components/signin/core/browser/signin_client.h" |
9 #include "components/signin/core/browser/signin_metrics.h" | 9 #include "components/signin/core/browser/signin_metrics.h" |
10 #include "components/signin/core/browser/webdata/token_web_data.h" | 10 #include "components/signin/core/browser/webdata/token_web_data.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (backoff_entry_.ShouldRejectRequest()) { | 165 if (backoff_entry_.ShouldRejectRequest()) { |
166 VLOG(1) << "Request for token has been rejected due to backoff rules from" | 166 VLOG(1) << "Request for token has been rejected due to backoff rules from" |
167 << " previous error #" << backoff_error_.state(); | 167 << " previous error #" << backoff_error_.state(); |
168 return new OAuth2AccessTokenFetcherImmediateError(consumer, backoff_error_); | 168 return new OAuth2AccessTokenFetcherImmediateError(consumer, backoff_error_); |
169 } | 169 } |
170 std::string refresh_token = GetRefreshToken(account_id); | 170 std::string refresh_token = GetRefreshToken(account_id); |
171 DCHECK(!refresh_token.empty()); | 171 DCHECK(!refresh_token.empty()); |
172 return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token); | 172 return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token); |
173 } | 173 } |
174 | 174 |
| 175 bool MutableProfileOAuth2TokenServiceDelegate::RefreshTokenHasError( |
| 176 const std::string& account_id) const { |
| 177 auto it = refresh_tokens_.find(account_id); |
| 178 return it == refresh_tokens_.end() ? false |
| 179 : IsError(it->second->GetAuthStatus()); |
| 180 } |
| 181 |
175 void MutableProfileOAuth2TokenServiceDelegate::UpdateAuthError( | 182 void MutableProfileOAuth2TokenServiceDelegate::UpdateAuthError( |
176 const std::string& account_id, | 183 const std::string& account_id, |
177 const GoogleServiceAuthError& error) { | 184 const GoogleServiceAuthError& error) { |
178 VLOG(1) << "MutablePO2TS::UpdateAuthError. Error: " << error.state(); | 185 VLOG(1) << "MutablePO2TS::UpdateAuthError. Error: " << error.state(); |
179 backoff_entry_.InformOfRequest(!error.IsTransientError()); | 186 backoff_entry_.InformOfRequest(!error.IsTransientError()); |
180 ValidateAccountId(account_id); | 187 ValidateAccountId(account_id); |
181 | 188 |
182 // Do not report connection errors as these are not actually auth errors. | 189 // Do not report connection errors as these are not actually auth errors. |
183 // We also want to avoid masking a "real" auth error just because we | 190 // We also want to avoid masking a "real" auth error just because we |
184 // subsequently get a transient network error. We do keep it around though | 191 // subsequently get a transient network error. We do keep it around though |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 web_data_service_request_ = 0; | 493 web_data_service_request_ = 0; |
487 } | 494 } |
488 } | 495 } |
489 | 496 |
490 void MutableProfileOAuth2TokenServiceDelegate::Shutdown() { | 497 void MutableProfileOAuth2TokenServiceDelegate::Shutdown() { |
491 VLOG(1) << "MutablePO2TS::Shutdown"; | 498 VLOG(1) << "MutablePO2TS::Shutdown"; |
492 server_revokes_.clear(); | 499 server_revokes_.clear(); |
493 CancelWebTokenFetch(); | 500 CancelWebTokenFetch(); |
494 refresh_tokens_.clear(); | 501 refresh_tokens_.clear(); |
495 } | 502 } |
OLD | NEW |