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

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

Issue 1339943003: Revert "Report data usage UMA for Chrome services" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « components/metrics/net/DEPS ('k') | components/omnibox.gypi » ('j') | 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"
9 #include "net/base/load_flags.h" 8 #include "net/base/load_flags.h"
10 #include "net/base/network_change_notifier.h" 9 #include "net/base/network_change_notifier.h"
11 #include "net/url_request/url_fetcher.h" 10 #include "net/url_request/url_fetcher.h"
12 #include "url/gurl.h" 11 #include "url/gurl.h"
13 12
14 namespace { 13 namespace {
15 14
16 // Records the network connection type if upload was successful. 15 // Records the network connection type if upload was successful.
17 void RecordConnectionType(int response_code) { 16 void RecordConnectionType(int response_code) {
18 if (response_code == 200) { 17 if (response_code == 200) {
(...skipping 16 matching lines...) Expand all
35 request_context_getter_(request_context_getter) { 34 request_context_getter_(request_context_getter) {
36 } 35 }
37 36
38 NetMetricsLogUploader::~NetMetricsLogUploader() { 37 NetMetricsLogUploader::~NetMetricsLogUploader() {
39 } 38 }
40 39
41 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data, 40 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
42 const std::string& log_hash) { 41 const std::string& log_hash) {
43 current_fetch_ = 42 current_fetch_ =
44 net::URLFetcher::Create(GURL(server_url_), net::URLFetcher::POST, this); 43 net::URLFetcher::Create(GURL(server_url_), net::URLFetcher::POST, this);
45 data_use_measurement::DataUseUserData::AttachToFetcher(
46 current_fetch_.get(), data_use_measurement::DataUseUserData::UMA);
47 current_fetch_->SetRequestContext(request_context_getter_); 44 current_fetch_->SetRequestContext(request_context_getter_);
48 current_fetch_->SetUploadData(mime_type_, compressed_log_data); 45 current_fetch_->SetUploadData(mime_type_, compressed_log_data);
49 46
50 // Tell the server that we're uploading gzipped protobufs. 47 // Tell the server that we're uploading gzipped protobufs.
51 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip"); 48 current_fetch_->SetExtraRequestHeaders("content-encoding: gzip");
52 49
53 DCHECK(!log_hash.empty()); 50 DCHECK(!log_hash.empty());
54 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + log_hash); 51 current_fetch_->AddExtraRequestHeader("X-Chrome-UMA-Log-SHA1: " + log_hash);
55 52
56 // We already drop cookies server-side, but we might as well strip them out 53 // We already drop cookies server-side, but we might as well strip them out
(...skipping 11 matching lines...) Expand all
68 65
69 int response_code = source->GetResponseCode(); 66 int response_code = source->GetResponseCode();
70 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) 67 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID)
71 response_code = -1; 68 response_code = -1;
72 current_fetch_.reset(); 69 current_fetch_.reset();
73 RecordConnectionType(response_code); 70 RecordConnectionType(response_code);
74 on_upload_complete_.Run(response_code); 71 on_upload_complete_.Run(response_code);
75 } 72 }
76 73
77 } // namespace metrics 74 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/net/DEPS ('k') | components/omnibox.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698