From be35a925668bfbcced00be73e04f2abd7905c5cd Mon Sep 17 00:00:00 2001 From: "tim@chromium.org" Date: Fri, 8 Nov 2013 15:53:46 +0000 Subject: sync: treat gaia http 500s as retriable. Both OAuth2TokenService and ProfileSyncService will now retry on HTTP 500s. Note that ProfileSyncService retries will only kick in if OA2TS gives up after a fixed number of attempts. BUG=311420 Review URL: https://codereview.chromium.org/61833003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233908 0039d316-1c4b-4281-b951-d872f2087c98 --- google_apis/gaia/oauth2_access_token_fetcher.cc | 65 +++++++++++++------------ 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'google_apis/gaia/oauth2_access_token_fetcher.cc') diff --git a/google_apis/gaia/oauth2_access_token_fetcher.cc b/google_apis/gaia/oauth2_access_token_fetcher.cc index 40df250..ab38205 100644 --- a/google_apis/gaia/oauth2_access_token_fetcher.cc +++ b/google_apis/gaia/oauth2_access_token_fetcher.cc @@ -167,42 +167,43 @@ void OAuth2AccessTokenFetcher::EndGetAccessToken( return; } - // HTTP_FORBIDDEN (403) is treated as temporary error, because it may be - // '403 Rate Limit Exeeded.' - if (source->GetResponseCode() == net::HTTP_FORBIDDEN) { - OnGetTokenFailure(GoogleServiceAuthError( - GoogleServiceAuthError::SERVICE_UNAVAILABLE)); - return; - } - - if (source->GetResponseCode() == net::HTTP_BAD_REQUEST) { - // HTTP_BAD_REQUEST (400) usually contains error as per - // http://tools.ietf.org/html/rfc6749#section-5.2. - std::string gaia_error; - OAuth2ErrorCodesForHistogram access_error(OAUTH2_ACCESS_ERROR_UNKNOWN); - if (!ParseGetAccessTokenFailureResponse(source, &gaia_error)) { + switch (source->GetResponseCode()) { + case net::HTTP_OK: + break; + case net::HTTP_FORBIDDEN: + case net::HTTP_INTERNAL_SERVER_ERROR: + // HTTP_FORBIDDEN (403) is treated as temporary error, because it may be + // '403 Rate Limit Exeeded.' 500 is always treated as transient. OnGetTokenFailure(GoogleServiceAuthError( GoogleServiceAuthError::SERVICE_UNAVAILABLE)); return; - } - - access_error = OAuth2ErrorToHistogramValue(gaia_error); - UMA_HISTOGRAM_ENUMERATION("Gaia.BadRequestTypeForOAuth2AccessToken", - access_error, OAUTH2_ACCESS_ERROR_COUNT); - - OnGetTokenFailure(access_error == OAUTH2_ACCESS_ERROR_INVALID_GRANT ? - GoogleServiceAuthError( - GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) : - GoogleServiceAuthError( + case net::HTTP_BAD_REQUEST: { + // HTTP_BAD_REQUEST (400) usually contains error as per + // http://tools.ietf.org/html/rfc6749#section-5.2. + std::string gaia_error; + if (!ParseGetAccessTokenFailureResponse(source, &gaia_error)) { + OnGetTokenFailure(GoogleServiceAuthError( GoogleServiceAuthError::SERVICE_ERROR)); - return; - } - - // The other errors are treated as permanent error. - if (source->GetResponseCode() != net::HTTP_OK) { - OnGetTokenFailure(GoogleServiceAuthError( - GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); - return; + return; + } + + OAuth2ErrorCodesForHistogram access_error(OAuth2ErrorToHistogramValue( + gaia_error)); + UMA_HISTOGRAM_ENUMERATION("Gaia.BadRequestTypeForOAuth2AccessToken", + access_error, OAUTH2_ACCESS_ERROR_COUNT); + + OnGetTokenFailure(access_error == OAUTH2_ACCESS_ERROR_INVALID_GRANT ? + GoogleServiceAuthError( + GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) : + GoogleServiceAuthError( + GoogleServiceAuthError::SERVICE_ERROR)); + return; + } + default: + // The other errors are treated as permanent error. + OnGetTokenFailure(GoogleServiceAuthError( + GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); + return; } // The request was successfully fetched and it returned OK. -- cgit v1.1