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

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

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
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/values.h" 10 #include "base/values.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 int max_retries, 118 int max_retries,
119 Delegate* delegate) { 119 Delegate* delegate) {
120 DCHECK_EQ(request_type_, NO_PENDING_REQUEST); 120 DCHECK_EQ(request_type_, NO_PENDING_REQUEST);
121 DCHECK(!request_.get()); 121 DCHECK(!request_.get());
122 request_type_ = USER_INFO; 122 request_type_ = USER_INFO;
123 delegate_ = delegate; 123 delegate_ = delegate;
124 num_retries_ = 0; 124 num_retries_ = 0;
125 request_.reset(net::URLFetcher::Create( 125 request_.reset(net::URLFetcher::Create(
126 0, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()), 126 0, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()),
127 net::URLFetcher::GET, this)); 127 net::URLFetcher::GET, this));
128 request_->SetRequestContext(request_context_getter_); 128 request_->SetRequestContext(request_context_getter_.get());
129 request_->AddExtraRequestHeader( 129 request_->AddExtraRequestHeader(
130 "Authorization: OAuth " + oauth_access_token); 130 "Authorization: OAuth " + oauth_access_token);
131 request_->SetMaxRetries(max_retries); 131 request_->SetMaxRetries(max_retries);
132 request_->Start(); 132 request_->Start();
133 } 133 }
134 134
135 void GaiaOAuthClient::Core::MakeGaiaRequest( 135 void GaiaOAuthClient::Core::MakeGaiaRequest(
136 const std::string& post_body, 136 const std::string& post_body,
137 int max_retries, 137 int max_retries,
138 GaiaOAuthClient::Delegate* delegate) { 138 GaiaOAuthClient::Delegate* delegate) {
139 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; 139 DCHECK(!request_.get()) << "Tried to fetch two things at once!";
140 delegate_ = delegate; 140 delegate_ = delegate;
141 num_retries_ = 0; 141 num_retries_ = 0;
142 request_.reset(net::URLFetcher::Create( 142 request_.reset(net::URLFetcher::Create(
143 0, gaia_url_, net::URLFetcher::POST, this)); 143 0, gaia_url_, net::URLFetcher::POST, this));
144 request_->SetRequestContext(request_context_getter_); 144 request_->SetRequestContext(request_context_getter_.get());
145 request_->SetUploadData("application/x-www-form-urlencoded", post_body); 145 request_->SetUploadData("application/x-www-form-urlencoded", post_body);
146 request_->SetMaxRetries(max_retries); 146 request_->SetMaxRetries(max_retries);
147 request_->Start(); 147 request_->Start();
148 } 148 }
149 149
150 // URLFetcher::Delegate implementation. 150 // URLFetcher::Delegate implementation.
151 void GaiaOAuthClient::Core::OnURLFetchComplete( 151 void GaiaOAuthClient::Core::OnURLFetchComplete(
152 const net::URLFetcher* source) { 152 const net::URLFetcher* source) {
153 bool should_retry = false; 153 bool should_retry = false;
154 HandleResponse(source, &should_retry); 154 HandleResponse(source, &should_retry);
155 if (should_retry) { 155 if (should_retry) {
156 // Explicitly call ReceivedContentWasMalformed() to ensure the current 156 // Explicitly call ReceivedContentWasMalformed() to ensure the current
157 // request gets counted as a failure for calculation of the back-off 157 // request gets counted as a failure for calculation of the back-off
158 // period. If it was already a failure by status code, this call will 158 // period. If it was already a failure by status code, this call will
159 // be ignored. 159 // be ignored.
160 request_->ReceivedContentWasMalformed(); 160 request_->ReceivedContentWasMalformed();
161 num_retries_++; 161 num_retries_++;
162 // We must set our request_context_getter_ again because 162 // We must set our request_context_getter_ again because
163 // URLFetcher::Core::RetryOrCompleteUrlFetch resets it to NULL... 163 // URLFetcher::Core::RetryOrCompleteUrlFetch resets it to NULL...
164 request_->SetRequestContext(request_context_getter_); 164 request_->SetRequestContext(request_context_getter_.get());
165 request_->Start(); 165 request_->Start();
166 } 166 }
167 } 167 }
168 168
169 void GaiaOAuthClient::Core::HandleResponse( 169 void GaiaOAuthClient::Core::HandleResponse(
170 const net::URLFetcher* source, 170 const net::URLFetcher* source,
171 bool* should_retry_request) { 171 bool* should_retry_request) {
172 // Keep the URLFetcher object in case we need to reuse it. 172 // Keep the URLFetcher object in case we need to reuse it.
173 scoped_ptr<net::URLFetcher> old_request = request_.Pass(); 173 scoped_ptr<net::URLFetcher> old_request = request_.Pass();
174 DCHECK_EQ(source, old_request.get()); 174 DCHECK_EQ(source, old_request.get());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 delegate); 275 delegate);
276 } 276 }
277 277
278 void GaiaOAuthClient::GetUserInfo(const std::string& access_token, 278 void GaiaOAuthClient::GetUserInfo(const std::string& access_token,
279 int max_retries, 279 int max_retries,
280 Delegate* delegate) { 280 Delegate* delegate) {
281 return core_->GetUserInfo(access_token, max_retries, delegate); 281 return core_->GetUserInfo(access_token, max_retries, delegate);
282 } 282 }
283 283
284 } // namespace gaia 284 } // namespace gaia
OLDNEW
« no previous file with comments | « content/test/net/url_request_slow_download_job.cc ('k') | gpu/command_buffer/service/context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698