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

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

Issue 1796983002: Log aggregated abort metrics when histograms are uploaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: isherman@ review Created 4 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
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/network_metrics_provider.h" 5 #include "components/metrics/net/network_metrics_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/metrics/histogram_macros.h"
14 #include "base/metrics/sparse_histogram.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
16 #include "base/task_runner_util.h" 18 #include "base/task_runner_util.h"
17 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "net/base/net_errors.h"
18 21
19 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
20 #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h" 23 #include "components/metrics/net/wifi_access_point_info_provider_chromeos.h"
21 #endif // OS_CHROMEOS 24 #endif // OS_CHROMEOS
22 25
23 namespace metrics { 26 namespace metrics {
24 27
25 NetworkMetricsProvider::NetworkMetricsProvider( 28 NetworkMetricsProvider::NetworkMetricsProvider(base::TaskRunner* io_task_runner)
26 base::TaskRunner* io_task_runner)
27 : io_task_runner_(io_task_runner), 29 : io_task_runner_(io_task_runner),
28 connection_type_is_ambiguous_(false), 30 connection_type_is_ambiguous_(false),
29 wifi_phy_layer_protocol_is_ambiguous_(false), 31 wifi_phy_layer_protocol_is_ambiguous_(false),
30 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN), 32 wifi_phy_layer_protocol_(net::WIFI_PHY_LAYER_PROTOCOL_UNKNOWN),
33 total_aborts_(0),
34 total_codes_(0),
31 weak_ptr_factory_(this) { 35 weak_ptr_factory_(this) {
32 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 36 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
33 connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); 37 connection_type_ = net::NetworkChangeNotifier::GetConnectionType();
34 ProbeWifiPHYLayerProtocol(); 38 ProbeWifiPHYLayerProtocol();
35 } 39 }
36 40
37 NetworkMetricsProvider::~NetworkMetricsProvider() { 41 NetworkMetricsProvider::~NetworkMetricsProvider() {
38 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 42 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
39 } 43 }
40 44
41 void NetworkMetricsProvider::ProvideGeneralMetrics( 45 void NetworkMetricsProvider::ProvideGeneralMetrics(
42 ChromeUserMetricsExtension*) { 46 ChromeUserMetricsExtension*) {
43 // ProvideGeneralMetrics is called on the main thread, at the time a metrics 47 // ProvideGeneralMetrics is called on the main thread, at the time a metrics
44 // record is being finalized. 48 // record is being finalized.
45 net::NetworkChangeNotifier::FinalizingMetricsLogRecord(); 49 net::NetworkChangeNotifier::FinalizingMetricsLogRecord();
50 LogAggregatedMetrics();
46 } 51 }
47 52
48 void NetworkMetricsProvider::ProvideSystemProfileMetrics( 53 void NetworkMetricsProvider::ProvideSystemProfileMetrics(
49 SystemProfileProto* system_profile) { 54 SystemProfileProto* system_profile) {
50 SystemProfileProto::Network* network = system_profile->mutable_network(); 55 SystemProfileProto::Network* network = system_profile->mutable_network();
51 network->set_connection_type_is_ambiguous(connection_type_is_ambiguous_); 56 network->set_connection_type_is_ambiguous(connection_type_is_ambiguous_);
52 network->set_connection_type(GetConnectionType()); 57 network->set_connection_type(GetConnectionType());
53 network->set_wifi_phy_layer_protocol_is_ambiguous( 58 network->set_wifi_phy_layer_protocol_is_ambiguous(
54 wifi_phy_layer_protocol_is_ambiguous_); 59 wifi_phy_layer_protocol_is_ambiguous_);
55 network->set_wifi_phy_layer_protocol(GetWifiPHYLayerProtocol()); 60 network->set_wifi_phy_layer_protocol(GetWifiPHYLayerProtocol());
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 for (const base::StringPiece& oui_str : base::SplitStringPiece( 238 for (const base::StringPiece& oui_str : base::SplitStringPiece(
234 info.oui_list, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { 239 info.oui_list, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
235 uint32_t oui; 240 uint32_t oui;
236 if (base::HexStringToUInt(oui_str, &oui)) 241 if (base::HexStringToUInt(oui_str, &oui))
237 vendor->add_element_identifier(oui); 242 vendor->add_element_identifier(oui);
238 else 243 else
239 NOTREACHED(); 244 NOTREACHED();
240 } 245 }
241 } 246 }
242 247
248 void NetworkMetricsProvider::LogAggregatedMetrics() {
249 base::HistogramBase* error_codes = base::SparseHistogram::FactoryGet(
250 "Net.ErrorCodesForMainFrame3",
251 base::HistogramBase::kUmaTargetedHistogramFlag);
252 scoped_ptr<base::HistogramSamples> samples = error_codes->SnapshotSamples();
253 base::HistogramBase::Count new_aborts =
254 samples->GetCount(-net::ERR_ABORTED) - total_aborts_;
255 base::HistogramBase::Count new_codes = samples->TotalCount() - total_codes_;
256 if (new_codes > 0) {
257 UMA_HISTOGRAM_COUNTS("Net.ErrAborted.CountPerUpload", new_aborts);
258 UMA_HISTOGRAM_PERCENTAGE("Net.ErrAborted.ProportionPerUpload",
259 (100 * new_aborts) / new_codes);
260 total_codes_ += new_codes;
261 total_aborts_ += new_aborts;
262 }
263 }
264
243 } // namespace metrics 265 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/net/network_metrics_provider.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698