OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/download/download_stats.h" | 5 #include "content/browser/download/download_stats.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "content/browser/download/download_resource_handler.h" | 9 #include "content/browser/download/download_resource_handler.h" |
10 #include "content/public/browser/download_interrupt_reasons.h" | 10 #include "content/public/browser/download_interrupt_reasons.h" |
| 11 #include "net/base/net_errors.h" |
11 #include "net/http/http_content_disposition.h" | 12 #include "net/http/http_content_disposition.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // All possible error codes from the network module. Note that the error codes | 18 // All possible error codes from the network module. Note that the error codes |
18 // are all positive (since histograms expect positive sample values). | 19 // are all positive (since histograms expect positive sample values). |
19 const int kAllInterruptReasonCodes[] = { | 20 const int kAllInterruptReasonCodes[] = { |
20 #define INTERRUPT_REASON(label, value) (value), | 21 #define INTERRUPT_REASON(label, value) (value), |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 int max = 1024 * 1024; // One Megabyte. | 172 int max = 1024 * 1024; // One Megabyte. |
172 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.WriteSize", data_len, 1, max, 256); | 173 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.WriteSize", data_len, 1, max, 256); |
173 } | 174 } |
174 | 175 |
175 void RecordDownloadWriteLoopCount(int count) { | 176 void RecordDownloadWriteLoopCount(int count) { |
176 UMA_HISTOGRAM_ENUMERATION("Download.WriteLoopCount", count, 20); | 177 UMA_HISTOGRAM_ENUMERATION("Download.WriteLoopCount", count, 20); |
177 } | 178 } |
178 | 179 |
179 void RecordAcceptsRanges(const std::string& accepts_ranges, | 180 void RecordAcceptsRanges(const std::string& accepts_ranges, |
180 int64 download_len, | 181 int64 download_len, |
181 const std::string& etag) { | 182 bool has_strong_validator) { |
182 int64 max = 1024 * 1024 * 1024; // One Terabyte. | 183 int64 max = 1024 * 1024 * 1024; // One Terabyte. |
183 download_len /= 1024; // In Kilobytes | 184 download_len /= 1024; // In Kilobytes |
184 static const int kBuckets = 50; | 185 static const int kBuckets = 50; |
185 | 186 |
186 if (LowerCaseEqualsASCII(accepts_ranges, "none")) { | 187 if (LowerCaseEqualsASCII(accepts_ranges, "none")) { |
187 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesNone.KBytes", | 188 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesNone.KBytes", |
188 download_len, | 189 download_len, |
189 1, | 190 1, |
190 max, | 191 max, |
191 kBuckets); | 192 kBuckets); |
192 } else if (LowerCaseEqualsASCII(accepts_ranges, "bytes")) { | 193 } else if (LowerCaseEqualsASCII(accepts_ranges, "bytes")) { |
193 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesBytes.KBytes", | 194 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesBytes.KBytes", |
194 download_len, | 195 download_len, |
195 1, | 196 1, |
196 max, | 197 max, |
197 kBuckets); | 198 kBuckets); |
198 // ETags that start with "W/" are considered weak ETags which don't imply | 199 if (has_strong_validator) |
199 // byte-wise equality. | |
200 if (!StartsWithASCII(etag, "w/", false)) | |
201 RecordDownloadCount(STRONG_ETAG_AND_ACCEPTS_RANGES); | 200 RecordDownloadCount(STRONG_ETAG_AND_ACCEPTS_RANGES); |
202 } else { | 201 } else { |
203 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesMissingOrInvalid.KBytes", | 202 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesMissingOrInvalid.KBytes", |
204 download_len, | 203 download_len, |
205 1, | 204 1, |
206 max, | 205 max, |
207 kBuckets); | 206 kBuckets); |
208 } | 207 } |
209 } | 208 } |
210 | 209 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 UMA_HISTOGRAM_CUSTOM_COUNTS( | 445 UMA_HISTOGRAM_CUSTOM_COUNTS( |
447 "Download.BandwidthOverallBytesPerSecond", | 446 "Download.BandwidthOverallBytesPerSecond", |
448 (1000 * length / elapsed_time_ms), 1, 50000000, 50); | 447 (1000 * length / elapsed_time_ms), 1, 50000000, 50); |
449 UMA_HISTOGRAM_CUSTOM_COUNTS( | 448 UMA_HISTOGRAM_CUSTOM_COUNTS( |
450 "Download.BandwidthDiskBytesPerSecond", | 449 "Download.BandwidthDiskBytesPerSecond", |
451 (1000 * length / disk_write_time_ms), 1, 50000000, 50); | 450 (1000 * length / disk_write_time_ms), 1, 50000000, 50); |
452 UMA_HISTOGRAM_COUNTS_100("Download.DiskBandwidthUsedPercentage", | 451 UMA_HISTOGRAM_COUNTS_100("Download.DiskBandwidthUsedPercentage", |
453 disk_write_time_ms * 100 / elapsed_time_ms); | 452 disk_write_time_ms * 100 / elapsed_time_ms); |
454 } | 453 } |
455 | 454 |
| 455 void RecordNetErrorForNetworkFailed(int net_error) { |
| 456 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.MapErrorNetworkFailed", |
| 457 std::abs(net_error), |
| 458 net::GetAllErrorCodesForUma()); |
| 459 } |
| 460 |
456 void RecordSavePackageEvent(SavePackageEvent event) { | 461 void RecordSavePackageEvent(SavePackageEvent event) { |
457 UMA_HISTOGRAM_ENUMERATION("Download.SavePackage", | 462 UMA_HISTOGRAM_ENUMERATION("Download.SavePackage", |
458 event, | 463 event, |
459 SAVE_PACKAGE_LAST_ENTRY); | 464 SAVE_PACKAGE_LAST_ENTRY); |
460 } | 465 } |
461 | 466 |
462 } // namespace content | 467 } // namespace content |
OLD | NEW |