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

Side by Side Diff: chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc

Issue 2644223003: Add data usage tracking for supervised_user service (Closed)
Patch Set: rebased 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fe tcher.h" 5 #include "chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fe tcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.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_constants.h" 13 #include "google_apis/gaia/gaia_constants.h"
13 #include "google_apis/gaia/gaia_oauth_client.h" 14 #include "google_apis/gaia/gaia_oauth_client.h"
14 #include "google_apis/gaia/gaia_urls.h" 15 #include "google_apis/gaia/gaia_urls.h"
15 #include "google_apis/gaia/google_service_auth_error.h" 16 #include "google_apis/gaia/google_service_auth_error.h"
16 #include "google_apis/gaia/oauth2_api_call_flow.h" 17 #include "google_apis/gaia/oauth2_api_call_flow.h"
17 #include "google_apis/gaia/oauth2_token_service.h" 18 #include "google_apis/gaia/oauth2_token_service.h"
18 #include "net/base/escape.h" 19 #include "net/base/escape.h"
19 #include "net/base/load_flags.h" 20 #include "net/base/load_flags.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/http/http_status_code.h" 22 #include "net/http/http_status_code.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 DCHECK_EQ(access_token_request_.get(), request); 156 DCHECK_EQ(access_token_request_.get(), request);
156 access_token_ = access_token; 157 access_token_ = access_token;
157 158
158 GURL url(GaiaUrls::GetInstance()->oauth2_issue_token_url()); 159 GURL url(GaiaUrls::GetInstance()->oauth2_issue_token_url());
159 // GaiaOAuthClient uses id 0, so we use 1 to distinguish the requests in 160 // GaiaOAuthClient uses id 0, so we use 1 to distinguish the requests in
160 // unit tests. 161 // unit tests.
161 const int id = 1; 162 const int id = 1;
162 163
163 url_fetcher_ = URLFetcher::Create(id, url, URLFetcher::POST, this); 164 url_fetcher_ = URLFetcher::Create(id, url, URLFetcher::POST, this);
164 165
166 data_use_measurement::DataUseUserData::AttachToFetcher(
167 url_fetcher_.get(),
168 data_use_measurement::DataUseUserData::SUPERVISED_USER);
165 url_fetcher_->SetRequestContext(context_); 169 url_fetcher_->SetRequestContext(context_);
166 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 170 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
167 net::LOAD_DO_NOT_SAVE_COOKIES); 171 net::LOAD_DO_NOT_SAVE_COOKIES);
168 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); 172 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries);
169 url_fetcher_->AddExtraRequestHeader( 173 url_fetcher_->AddExtraRequestHeader(
170 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); 174 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str()));
171 175
172 std::string body = base::StringPrintf( 176 std::string body = base::StringPrintf(
173 kIssueTokenBodyFormat, 177 kIssueTokenBodyFormat,
174 net::EscapeUrlEncodedData( 178 net::EscapeUrlEncodedData(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 const std::string& account_id, 299 const std::string& account_id,
296 const std::string& device_id, 300 const std::string& device_id,
297 URLRequestContextGetter* context) { 301 URLRequestContextGetter* context) {
298 std::unique_ptr<SupervisedUserRefreshTokenFetcher> fetcher( 302 std::unique_ptr<SupervisedUserRefreshTokenFetcher> fetcher(
299 new SupervisedUserRefreshTokenFetcherImpl( 303 new SupervisedUserRefreshTokenFetcherImpl(
300 oauth2_token_service, account_id, device_id, context)); 304 oauth2_token_service, account_id, device_id, context));
301 return fetcher; 305 return fetcher;
302 } 306 }
303 307
304 SupervisedUserRefreshTokenFetcher::~SupervisedUserRefreshTokenFetcher() {} 308 SupervisedUserRefreshTokenFetcher::~SupervisedUserRefreshTokenFetcher() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698