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

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

Issue 2703363002: Network traffic annotation added to NetMetricsLogUploader. (Closed)
Patch Set: nits 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
15 namespace {
16
17 net::NetworkTrafficAnnotationTag GetNetworkTrafficAnnotation(
18 const metrics::MetricsLogUploader::MetricServiceType& service_type) {
19 if (service_type == metrics::MetricsLogUploader::UMA) {
Alexei Svitkine (slow) 2017/03/08 16:02:19 Please use a switch, so that if a new type is adde
Ramin Halavati 2017/03/08 17:48:07 If we add a switch, we again need NO_TRAFFIC_ANNOT
20 return net::DefineNetworkTrafficAnnotation("metrics_report_uma", R"(
21 semantics {
22 sender: "Metrics UMA Log Uploader"
23 description:
24 "Report of usage statistics and crash-related data about Chromium. "
25 "Usage statistics contain information such as preferences, button "
26 "clicks, and memory usage and do not include web page URLs or "
27 "personal information. See more at "
28 "https://www.google.com/chrome/browser/privacy/ under 'Usage "
29 "statistics and crash reports'. Usage statistics are tied to a "
30 "pseudonymous machine identifier and not to your email address."
31 trigger:
32 "Reports are automatically generated on startup and at intervals "
33 "while Chromium is running."
34 data:
35 "A protocol buffer with usage statistics and crash related data."
36 destination: GOOGLE_OWNED_SERVICE
37 }
38 policy {
39 cookies_allowed: false
40 setting:
41 "Users can enable or disable this feature by disabling "
42 "'Automatically send usage statistics and crash reports to Google' "
43 "in Chromium's settings under Advanced Settings, Privacy. The "
44 "feature is enabled by default."
45 chrome_policy {
46 MetricsReportingEnabled {
47 policy_options {mode: MANDATORY}
48 MetricsReportingEnabled: false
49 }
50 }
51 })");
52 } else {
53 return net::DefineNetworkTrafficAnnotation("metrics_report_ukm", R"(
54 semantics {
55 sender: "Metrics UKM Log Uploader"
56 description:
57 "Report of usage statistics that are keyed by URLs to Chromium, "
58 "sent only if the profile has History Sync. This includes "
59 "information about the web pages you visit and your usage of them, "
60 "such as page load speed. This will also include URLs and "
61 "statistics related to downloaded files. If Extension Sync is "
62 "enabled, these statistics will also include information about "
63 "the extensions that have been installed from Chrome Web Store. "
64 "Google only stores usage statistics associated with published "
65 "extensions, and URLs that are known by Google’s search index. "
66 "Usage statistics are tied to a pseudonymous machine identifier "
67 "and not to your email address."
68 trigger:
69 "Reports are automatically generated on startup and at intervals "
70 "while Chromium is running with Sync enabled."
71 data:
72 "A protocol buffer with usage statistics and associated URLs."
73 destination: GOOGLE_OWNED_SERVICE
74 }
75 policy {
76 cookies_allowed: false
77 setting:
78 "Users can enable or disable this feature by disabling "
79 "'Automatically send usage statistics and crash reports to Google' "
80 "in Chromium's settings under Advanced Settings, Privacy. This is "
81 "only enabled if all active profiles have History/Extension Sync "
82 "enabled without a Sync passphrase."
83 chrome_policy {
84 MetricsReportingEnabled {
85 policy_options {mode: MANDATORY}
86 MetricsReportingEnabled: false
87 }
88 }
89 })");
90 }
91 }
92
93 } // namespace
94
14 namespace metrics { 95 namespace metrics {
15 96
16 NetMetricsLogUploader::NetMetricsLogUploader( 97 NetMetricsLogUploader::NetMetricsLogUploader(
17 net::URLRequestContextGetter* request_context_getter, 98 net::URLRequestContextGetter* request_context_getter,
18 base::StringPiece server_url, 99 base::StringPiece server_url,
19 base::StringPiece mime_type, 100 base::StringPiece mime_type,
20 MetricsLogUploader::MetricServiceType service_type, 101 MetricsLogUploader::MetricServiceType service_type,
21 const base::Callback<void(int)>& on_upload_complete) 102 const base::Callback<void(int)>& on_upload_complete)
22 : request_context_getter_(request_context_getter), 103 : request_context_getter_(request_context_getter),
23 server_url_(server_url), 104 server_url_(server_url),
24 mime_type_(mime_type.data(), mime_type.size()), 105 mime_type_(mime_type.data(), mime_type.size()),
25 service_type_(service_type), 106 service_type_(service_type),
26 on_upload_complete_(on_upload_complete) {} 107 on_upload_complete_(on_upload_complete) {}
27 108
28 NetMetricsLogUploader::~NetMetricsLogUploader() { 109 NetMetricsLogUploader::~NetMetricsLogUploader() {
29 } 110 }
30 111
31 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data, 112 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
32 const std::string& log_hash) { 113 const std::string& log_hash) {
33 current_fetch_ = 114 current_fetch_ =
34 net::URLFetcher::Create(GURL(server_url_), net::URLFetcher::POST, this); 115 net::URLFetcher::Create(GURL(server_url_), net::URLFetcher::POST, this,
116 GetNetworkTrafficAnnotation(service_type_));
35 117
36 auto service = data_use_measurement::DataUseUserData::UMA; 118 auto service = data_use_measurement::DataUseUserData::UMA;
37 119
38 switch (service_type_) { 120 switch (service_type_) {
39 case MetricsLogUploader::UMA: 121 case MetricsLogUploader::UMA:
40 service = data_use_measurement::DataUseUserData::UMA; 122 service = data_use_measurement::DataUseUserData::UMA;
41 break; 123 break;
42 case MetricsLogUploader::UKM: 124 case MetricsLogUploader::UKM:
43 service = data_use_measurement::DataUseUserData::UKM; 125 service = data_use_measurement::DataUseUserData::UKM;
44 break; 126 break;
(...skipping 23 matching lines...) Expand all
68 DCHECK_EQ(current_fetch_.get(), source); 150 DCHECK_EQ(current_fetch_.get(), source);
69 151
70 int response_code = source->GetResponseCode(); 152 int response_code = source->GetResponseCode();
71 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) 153 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID)
72 response_code = -1; 154 response_code = -1;
73 current_fetch_.reset(); 155 current_fetch_.reset();
74 on_upload_complete_.Run(response_code); 156 on_upload_complete_.Run(response_code);
75 } 157 }
76 158
77 } // namespace metrics 159 } // 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