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

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

Issue 2575603002: Add data usage tracking for GAIA auth api (Closed)
Patch Set: Addressed tbansal comments Created 3 years, 11 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
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "google_apis/gaia/gaia_auth_util.h"
14 #include "google_apis/gaia/gaia_urls.h" 15 #include "google_apis/gaia/gaia_urls.h"
15 #include "net/base/escape.h" 16 #include "net/base/escape.h"
16 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
17 #include "net/http/http_status_code.h" 18 #include "net/http/http_status_code.h"
18 #include "net/url_request/url_fetcher.h" 19 #include "net/url_request/url_fetcher.h"
19 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 namespace { 24 namespace {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 delegate_ = delegate; 177 delegate_ = delegate;
177 num_retries_ = 0; 178 num_retries_ = 0;
178 request_ = net::URLFetcher::Create( 179 request_ = net::URLFetcher::Create(
179 kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()), 180 kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()),
180 net::URLFetcher::GET, this); 181 net::URLFetcher::GET, this);
181 request_->SetRequestContext(request_context_getter_.get()); 182 request_->SetRequestContext(request_context_getter_.get());
182 request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token); 183 request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token);
183 request_->SetMaxRetriesOn5xx(max_retries); 184 request_->SetMaxRetriesOn5xx(max_retries);
184 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 185 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
185 net::LOAD_DO_NOT_SAVE_COOKIES); 186 net::LOAD_DO_NOT_SAVE_COOKIES);
187 MarkURLFetcherAsGaia(request_.get());
186 188
187 // Fetchers are sometimes cancelled because a network change was detected, 189 // Fetchers are sometimes cancelled because a network change was detected,
188 // especially at startup and after sign-in on ChromeOS. Retrying once should 190 // especially at startup and after sign-in on ChromeOS. Retrying once should
189 // be enough in those cases; let the fetcher retry up to 3 times just in case. 191 // be enough in those cases; let the fetcher retry up to 3 times just in case.
190 // http://crbug.com/163710 192 // http://crbug.com/163710
191 request_->SetAutomaticallyRetryOnNetworkChanges(3); 193 request_->SetAutomaticallyRetryOnNetworkChanges(3);
192 request_->Start(); 194 request_->Start();
193 } 195 }
194 196
195 void GaiaOAuthClient::Core::GetTokenInfo(const std::string& qualifier, 197 void GaiaOAuthClient::Core::GetTokenInfo(const std::string& qualifier,
(...skipping 19 matching lines...) Expand all
215 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; 217 DCHECK(!request_.get()) << "Tried to fetch two things at once!";
216 delegate_ = delegate; 218 delegate_ = delegate;
217 num_retries_ = 0; 219 num_retries_ = 0;
218 request_ = 220 request_ =
219 net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST, this); 221 net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST, this);
220 request_->SetRequestContext(request_context_getter_.get()); 222 request_->SetRequestContext(request_context_getter_.get());
221 request_->SetUploadData("application/x-www-form-urlencoded", post_body); 223 request_->SetUploadData("application/x-www-form-urlencoded", post_body);
222 request_->SetMaxRetriesOn5xx(max_retries); 224 request_->SetMaxRetriesOn5xx(max_retries);
223 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 225 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
224 net::LOAD_DO_NOT_SAVE_COOKIES); 226 net::LOAD_DO_NOT_SAVE_COOKIES);
227 MarkURLFetcherAsGaia(request_.get());
225 // See comment on SetAutomaticallyRetryOnNetworkChanges() above. 228 // See comment on SetAutomaticallyRetryOnNetworkChanges() above.
226 request_->SetAutomaticallyRetryOnNetworkChanges(3); 229 request_->SetAutomaticallyRetryOnNetworkChanges(3);
227 request_->Start(); 230 request_->Start();
228 } 231 }
229 232
230 // URLFetcher::Delegate implementation. 233 // URLFetcher::Delegate implementation.
231 void GaiaOAuthClient::Core::OnURLFetchComplete( 234 void GaiaOAuthClient::Core::OnURLFetchComplete(
232 const net::URLFetcher* source) { 235 const net::URLFetcher* source) {
233 bool should_retry = false; 236 bool should_retry = false;
234 HandleResponse(source, &should_retry); 237 HandleResponse(source, &should_retry);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 409 }
407 410
408 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle, 411 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle,
409 int max_retries, 412 int max_retries,
410 Delegate* delegate) { 413 Delegate* delegate) {
411 return core_->GetTokenInfo("token_handle", token_handle, max_retries, 414 return core_->GetTokenInfo("token_handle", token_handle, max_retries,
412 delegate); 415 delegate);
413 } 416 }
414 417
415 } // namespace gaia 418 } // namespace gaia
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_auth_util.cc ('k') | google_apis/gaia/oauth2_access_token_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698