| 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/gaia_oauth_client.h" | 5 #include "google_apis/gaia/gaia_oauth_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void GaiaOAuthClient::Core::GetUserInfoImpl( | 166 void GaiaOAuthClient::Core::GetUserInfoImpl( |
| 167 RequestType type, | 167 RequestType type, |
| 168 const std::string& oauth_access_token, | 168 const std::string& oauth_access_token, |
| 169 int max_retries, | 169 int max_retries, |
| 170 Delegate* delegate) { | 170 Delegate* delegate) { |
| 171 DCHECK_EQ(request_type_, NO_PENDING_REQUEST); | 171 DCHECK_EQ(request_type_, NO_PENDING_REQUEST); |
| 172 DCHECK(!request_.get()); | 172 DCHECK(!request_.get()); |
| 173 request_type_ = type; | 173 request_type_ = type; |
| 174 delegate_ = delegate; | 174 delegate_ = delegate; |
| 175 num_retries_ = 0; | 175 num_retries_ = 0; |
| 176 request_.reset(net::URLFetcher::Create( | 176 request_ = net::URLFetcher::Create( |
| 177 kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()), | 177 kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()), |
| 178 net::URLFetcher::GET, this)); | 178 net::URLFetcher::GET, this); |
| 179 request_->SetRequestContext(request_context_getter_.get()); | 179 request_->SetRequestContext(request_context_getter_.get()); |
| 180 request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token); | 180 request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token); |
| 181 request_->SetMaxRetriesOn5xx(max_retries); | 181 request_->SetMaxRetriesOn5xx(max_retries); |
| 182 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 182 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 183 net::LOAD_DO_NOT_SAVE_COOKIES); | 183 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 184 | 184 |
| 185 // Fetchers are sometimes cancelled because a network change was detected, | 185 // Fetchers are sometimes cancelled because a network change was detected, |
| 186 // especially at startup and after sign-in on ChromeOS. Retrying once should | 186 // especially at startup and after sign-in on ChromeOS. Retrying once should |
| 187 // be enough in those cases; let the fetcher retry up to 3 times just in case. | 187 // be enough in those cases; let the fetcher retry up to 3 times just in case. |
| 188 // http://crbug.com/163710 | 188 // http://crbug.com/163710 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 void GaiaOAuthClient::Core::MakeGaiaRequest( | 208 void GaiaOAuthClient::Core::MakeGaiaRequest( |
| 209 const GURL& url, | 209 const GURL& url, |
| 210 const std::string& post_body, | 210 const std::string& post_body, |
| 211 int max_retries, | 211 int max_retries, |
| 212 GaiaOAuthClient::Delegate* delegate) { | 212 GaiaOAuthClient::Delegate* delegate) { |
| 213 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; | 213 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; |
| 214 delegate_ = delegate; | 214 delegate_ = delegate; |
| 215 num_retries_ = 0; | 215 num_retries_ = 0; |
| 216 request_.reset(net::URLFetcher::Create( | 216 request_ = |
| 217 kUrlFetcherId, url, net::URLFetcher::POST, this)); | 217 net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST, this); |
| 218 request_->SetRequestContext(request_context_getter_.get()); | 218 request_->SetRequestContext(request_context_getter_.get()); |
| 219 request_->SetUploadData("application/x-www-form-urlencoded", post_body); | 219 request_->SetUploadData("application/x-www-form-urlencoded", post_body); |
| 220 request_->SetMaxRetriesOn5xx(max_retries); | 220 request_->SetMaxRetriesOn5xx(max_retries); |
| 221 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 221 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 222 net::LOAD_DO_NOT_SAVE_COOKIES); | 222 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 223 // See comment on SetAutomaticallyRetryOnNetworkChanges() above. | 223 // See comment on SetAutomaticallyRetryOnNetworkChanges() above. |
| 224 request_->SetAutomaticallyRetryOnNetworkChanges(3); | 224 request_->SetAutomaticallyRetryOnNetworkChanges(3); |
| 225 request_->Start(); | 225 request_->Start(); |
| 226 } | 226 } |
| 227 | 227 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 403 } |
| 404 | 404 |
| 405 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle, | 405 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle, |
| 406 int max_retries, | 406 int max_retries, |
| 407 Delegate* delegate) { | 407 Delegate* delegate) { |
| 408 return core_->GetTokenInfo("token_handle", token_handle, max_retries, | 408 return core_->GetTokenInfo("token_handle", token_handle, max_retries, |
| 409 delegate); | 409 delegate); |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace gaia | 412 } // namespace gaia |
| OLD | NEW |