OLD | NEW |
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 "components/signin/core/browser/refresh_token_annotation_request.h" | 5 #include "components/signin/core/browser/refresh_token_annotation_request.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
15 #include "components/signin/core/browser/signin_client.h" | 15 #include "components/signin/core/browser/signin_client.h" |
16 #include "components/signin/core/common/signin_pref_names.h" | 16 #include "components/signin/core/common/signin_pref_names.h" |
17 #include "google_apis/gaia/gaia_constants.h" | 17 #include "google_apis/gaia/gaia_constants.h" |
18 #include "google_apis/gaia/gaia_urls.h" | 18 #include "google_apis/gaia/gaia_urls.h" |
19 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
| 20 #include "net/traffic_annotation/network_traffic_annotation.h" |
20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 void RecordRequestStatusHistogram(bool success) { | 25 void RecordRequestStatusHistogram(bool success) { |
25 UMA_HISTOGRAM_BOOLEAN("Signin.RefreshTokenAnnotationRequest", success); | 26 UMA_HISTOGRAM_BOOLEAN("Signin.RefreshTokenAnnotationRequest", success); |
26 } | 27 } |
27 } | 28 } |
28 | 29 |
29 RefreshTokenAnnotationRequest::RefreshTokenAnnotationRequest( | 30 RefreshTokenAnnotationRequest::RefreshTokenAnnotationRequest( |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 165 } |
165 | 166 |
166 void RefreshTokenAnnotationRequest::ProcessApiCallFailure( | 167 void RefreshTokenAnnotationRequest::ProcessApiCallFailure( |
167 const net::URLFetcher* source) { | 168 const net::URLFetcher* source) { |
168 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 169 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
169 DVLOG(2) << "Request failed"; | 170 DVLOG(2) << "Request failed"; |
170 RecordRequestStatusHistogram(false); | 171 RecordRequestStatusHistogram(false); |
171 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_); | 172 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, request_callback_); |
172 request_callback_.Reset(); | 173 request_callback_.Reset(); |
173 } | 174 } |
| 175 |
| 176 net::PartialNetworkTrafficAnnotationTag |
| 177 RefreshTokenAnnotationRequest::GetNetworkTrafficAnnotationTag() { |
| 178 return net::DefinePartialNetworkTrafficAnnotation( |
| 179 "refresh_token_annotation_request", "oauth2_api_call_flow", R"( |
| 180 semantics { |
| 181 sender: "Account Fetcher Service" |
| 182 description: |
| 183 "Sends request to /IssueToken endpoint with device_id to backfill " |
| 184 "device info for refresh tokens issued pre-M38." |
| 185 trigger: |
| 186 "When refreshing account information in AccountFetcherService. On " |
| 187 "chrome startup and at most once per day." |
| 188 data: |
| 189 "OAuth 2.0 access token, Chrome's client id and version number, and " |
| 190 "a single signin scoped, randomly generated device id for Chrome " |
| 191 "profile." |
| 192 destination: GOOGLE_OWNED_SERVICE |
| 193 } |
| 194 policy { |
| 195 setting: |
| 196 "This feature cannot be disabled by settings, however the request is " |
| 197 "made only for signed-in users." |
| 198 chrome_policy { |
| 199 SigninAllowed { |
| 200 policy_options {mode: MANDATORY} |
| 201 SigninAllowed: false |
| 202 } |
| 203 } |
| 204 })"); |
| 205 } |
OLD | NEW |