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

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

Issue 2774503002: Track network stack error codes from UMA and UKM (Closed)
Patch Set: Rebase on 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
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"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 } // namespace 96 } // namespace
97 97
98 namespace metrics { 98 namespace metrics {
99 99
100 NetMetricsLogUploader::NetMetricsLogUploader( 100 NetMetricsLogUploader::NetMetricsLogUploader(
101 net::URLRequestContextGetter* request_context_getter, 101 net::URLRequestContextGetter* request_context_getter,
102 base::StringPiece server_url, 102 base::StringPiece server_url,
103 base::StringPiece mime_type, 103 base::StringPiece mime_type,
104 MetricsLogUploader::MetricServiceType service_type, 104 MetricsLogUploader::MetricServiceType service_type,
105 const base::Callback<void(int)>& on_upload_complete) 105 const MetricsLogUploader::UploadCallback& on_upload_complete)
106 : request_context_getter_(request_context_getter), 106 : request_context_getter_(request_context_getter),
107 server_url_(server_url), 107 server_url_(server_url),
108 mime_type_(mime_type.data(), mime_type.size()), 108 mime_type_(mime_type.data(), mime_type.size()),
109 service_type_(service_type), 109 service_type_(service_type),
110 on_upload_complete_(on_upload_complete) {} 110 on_upload_complete_(on_upload_complete) {}
111 111
112 NetMetricsLogUploader::~NetMetricsLogUploader() { 112 NetMetricsLogUploader::~NetMetricsLogUploader() {
113 } 113 }
114 114
115 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data, 115 void NetMetricsLogUploader::UploadLog(const std::string& compressed_log_data,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 void NetMetricsLogUploader::OnURLFetchComplete(const net::URLFetcher* source) { 149 void NetMetricsLogUploader::OnURLFetchComplete(const net::URLFetcher* source) {
150 // We're not allowed to re-use the existing |URLFetcher|s, so free them here. 150 // We're not allowed to re-use the existing |URLFetcher|s, so free them here.
151 // Note however that |source| is aliased to the fetcher, so we should be 151 // Note however that |source| is aliased to the fetcher, so we should be
152 // careful not to delete it too early. 152 // careful not to delete it too early.
153 DCHECK_EQ(current_fetch_.get(), source); 153 DCHECK_EQ(current_fetch_.get(), source);
154 154
155 int response_code = source->GetResponseCode(); 155 int response_code = source->GetResponseCode();
156 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) 156 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID)
157 response_code = -1; 157 response_code = -1;
158 int error_code = 0;
159 const net::URLRequestStatus& request_status = source->GetStatus();
160 if (request_status.status() != net::URLRequestStatus::SUCCESS) {
161 error_code = request_status.error();
162 }
158 current_fetch_.reset(); 163 current_fetch_.reset();
159 on_upload_complete_.Run(response_code); 164 on_upload_complete_.Run(response_code, error_code);
160 } 165 }
161 166
162 } // namespace metrics 167 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/net/net_metrics_log_uploader.h ('k') | components/metrics/net/net_metrics_log_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698