summaryrefslogtreecommitdiffstats
path: root/google_apis/gaia/oauth2_access_token_fetcher.cc
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-08 15:53:46 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-08 15:53:46 +0000
commitbe35a925668bfbcced00be73e04f2abd7905c5cd (patch)
tree78ec5bc6e0168288073b787bc4356874248b5af9 /google_apis/gaia/oauth2_access_token_fetcher.cc
parentd890df477eb876be1688b7bebd4d10b51a1b16a8 (diff)
downloadchromium_src-be35a925668bfbcced00be73e04f2abd7905c5cd.zip
chromium_src-be35a925668bfbcced00be73e04f2abd7905c5cd.tar.gz
chromium_src-be35a925668bfbcced00be73e04f2abd7905c5cd.tar.bz2
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
Diffstat (limited to 'google_apis/gaia/oauth2_access_token_fetcher.cc')
-rw-r--r--google_apis/gaia/oauth2_access_token_fetcher.cc65
1 files changed, 33 insertions, 32 deletions
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.