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

Side by Side Diff: components/metrics/net/net_metrics_log_uploader.cc

Issue 2703363002: Network traffic annotation added to NetMetricsLogUploader. (Closed)
Patch Set: Annotation updated. Created 3 years, 9 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 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/metrics/net/net_metrics_log_uploader.h" 5 #include "components/metrics/net/net_metrics_log_uploader.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "components/data_use_measurement/core/data_use_user_data.h" 8 #include "components/data_use_measurement/core/data_use_user_data.h"
9 #include "components/metrics/metrics_log_uploader.h" 9 #include "components/metrics/metrics_log_uploader.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
11 #include "net/traffic_annotation/network_traffic_annotation.h"
11 #include "net/url_request/url_fetcher.h" 12 #include "net/url_request/url_fetcher.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 namespace metrics { 15 namespace metrics {
15 16
16 NetMetricsLogUploader::NetMetricsLogUploader( 17 NetMetricsLogUploader::NetMetricsLogUploader(
17 net::URLRequestContextGetter* request_context_getter, 18 net::URLRequestContextGetter* request_context_getter,
18 const std::string& server_url, 19 const std::string& server_url,
19 const std::string& mime_type, 20 const std::string& mime_type,
20 MetricsLogUploader::MetricServiceType service_type, 21 MetricsLogUploader::MetricServiceType service_type,
21 const base::Callback<void(int)>& on_upload_complete) 22 const base::Callback<void(int)>& on_upload_complete)
22 : MetricsLogUploader(server_url, 23 : MetricsLogUploader(server_url,
23 mime_type, 24 mime_type,
24 service_type, 25 service_type,
25 on_upload_complete), 26 on_upload_complete),
26 request_context_getter_(request_context_getter) {} 27 request_context_getter_(request_context_getter) {}
27 28
28 NetMetricsLogUploader::~NetMetricsLogUploader() { 29 NetMetricsLogUploader::~NetMetricsLogUploader() {
29 } 30 }
30 31
31 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data, 32 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
32 const std::string& log_hash) { 33 const std::string& log_hash) {
33 current_fetch_ =
34 net::URLFetcher::Create(GURL(server_url_), net::URLFetcher::POST, this);
35
36 auto service = data_use_measurement::DataUseUserData::UMA; 34 auto service = data_use_measurement::DataUseUserData::UMA;
37 35 net::NetworkTrafficAnnotationTag traffic_annotation =
36 NO_TRAFFIC_ANNOTATION_YET;
battre 2017/03/08 14:19:31 I think that this is problematic because it will k
Ramin Halavati 2017/03/08 15:04:10 You are right, moved it to anonymous function.
38 switch (service_type_) { 37 switch (service_type_) {
39 case MetricsLogUploader::UMA: 38 case MetricsLogUploader::UMA:
40 service = data_use_measurement::DataUseUserData::UMA; 39 service = data_use_measurement::DataUseUserData::UMA;
40 traffic_annotation =
41 net::DefineNetworkTrafficAnnotation("metrics_report_uma", R"(
42 semantics {
43 sender: "Metrics UMA Log Uploader"
44 description:
45 "Report of usage statistics and crash-related data about "
46 "Chromium. Usage statistics contain information such as "
47 "preferences, button clicks, and memory usage and do not "
48 "include web page URLs or personal information. See more at "
49 "https://www.google.com/chrome/browser/privacy/ under 'Usage "
50 "statistics and crash reports'."
battre 2017/03/08 14:19:31 Add at the end: Usage statistics are tied to a pse
Ramin Halavati 2017/03/08 15:04:10 Done.
51 trigger:
52 "Reports are automatically generated on startup and at "
53 "intervals while Chromium is running."
54 data:
55 "A protocol buffer with usage statistics and crash related "
56 "data."
57 destination: GOOGLE_OWNED_SERVICE
58 }
59 policy {
60 cookies_allowed: false
61 setting:
62 "Users can enable or disable this feature by disabling "
63 "'Automatically send usage statistics and crash reports to "
64 "Google' in Chromium's settings under Advanced Settings, "
65 "Privacy. The feature is enabled by default."
66 policy {
67 MetricsReportingEnabled {
68 policy_options {mode: MANDATORY}
69 value: false
70 }
71 }
72 })");
41 break; 73 break;
42 case MetricsLogUploader::UKM: 74 case MetricsLogUploader::UKM:
43 service = data_use_measurement::DataUseUserData::UKM; 75 service = data_use_measurement::DataUseUserData::UKM;
76 traffic_annotation =
77 net::DefineNetworkTrafficAnnotation("metrics_report_ukm", R"(
78 semantics {
79 sender: "Metrics UKM Log Uploader"
80 description:
81 "Report of usage statistics that are keyed by URLs to "
82 "Chromium, sent only if the profile has History Sync. This "
83 "includes information about the web pages you visit and your "
84 "usage of them, such as page load speed. This will also "
85 "include URLs and statistics related to downloaded files. If "
86 "Extension Sync is enabled, these statistics will also include "
87 "information about the extensions that have been installed "
88 "from Chrome Web Store. Google only stores usage statistics "
89 "associated with published extensions, and URLs that are known "
90 "by Google’s search index."
battre 2017/03/08 14:19:31 Add at the end: Add: Usage statistics are tied to
Ramin Halavati 2017/03/08 15:04:10 Done.
91 trigger:
92 "Reports are automatically generated on startup and at "
93 "intervals while Chromium is running with Sync enabled."
94 data:
95 "A protocol buffer with usage statistics and associated URLs."
96 destination: GOOGLE_OWNED_SERVICE
97 }
98 policy {
99 cookies_allowed: false
100 setting:
101 "Users can enable or disable this feature by disabling "
102 "'Automatically send usage statistics and crash reports to "
103 "Google' in Chromium's settings under Advanced Settings, "
104 "Privacy. This is only enabled if all active profiles have "
105 "History/Extension Sync enabled without a Sync passphrase."
106 policy {
107 MetricsReportingEnabled {
108 policy_options {mode: MANDATORY}
109 value: false
110 }
111 }
112 })");
44 break; 113 break;
45 } 114 }
115 current_fetch_ = net::URLFetcher::Create(
116 GURL(server_url_), net::URLFetcher::POST, this, traffic_annotation);
117
46 data_use_measurement::DataUseUserData::AttachToFetcher(current_fetch_.get(), 118 data_use_measurement::DataUseUserData::AttachToFetcher(current_fetch_.get(),
47 service); 119 service);
120
48 current_fetch_->SetRequestContext(request_context_getter_); 121 current_fetch_->SetRequestContext(request_context_getter_);
49 current_fetch_->SetUploadData(mime_type_, compressed_log_data); 122 current_fetch_->SetUploadData(mime_type_, compressed_log_data);
50 123
51 // Tell the server that we're uploading gzipped protobufs. 124 // Tell the server that we're uploading gzipped protobufs.
52 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip"); 125 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip");
53 126
54 DCHECK(!log_hash.empty()); 127 DCHECK(!log_hash.empty());
55 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + log_hash); 128 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + log_hash);
56 129
57 // Drop cookies and auth data. 130 // Drop cookies and auth data.
(...skipping 10 matching lines...) Expand all
68 DCHECK_EQ(current_fetch_.get(), source); 141 DCHECK_EQ(current_fetch_.get(), source);
69 142
70 int response_code = source->GetResponseCode(); 143 int response_code = source->GetResponseCode();
71 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) 144 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID)
72 response_code = -1; 145 response_code = -1;
73 current_fetch_.reset(); 146 current_fetch_.reset();
74 on_upload_complete_.Run(response_code); 147 on_upload_complete_.Run(response_code);
75 } 148 }
76 149
77 } // namespace metrics 150 } // namespace metrics
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