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

Side by Side Diff: chrome/service/cloud_print/cloud_print_url_fetcher.cc

Issue 2804613002: Network traffic annotation added to cloud_print_url_fetcher. (Closed)
Patch Set: Annotation updated. Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/service/cloud_print/cloud_print_url_fetcher.h" 5 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.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 "chrome/common/cloud_print/cloud_print_constants.h" 12 #include "chrome/common/cloud_print/cloud_print_constants.h"
13 #include "chrome/common/cloud_print/cloud_print_helpers.h" 13 #include "chrome/common/cloud_print/cloud_print_helpers.h"
14 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" 14 #include "chrome/service/cloud_print/cloud_print_service_helpers.h"
15 #include "chrome/service/cloud_print/cloud_print_token_store.h" 15 #include "chrome/service/cloud_print/cloud_print_token_store.h"
16 #include "chrome/service/net/service_url_request_context_getter.h" 16 #include "chrome/service/net/service_url_request_context_getter.h"
17 #include "chrome/service/service_process.h" 17 #include "chrome/service/service_process.h"
18 #include "components/data_use_measurement/core/data_use_user_data.h" 18 #include "components/data_use_measurement/core/data_use_user_data.h"
19 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
20 #include "net/http/http_status_code.h" 20 #include "net/http/http_status_code.h"
21 #include "net/traffic_annotation/network_traffic_annotation.h"
21 #include "net/url_request/url_fetcher.h" 22 #include "net/url_request/url_fetcher.h"
22 #include "net/url_request/url_request_status.h" 23 #include "net/url_request/url_request_status.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 namespace cloud_print { 26 namespace cloud_print {
26 27
27 namespace { 28 namespace {
28 29
29 void ReportRequestTime(CloudPrintURLFetcher::RequestType type, 30 void ReportRequestTime(CloudPrintURLFetcher::RequestType type,
30 base::TimeDelta time) { 31 base::TimeDelta time) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 int max_retries, 253 int max_retries,
253 const std::string& post_data_mime_type, 254 const std::string& post_data_mime_type,
254 const std::string& post_data, 255 const std::string& post_data,
255 const std::string& additional_headers) { 256 const std::string& additional_headers) {
256 DCHECK(delegate); 257 DCHECK(delegate);
257 type_ = type; 258 type_ = type;
258 UMA_HISTOGRAM_ENUMERATION("CloudPrint.UrlFetcherRequestType", type, 259 UMA_HISTOGRAM_ENUMERATION("CloudPrint.UrlFetcherRequestType", type,
259 REQUEST_MAX); 260 REQUEST_MAX);
260 // Persist the additional headers in case we need to retry the request. 261 // Persist the additional headers in case we need to retry the request.
261 additional_headers_ = additional_headers; 262 additional_headers_ = additional_headers;
262 request_ = net::URLFetcher::Create(0, url, request_type, this); 263 net::NetworkTrafficAnnotationTag traffic_annotation =
264 net::DefineNetworkTrafficAnnotation("cloud_print_url_fetcher", R"(
265 semantics {
266 sender: "Cloud Print"
267 description:
268 "Google Cloud Print allows users to print to printers from Chrome "
269 "and Android without needing to install print drivers."
270 trigger:
271 "Printing and running background Cloud Print services."
Ramin Halavati 2017/04/19 05:59:07 Can "background" be elaborated?
Lei Zhang 2017/04/19 19:27:25 This is part of the Cloud Print Connector that can
272 data: "..."
Ramin Halavati 2017/04/19 05:59:07 What is sent?
Lei Zhang 2017/04/19 19:27:26 StartPostRequest() and StartGetRequest() both use
273 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER/LOCAL
Ramin Halavati 2017/04/19 05:59:07 I assume it should be OTHER?
Lei Zhang 2017/04/19 19:27:25 That would be consistent with "cloud_print_privet_
274 }
275 policy {
276 cookies_allowed: false
277 setting:
278 "This feature cannot be disabled by settings."
279 chrome_policy {
280 CloudPrintProxyEnabled {
281 policy_options {mode: MANDATORY}
282 CloudPrintProxyEnabled: false
283 }
284 }
285 chrome_policy {
286 CloudPrintSubmitEnabled {
287 policy_options {mode: MANDATORY}
288 CloudPrintSubmitEnabled: false
289 }
290 }
291 })");
Ramin Halavati 2017/04/19 05:59:07 Are both policies required to disable this request
Lei Zhang 2017/04/19 19:27:25 CloudPrintSubmitEnabled doesn't belong here. It's
292 request_ =
293 net::URLFetcher::Create(0, url, request_type, this, traffic_annotation);
263 data_use_measurement::DataUseUserData::AttachToFetcher( 294 data_use_measurement::DataUseUserData::AttachToFetcher(
264 request_.get(), data_use_measurement::DataUseUserData::CLOUD_PRINT); 295 request_.get(), data_use_measurement::DataUseUserData::CLOUD_PRINT);
265 request_->SetRequestContext(GetRequestContextGetter()); 296 request_->SetRequestContext(GetRequestContextGetter());
266 // Since we implement our own retry logic, disable the retry in URLFetcher. 297 // Since we implement our own retry logic, disable the retry in URLFetcher.
267 request_->SetAutomaticallyRetryOn5xx(false); 298 request_->SetAutomaticallyRetryOn5xx(false);
268 request_->SetMaxRetriesOn5xx(max_retries); 299 request_->SetMaxRetriesOn5xx(max_retries);
269 delegate_ = delegate; 300 delegate_ = delegate;
270 SetupRequestHeaders(); 301 SetupRequestHeaders();
271 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 302 request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
272 net::LOAD_DO_NOT_SAVE_COOKIES); 303 net::LOAD_DO_NOT_SAVE_COOKIES);
(...skipping 23 matching lines...) Expand all
296 ServiceURLRequestContextGetter* getter = 327 ServiceURLRequestContextGetter* getter =
297 g_service_process->GetServiceURLRequestContextGetter(); 328 g_service_process->GetServiceURLRequestContextGetter();
298 // Now set up the user agent for cloudprint. 329 // Now set up the user agent for cloudprint.
299 std::string user_agent = getter->user_agent(); 330 std::string user_agent = getter->user_agent();
300 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); 331 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent);
301 getter->set_user_agent(user_agent); 332 getter->set_user_agent(user_agent);
302 return getter; 333 return getter;
303 } 334 }
304 335
305 } // namespace cloud_print 336 } // namespace cloud_print
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698