OLD | NEW |
---|---|
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/hash.h" | 7 #include "base/hash.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "net/base/network_change_notifier.h" | 10 #include "net/base/network_change_notifier.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 } | 128 } |
129 std::string serviceHistogramName = "DataUse.Service." + service_name; | 129 std::string serviceHistogramName = "DataUse.Service." + service_name; |
130 std::string combinedHistogramName = | 130 std::string combinedHistogramName = |
131 "DataUse.Services" + first_suffix + second_suffix + third_suffix; | 131 "DataUse.Services" + first_suffix + second_suffix + third_suffix; |
132 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE( | 132 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE( |
133 combinedHistogramName, base::Hash(service_name), message_size); | 133 combinedHistogramName, base::Hash(service_name), message_size); |
134 TRAFFIC_MEASUREMENT_UMA_HISTOGRAM(serviceHistogramName, message_size); | 134 TRAFFIC_MEASUREMENT_UMA_HISTOGRAM(serviceHistogramName, message_size); |
135 } | 135 } |
136 | 136 |
137 } // namespace | 137 } // namespace |
138 void SparseDataUseReport(const std::string& histogram_name, | |
bengr
2015/08/07 17:13:37
Add a blank line above.
amohammadkhan
2015/08/07 18:52:30
Done.
| |
139 int value, | |
140 int count) { | |
141 if (count > 0) | |
142 UMA_HISTOGRAM_SPARSE_SLOWLY_WITH_VALUE(histogram_name, value, count); | |
143 else | |
144 LOG(ERROR) << "Ali1 zero or negative count " << count; | |
bengr
2015/08/07 17:13:37
What is Ali1?
amohammadkhan
2015/08/07 18:52:30
Sorry, basically this LOG(ERROR) was for testing t
| |
145 } | |
138 | 146 |
139 void DataUseReport(const std::string& service_name, | 147 void DataUseReport(const std::string& service_name, |
140 const net::URLFetcher* fetcher) { | 148 const net::URLFetcher* fetcher) { |
141 #if defined(OS_ANDROID) | 149 #if defined(OS_ANDROID) |
142 if (!listener_made) { | 150 if (!listener_made) { |
143 listener_made = true; | 151 listener_made = true; |
144 app_listener = new base::android::ApplicationStatusListener( | 152 app_listener = new base::android::ApplicationStatusListener( |
145 base::Bind(&OnApplicationStateChange)); | 153 base::Bind(&OnApplicationStateChange)); |
146 } | 154 } |
147 #endif | 155 #endif |
148 int total_upload_bytes = fetcher->GetBytesSentSize(); | 156 int total_upload_bytes = fetcher->GetBytesSentSize(); |
149 int total_received_bytes = fetcher->GetBytesReceivedSize(); | 157 int total_received_bytes = fetcher->GetBytesReceivedSize(); |
150 ReportDataUsage(service_name, UPLOAD, total_upload_bytes); | 158 ReportDataUsage(service_name, UPLOAD, total_upload_bytes); |
151 ReportDataUsage(service_name, DOWNLOAD, total_received_bytes); | 159 ReportDataUsage(service_name, DOWNLOAD, total_received_bytes); |
152 } | 160 } |
OLD | NEW |