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

Side by Side Diff: components/data_use_measurement/content/data_use_measurement.cc

Issue 1818613002: Implement UMA log throttling for cellular connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build for gn, fix unittests, add comments Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/data_use_measurement/content/data_use_measurement.h" 5 #include "components/data_use_measurement/content/data_use_measurement.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/metrics/sparse_histogram.h" 8 #include "base/metrics/sparse_histogram.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 UPSTREAM), 81 UPSTREAM),
82 total_upload_bytes); 82 total_upload_bytes);
83 RecordUMAHistogramCount( 83 RecordUMAHistogramCount(
84 GetHistogramName(is_user_traffic ? "DataUse.TrafficSize.User" 84 GetHistogramName(is_user_traffic ? "DataUse.TrafficSize.User"
85 : "DataUse.TrafficSize.System", 85 : "DataUse.TrafficSize.System",
86 DOWNSTREAM), 86 DOWNSTREAM),
87 total_received_bytes); 87 total_received_bytes);
88 88
89 DataUseUserData* attached_service_data = reinterpret_cast<DataUseUserData*>( 89 DataUseUserData* attached_service_data = reinterpret_cast<DataUseUserData*>(
90 request->GetUserData(DataUseUserData::kUserDataKey)); 90 request->GetUserData(DataUseUserData::kUserDataKey));
91 91 DataUseUserData::ServiceName service_name =
92 attached_service_data ? attached_service_data->service_name()
93 : DataUseUserData::NOT_TAGGED;
92 if (!is_user_traffic) { 94 if (!is_user_traffic) {
93 DataUseUserData::ServiceName service_name =
94 attached_service_data ? attached_service_data->service_name()
95 : DataUseUserData::NOT_TAGGED;
96 ReportDataUsageServices(service_name, UPSTREAM, total_upload_bytes); 95 ReportDataUsageServices(service_name, UPSTREAM, total_upload_bytes);
97 ReportDataUsageServices(service_name, DOWNSTREAM, total_received_bytes); 96 ReportDataUsageServices(service_name, DOWNSTREAM, total_received_bytes);
98 } 97 }
98
99 // Update data use prefs for cellular connections.
100 bool is_cellular = net::NetworkChangeNotifier::IsConnectionCellular(
101 net::NetworkChangeNotifier::GetConnectionType());
Alexei Svitkine (slow) 2016/03/31 04:32:25 This already gets queried inside the GetHistogramN
gayane -on leave until 09-2017 2016/03/31 17:54:58 Done.
102 if (is_cellular && !metrics_data_use_forwarder_.is_null()) {
103 metrics_data_use_forwarder_.Run(
104 attached_service_data->GetServiceNameAsString(service_name),
105 total_upload_bytes + total_received_bytes);
106 }
99 } 107 }
100 108
101 #if defined(OS_ANDROID) 109 #if defined(OS_ANDROID)
102 void DataUseMeasurement::OnApplicationStateChangeForTesting( 110 void DataUseMeasurement::OnApplicationStateChangeForTesting(
103 base::android::ApplicationState application_state) { 111 base::android::ApplicationState application_state) {
104 app_state_ = application_state; 112 app_state_ = application_state;
105 } 113 }
106 #endif 114 #endif
107 115
108 DataUseMeasurement::AppState DataUseMeasurement::CurrentAppState() const { 116 DataUseMeasurement::AppState DataUseMeasurement::CurrentAppState() const {
(...skipping 30 matching lines...) Expand all
139 RecordUMAHistogramCount( 147 RecordUMAHistogramCount(
140 "DataUse.MessageSize." + DataUseUserData::GetServiceNameAsString(service), 148 "DataUse.MessageSize." + DataUseUserData::GetServiceNameAsString(service),
141 message_size); 149 message_size);
142 if (message_size > 0) { 150 if (message_size > 0) {
143 IncreaseSparseHistogramByValue( 151 IncreaseSparseHistogramByValue(
144 GetHistogramName("DataUse.MessageSize.AllServices", dir), service, 152 GetHistogramName("DataUse.MessageSize.AllServices", dir), service,
145 message_size); 153 message_size);
146 } 154 }
147 } 155 }
148 156
157 void DataUseMeasurement::SetMetricsDataUseForwarder(
158 metrics::UpdateUsagePrefCallbackType metrics_data_use_forwarder) {
159 metrics_data_use_forwarder_ = metrics_data_use_forwarder;
160 }
161
149 } // namespace data_use_measurement 162 } // namespace data_use_measurement
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698