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

Side by Side Diff: google_apis/gaia/oauth2_access_token_fetcher_impl.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
« no previous file with comments | « google_apis/gaia/gaia_oauth_client.cc ('k') | google_apis/gaia/oauth2_api_call_flow.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "google_apis/gaia/oauth2_access_token_fetcher_impl.h" 5 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "google_apis/gaia/gaia_auth_util.h"
18 #include "google_apis/gaia/gaia_urls.h" 19 #include "google_apis/gaia/gaia_urls.h"
19 #include "google_apis/gaia/google_service_auth_error.h" 20 #include "google_apis/gaia/google_service_auth_error.h"
20 #include "net/base/escape.h" 21 #include "net/base/escape.h"
21 #include "net/base/load_flags.h" 22 #include "net/base/load_flags.h"
22 #include "net/http/http_status_code.h" 23 #include "net/http/http_status_code.h"
23 #include "net/url_request/url_fetcher.h" 24 #include "net/url_request/url_fetcher.h"
24 #include "net/url_request/url_request_context_getter.h" 25 #include "net/url_request/url_request_context_getter.h"
25 #include "net/url_request/url_request_status.h" 26 #include "net/url_request/url_request_status.h"
26 27
27 using net::URLFetcher; 28 using net::URLFetcher;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 92
92 static std::unique_ptr<URLFetcher> CreateFetcher( 93 static std::unique_ptr<URLFetcher> CreateFetcher(
93 URLRequestContextGetter* getter, 94 URLRequestContextGetter* getter,
94 const GURL& url, 95 const GURL& url,
95 const std::string& body, 96 const std::string& body,
96 URLFetcherDelegate* delegate) { 97 URLFetcherDelegate* delegate) {
97 bool empty_body = body.empty(); 98 bool empty_body = body.empty();
98 std::unique_ptr<URLFetcher> result = net::URLFetcher::Create( 99 std::unique_ptr<URLFetcher> result = net::URLFetcher::Create(
99 0, url, empty_body ? URLFetcher::GET : URLFetcher::POST, delegate); 100 0, url, empty_body ? URLFetcher::GET : URLFetcher::POST, delegate);
100 101
102 gaia::MarkURLFetcherAsGaia(result.get());
101 result->SetRequestContext(getter); 103 result->SetRequestContext(getter);
102 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 104 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
103 net::LOAD_DO_NOT_SAVE_COOKIES); 105 net::LOAD_DO_NOT_SAVE_COOKIES);
104 // Fetchers are sometimes cancelled because a network change was detected, 106 // Fetchers are sometimes cancelled because a network change was detected,
105 // especially at startup and after sign-in on ChromeOS. Retrying once should 107 // especially at startup and after sign-in on ChromeOS. Retrying once should
106 // be enough in those cases; let the fetcher retry up to 3 times just in case. 108 // be enough in those cases; let the fetcher retry up to 3 times just in case.
107 // http://crbug.com/163710 109 // http://crbug.com/163710
108 result->SetAutomaticallyRetryOnNetworkChanges(3); 110 result->SetAutomaticallyRetryOnNetworkChanges(3);
109 111
110 if (!empty_body) 112 if (!empty_body)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 bool OAuth2AccessTokenFetcherImpl::ParseGetAccessTokenFailureResponse( 314 bool OAuth2AccessTokenFetcherImpl::ParseGetAccessTokenFailureResponse(
313 const net::URLFetcher* source, 315 const net::URLFetcher* source,
314 std::string* error) { 316 std::string* error) {
315 CHECK(error); 317 CHECK(error);
316 std::unique_ptr<base::DictionaryValue> value = 318 std::unique_ptr<base::DictionaryValue> value =
317 ParseGetAccessTokenResponse(source); 319 ParseGetAccessTokenResponse(source);
318 if (value.get() == NULL) 320 if (value.get() == NULL)
319 return false; 321 return false;
320 return value->GetString(kErrorKey, error); 322 return value->GetString(kErrorKey, error);
321 } 323 }
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_oauth_client.cc ('k') | google_apis/gaia/oauth2_api_call_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698