Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: google_apis/gaia/gaia_oauth_client.cc

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | google_apis/gaia/gaia_oauth_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | google_apis/gaia/gaia_oauth_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698