| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/gaia/oauth2_api_call_flow.h" | 5 #include "google_apis/gaia/oauth2_api_call_flow.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" | 
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" | 
| 12 #include "google_apis/gaia/gaia_urls.h" | 12 #include "google_apis/gaia/gaia_urls.h" | 
|  | 13 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h" | 
| 13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" | 
| 14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" | 
| 15 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" | 
| 16 #include "net/url_request/url_fetcher.h" | 17 #include "net/url_request/url_fetcher.h" | 
| 17 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" | 
| 18 #include "net/url_request/url_request_status.h" | 19 #include "net/url_request/url_request_status.h" | 
| 19 | 20 | 
| 20 using net::ResponseCookies; | 21 using net::ResponseCookies; | 
| 21 using net::URLFetcher; | 22 using net::URLFetcher; | 
| 22 using net::URLFetcherDelegate; | 23 using net::URLFetcherDelegate; | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 119   if (!error) { | 120   if (!error) { | 
| 120     state_ = MINT_ACCESS_TOKEN_DONE; | 121     state_ = MINT_ACCESS_TOKEN_DONE; | 
| 121     BeginApiCall(); | 122     BeginApiCall(); | 
| 122   } else { | 123   } else { | 
| 123     state_ = ERROR_STATE; | 124     state_ = ERROR_STATE; | 
| 124     ProcessMintAccessTokenFailure(*error); | 125     ProcessMintAccessTokenFailure(*error); | 
| 125   } | 126   } | 
| 126 } | 127 } | 
| 127 | 128 | 
| 128 OAuth2AccessTokenFetcher* OAuth2ApiCallFlow::CreateAccessTokenFetcher() { | 129 OAuth2AccessTokenFetcher* OAuth2ApiCallFlow::CreateAccessTokenFetcher() { | 
| 129   return new OAuth2AccessTokenFetcher(this, context_); | 130   return new OAuth2AccessTokenFetcherImpl(this, context_); | 
| 130 } | 131 } | 
| 131 | 132 | 
| 132 void OAuth2ApiCallFlow::OnURLFetchComplete(const net::URLFetcher* source) { | 133 void OAuth2ApiCallFlow::OnURLFetchComplete(const net::URLFetcher* source) { | 
| 133   CHECK(source); | 134   CHECK(source); | 
| 134   CHECK_EQ(API_CALL_STARTED, state_); | 135   CHECK_EQ(API_CALL_STARTED, state_); | 
| 135   EndApiCall(source); | 136   EndApiCall(source); | 
| 136 } | 137 } | 
| 137 | 138 | 
| 138 void OAuth2ApiCallFlow::OnGetTokenSuccess(const std::string& access_token, | 139 void OAuth2ApiCallFlow::OnGetTokenSuccess(const std::string& access_token, | 
| 139                                           const base::Time& expiration_time) { | 140                                           const base::Time& expiration_time) { | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 163   // especially at startup and after sign-in on ChromeOS. Retrying once should | 164   // especially at startup and after sign-in on ChromeOS. Retrying once should | 
| 164   // be enough in those cases; let the fetcher retry up to 3 times just in case. | 165   // be enough in those cases; let the fetcher retry up to 3 times just in case. | 
| 165   // http://crbug.com/163710 | 166   // http://crbug.com/163710 | 
| 166   result->SetAutomaticallyRetryOnNetworkChanges(3); | 167   result->SetAutomaticallyRetryOnNetworkChanges(3); | 
| 167 | 168 | 
| 168   if (!empty_body) | 169   if (!empty_body) | 
| 169     result->SetUploadData("application/x-www-form-urlencoded", body); | 170     result->SetUploadData("application/x-www-form-urlencoded", body); | 
| 170 | 171 | 
| 171   return result; | 172   return result; | 
| 172 } | 173 } | 
| OLD | NEW | 
|---|