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

Side by Side Diff: google_apis/gaia/oauth2_api_call_flow.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/oauth2_api_call_flow.h" 5 #include "google_apis/gaia/oauth2_api_call_flow.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.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_request_context_getter.h" 17 #include "net/url_request/url_request_context_getter.h"
17 #include "net/url_request/url_request_status.h" 18 #include "net/url_request/url_request_status.h"
18 19
19 using net::ResponseCookies; 20 using net::ResponseCookies;
20 using net::URLFetcher; 21 using net::URLFetcher;
21 using net::URLFetcherDelegate; 22 using net::URLFetcherDelegate;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EndApiCall(source); 76 EndApiCall(source);
76 } 77 }
77 78
78 scoped_ptr<URLFetcher> OAuth2ApiCallFlow::CreateURLFetcher( 79 scoped_ptr<URLFetcher> OAuth2ApiCallFlow::CreateURLFetcher(
79 net::URLRequestContextGetter* context, 80 net::URLRequestContextGetter* context,
80 const std::string& access_token) { 81 const std::string& access_token) {
81 std::string body = CreateApiCallBody(); 82 std::string body = CreateApiCallBody();
82 net::URLFetcher::RequestType request_type = GetRequestTypeForBody(body); 83 net::URLFetcher::RequestType request_type = GetRequestTypeForBody(body);
83 scoped_ptr<URLFetcher> result = 84 scoped_ptr<URLFetcher> result =
84 net::URLFetcher::Create(0, CreateApiCallUrl(), request_type, this); 85 net::URLFetcher::Create(0, CreateApiCallUrl(), request_type, this);
85 86 data_use_measurement::DataUseUserData::AttachToFetcher(
87 result.get(), data_use_measurement::DataUseUserData::GOOGLE_APIS);
86 result->SetRequestContext(context); 88 result->SetRequestContext(context);
87 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 89 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
88 net::LOAD_DO_NOT_SAVE_COOKIES); 90 net::LOAD_DO_NOT_SAVE_COOKIES);
89 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token)); 91 result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token));
90 // Fetchers are sometimes cancelled because a network change was detected, 92 // Fetchers are sometimes cancelled because a network change was detected,
91 // especially at startup and after sign-in on ChromeOS. Retrying once should 93 // especially at startup and after sign-in on ChromeOS. Retrying once should
92 // be enough in those cases; let the fetcher retry up to 3 times just in case. 94 // be enough in those cases; let the fetcher retry up to 3 times just in case.
93 // http://crbug.com/163710 95 // http://crbug.com/163710
94 result->SetAutomaticallyRetryOnNetworkChanges(3); 96 result->SetAutomaticallyRetryOnNetworkChanges(3);
95 97
96 // Even if the the body is empty, we still set the Content-Type because an 98 // Even if the the body is empty, we still set the Content-Type because an
97 // empty string may be a meaningful value. For example, a Protocol Buffer 99 // empty string may be a meaningful value. For example, a Protocol Buffer
98 // message with only default values will be serialized as an empty string. 100 // message with only default values will be serialized as an empty string.
99 if (request_type != net::URLFetcher::GET) 101 if (request_type != net::URLFetcher::GET)
100 result->SetUploadData(CreateApiCallBodyContentType(), body); 102 result->SetUploadData(CreateApiCallBodyContentType(), body);
101 103
102 return result; 104 return result;
103 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698