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

Side by Side Diff: components/policy/core/common/cloud/user_info_fetcher.cc

Issue 1330443002: Report data usage UMA for Chrome services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Fix calling Init function in sync_client.cc 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 "components/policy/core/common/cloud/user_info_fetcher.h" 5 #include "components/policy/core/common/cloud/user_info_fetcher.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/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "components/data_use_measurement/core/data_use_user_data.h"
11 #include "google_apis/gaia/gaia_urls.h" 12 #include "google_apis/gaia/gaia_urls.h"
12 #include "google_apis/gaia/google_service_auth_error.h" 13 #include "google_apis/gaia/google_service_auth_error.h"
13 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
14 #include "net/http/http_status_code.h" 15 #include "net/http/http_status_code.h"
15 #include "net/url_request/url_fetcher.h" 16 #include "net/url_request/url_fetcher.h"
16 #include "net/url_request/url_request_status.h" 17 #include "net/url_request/url_request_status.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 namespace { 20 namespace {
20 21
(...skipping 16 matching lines...) Expand all
37 } 38 }
38 39
39 UserInfoFetcher::~UserInfoFetcher() { 40 UserInfoFetcher::~UserInfoFetcher() {
40 } 41 }
41 42
42 void UserInfoFetcher::Start(const std::string& access_token) { 43 void UserInfoFetcher::Start(const std::string& access_token) {
43 // Create a URLFetcher and start it. 44 // Create a URLFetcher and start it.
44 url_fetcher_ = 45 url_fetcher_ =
45 net::URLFetcher::Create(0, GaiaUrls::GetInstance()->oauth_user_info_url(), 46 net::URLFetcher::Create(0, GaiaUrls::GetInstance()->oauth_user_info_url(),
46 net::URLFetcher::GET, this); 47 net::URLFetcher::GET, this);
48 data_use_measurement::DataUseUserData::AttachToFetcher(
49 url_fetcher_.get(), data_use_measurement::DataUseUserData::POLICY);
47 url_fetcher_->SetRequestContext(context_); 50 url_fetcher_->SetRequestContext(context_);
48 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 51 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
49 net::LOAD_DO_NOT_SAVE_COOKIES); 52 net::LOAD_DO_NOT_SAVE_COOKIES);
50 url_fetcher_->AddExtraRequestHeader(MakeAuthorizationHeader(access_token)); 53 url_fetcher_->AddExtraRequestHeader(MakeAuthorizationHeader(access_token));
51 url_fetcher_->Start(); // Results in a call to OnURLFetchComplete(). 54 url_fetcher_->Start(); // Results in a call to OnURLFetchComplete().
52 } 55 }
53 56
54 void UserInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) { 57 void UserInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
55 net::URLRequestStatus status = source->GetStatus(); 58 net::URLRequestStatus status = source->GetStatus();
56 GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); 59 GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone();
(...skipping 23 matching lines...) Expand all
80 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) { 83 if (parsed_value.get() && parsed_value->GetAsDictionary(&dict)) {
81 delegate_->OnGetUserInfoSuccess(dict); 84 delegate_->OnGetUserInfoSuccess(dict);
82 } else { 85 } else {
83 NOTREACHED() << "Could not parse userinfo response from server"; 86 NOTREACHED() << "Could not parse userinfo response from server";
84 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError( 87 delegate_->OnGetUserInfoFailure(GoogleServiceAuthError(
85 GoogleServiceAuthError::CONNECTION_FAILED)); 88 GoogleServiceAuthError::CONNECTION_FAILED));
86 } 89 }
87 } 90 }
88 91
89 }; // namespace policy 92 }; // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/cloud/external_policy_data_fetcher.cc ('k') | components/policy/policy_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698