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

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

Issue 1330443002: Report data usage UMA for Chrome services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Addressing sclittle's comments. Created 5 years, 3 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 "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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/data_use_measurement/core/data_use_user_data.h"
12 #include "google_apis/gaia/gaia_urls.h" 13 #include "google_apis/gaia/gaia_urls.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_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
18 #include "net/url_request/url_request_context_getter.h" 19 #include "net/url_request/url_request_context_getter.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace { 22 namespace {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 int max_retries, 170 int max_retries,
170 Delegate* delegate) { 171 Delegate* delegate) {
171 DCHECK_EQ(request_type_, NO_PENDING_REQUEST); 172 DCHECK_EQ(request_type_, NO_PENDING_REQUEST);
172 DCHECK(!request_.get()); 173 DCHECK(!request_.get());
173 request_type_ = type; 174 request_type_ = type;
174 delegate_ = delegate; 175 delegate_ = delegate;
175 num_retries_ = 0; 176 num_retries_ = 0;
176 request_ = net::URLFetcher::Create( 177 request_ = net::URLFetcher::Create(
177 kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()), 178 kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()),
178 net::URLFetcher::GET, this); 179 net::URLFetcher::GET, this);
180 data_use_measurement::DataUseUserData::AttachToFetcher(
181 request_.get(), data_use_measurement::DataUseUserData::GOOGLE_APIS);
179 request_->SetRequestContext(request_context_getter_.get()); 182 request_->SetRequestContext(request_context_getter_.get());
180 request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token); 183 request_->AddExtraRequestHeader("Authorization: OAuth " + oauth_access_token);
181 request_->SetMaxRetriesOn5xx(max_retries); 184 request_->SetMaxRetriesOn5xx(max_retries);
182 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 185 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
183 net::LOAD_DO_NOT_SAVE_COOKIES); 186 net::LOAD_DO_NOT_SAVE_COOKIES);
184 187
185 // Fetchers are sometimes cancelled because a network change was detected, 188 // Fetchers are sometimes cancelled because a network change was detected,
186 // especially at startup and after sign-in on ChromeOS. Retrying once should 189 // 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. 190 // be enough in those cases; let the fetcher retry up to 3 times just in case.
188 // http://crbug.com/163710 191 // http://crbug.com/163710
(...skipping 19 matching lines...) Expand all
208 void GaiaOAuthClient::Core::MakeGaiaRequest( 211 void GaiaOAuthClient::Core::MakeGaiaRequest(
209 const GURL& url, 212 const GURL& url,
210 const std::string& post_body, 213 const std::string& post_body,
211 int max_retries, 214 int max_retries,
212 GaiaOAuthClient::Delegate* delegate) { 215 GaiaOAuthClient::Delegate* delegate) {
213 DCHECK(!request_.get()) << "Tried to fetch two things at once!"; 216 DCHECK(!request_.get()) << "Tried to fetch two things at once!";
214 delegate_ = delegate; 217 delegate_ = delegate;
215 num_retries_ = 0; 218 num_retries_ = 0;
216 request_ = 219 request_ =
217 net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST, this); 220 net::URLFetcher::Create(kUrlFetcherId, url, net::URLFetcher::POST, this);
221 data_use_measurement::DataUseUserData::AttachToFetcher(
222 request_.get(), data_use_measurement::DataUseUserData::GOOGLE_APIS);
218 request_->SetRequestContext(request_context_getter_.get()); 223 request_->SetRequestContext(request_context_getter_.get());
219 request_->SetUploadData("application/x-www-form-urlencoded", post_body); 224 request_->SetUploadData("application/x-www-form-urlencoded", post_body);
220 request_->SetMaxRetriesOn5xx(max_retries); 225 request_->SetMaxRetriesOn5xx(max_retries);
221 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 226 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
222 net::LOAD_DO_NOT_SAVE_COOKIES); 227 net::LOAD_DO_NOT_SAVE_COOKIES);
223 // See comment on SetAutomaticallyRetryOnNetworkChanges() above. 228 // See comment on SetAutomaticallyRetryOnNetworkChanges() above.
224 request_->SetAutomaticallyRetryOnNetworkChanges(3); 229 request_->SetAutomaticallyRetryOnNetworkChanges(3);
225 request_->Start(); 230 request_->Start();
226 } 231 }
227 232
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 408 }
404 409
405 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle, 410 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle,
406 int max_retries, 411 int max_retries,
407 Delegate* delegate) { 412 Delegate* delegate) {
408 return core_->GetTokenInfo("token_handle", token_handle, max_retries, 413 return core_->GetTokenInfo("token_handle", token_handle, max_retries,
409 delegate); 414 delegate);
410 } 415 }
411 416
412 } // namespace gaia 417 } // namespace gaia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698