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

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

Issue 1033493002: Histogram for UMA log upload connection type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment fix Created 5 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 | net/base/network_change_notifier.h » ('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.h" 7 #include "base/metrics/histogram.h"
8 #include "net/base/load_flags.h" 8 #include "net/base/load_flags.h"
9 #include "net/base/network_change_notifier.h"
9 #include "net/url_request/url_fetcher.h" 10 #include "net/url_request/url_fetcher.h"
10 #include "url/gurl.h" 11 #include "url/gurl.h"
11 12
13 namespace {
14
15 // Records the network connection type if upload was successful.
16 void RecordConnectionType(int response_code) {
17 if (response_code == 200) {
18 UMA_HISTOGRAM_ENUMERATION("UMA.LogUpload.ConnetionType",
19 net::NetworkChangeNotifier::GetConnectionType(),
20 net::NetworkChangeNotifier::CONNECTION_LAST);
21 }
22 }
23
24 } // namespace
25
12 namespace metrics { 26 namespace metrics {
13 27
14 NetMetricsLogUploader::NetMetricsLogUploader( 28 NetMetricsLogUploader::NetMetricsLogUploader(
15 net::URLRequestContextGetter* request_context_getter, 29 net::URLRequestContextGetter* request_context_getter,
16 const std::string& server_url, 30 const std::string& server_url,
17 const std::string& mime_type, 31 const std::string& mime_type,
18 const base::Callback<void(int)>& on_upload_complete) 32 const base::Callback<void(int)>& on_upload_complete)
19 : MetricsLogUploader(server_url, mime_type, on_upload_complete), 33 : MetricsLogUploader(server_url, mime_type, on_upload_complete),
20 request_context_getter_(request_context_getter) { 34 request_context_getter_(request_context_getter) {
21 } 35 }
(...skipping 25 matching lines...) Expand all
47 void NetMetricsLogUploader::OnURLFetchComplete(const net::URLFetcher* source) { 61 void NetMetricsLogUploader::OnURLFetchComplete(const net::URLFetcher* source) {
48 // We're not allowed to re-use the existing |URLFetcher|s, so free them here. 62 // We're not allowed to re-use the existing |URLFetcher|s, so free them here.
49 // Note however that |source| is aliased to the fetcher, so we should be 63 // Note however that |source| is aliased to the fetcher, so we should be
50 // careful not to delete it too early. 64 // careful not to delete it too early.
51 DCHECK_EQ(current_fetch_.get(), source); 65 DCHECK_EQ(current_fetch_.get(), source);
52 66
53 int response_code = source->GetResponseCode(); 67 int response_code = source->GetResponseCode();
54 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) 68 if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID)
55 response_code = -1; 69 response_code = -1;
56 current_fetch_.reset(); 70 current_fetch_.reset();
71 RecordConnectionType(response_code);
57 on_upload_complete_.Run(response_code); 72 on_upload_complete_.Run(response_code);
58 } 73 }
59 74
60 } // namespace metrics 75 } // namespace metrics
OLDNEW
« no previous file with comments | « no previous file | net/base/network_change_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698