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

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

Issue 2703363002: Network traffic annotation added to NetMetricsLogUploader. (Closed)
Patch Set: Created 3 years, 10 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 "net/base/load_flags.h" 9 #include "net/base/load_flags.h"
10 #include "net/traffic_annotation/network_traffic_annotation.h"
10 #include "net/url_request/url_fetcher.h" 11 #include "net/url_request/url_fetcher.h"
11 #include "url/gurl.h" 12 #include "url/gurl.h"
12 13
13 namespace metrics { 14 namespace metrics {
14 15
15 NetMetricsLogUploader::NetMetricsLogUploader( 16 NetMetricsLogUploader::NetMetricsLogUploader(
16 net::URLRequestContextGetter* request_context_getter, 17 net::URLRequestContextGetter* request_context_getter,
17 const std::string& server_url, 18 const std::string& server_url,
18 const std::string& mime_type, 19 const std::string& mime_type,
19 const base::Callback<void(int)>& on_upload_complete) 20 const base::Callback<void(int)>& on_upload_complete)
20 : MetricsLogUploader(server_url, mime_type, on_upload_complete), 21 : MetricsLogUploader(server_url, mime_type, on_upload_complete),
21 request_context_getter_(request_context_getter) { 22 request_context_getter_(request_context_getter) {
22 } 23 }
23 24
24 NetMetricsLogUploader::~NetMetricsLogUploader() { 25 NetMetricsLogUploader::~NetMetricsLogUploader() {
25 } 26 }
26 27
27 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data, 28 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
28 const std::string& log_hash) { 29 const std::string& log_hash) {
29 current_fetch_ = 30 net::NetworkTrafficAnnotationTag traffic_annotation =
Steven Holte 2017/02/21 22:45:03 net::DefineNetworkTrafficAnnotation("metrics_repor
Ramin Halavati 2017/02/22 11:48:08 Done.
30 net::URLFetcher::Create(GURL(server_url_), net::URLFetcher::POST, this); 31 net::DefineNetworkTrafficAnnotation("...", R"(
32 semantics {
33 sender: "..."
34 description: "..."
35 trigger: "..."
36 data: "..."
37 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
38 }
39 policy {
40 cookies_allowed: false/true
41 cookies_store: "..."
42 setting: "..."
43 policy {
44 [POLICY_NAME] {
45 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
46 value: ...
47 }
48 }
49 policy_exception_justification: "..."
50 })");
51 current_fetch_ = net::URLFetcher::Create(
52 GURL(server_url_), net::URLFetcher::POST, this, traffic_annotation);
31 data_use_measurement::DataUseUserData::AttachToFetcher( 53 data_use_measurement::DataUseUserData::AttachToFetcher(
32 current_fetch_.get(), data_use_measurement::DataUseUserData::UMA); 54 current_fetch_.get(), data_use_measurement::DataUseUserData::UMA);
33 current_fetch_->SetRequestContext(request_context_getter_); 55 current_fetch_->SetRequestContext(request_context_getter_);
34 current_fetch_->SetUploadData(mime_type_, compressed_log_data); 56 current_fetch_->SetUploadData(mime_type_, compressed_log_data);
35 57
36 // Tell the server that we're uploading gzipped protobufs. 58 // Tell the server that we're uploading gzipped protobufs.
37 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip"); 59 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip");
38 60
39 DCHECK(!log_hash.empty()); 61 DCHECK(!log_hash.empty());
40 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + log_hash); 62 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + log_hash);
(...skipping 12 matching lines...) Expand all
53 DCHECK_EQ(current_fetch_.get(), source); 75 DCHECK_EQ(current_fetch_.get(), source);
54 76
55 int response_code = source->GetResponseCode(); 77 int response_code = source->GetResponseCode();
56 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) 78 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID)
57 response_code = -1; 79 response_code = -1;
58 current_fetch_.reset(); 80 current_fetch_.reset();
59 on_upload_complete_.Run(response_code); 81 on_upload_complete_.Run(response_code);
60 } 82 }
61 83
62 } // namespace metrics 84 } // 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