| 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/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "content/browser/download/download_resource_handler.h" | 10 #include "content/browser/download/download_resource_handler.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 int max = 1024 * 1024; // One Megabyte. | 325 int max = 1024 * 1024; // One Megabyte. |
| 326 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.WriteSize", data_len, 1, max, 256); | 326 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.WriteSize", data_len, 1, max, 256); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void RecordDownloadWriteLoopCount(int count) { | 329 void RecordDownloadWriteLoopCount(int count) { |
| 330 UMA_HISTOGRAM_ENUMERATION("Download.WriteLoopCount", count, 20); | 330 UMA_HISTOGRAM_ENUMERATION("Download.WriteLoopCount", count, 20); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void RecordAcceptsRanges(const std::string& accepts_ranges, | 333 void RecordAcceptsRanges(const std::string& accepts_ranges, |
| 334 int64 download_len, | 334 int64 download_len, |
| 335 const std::string& etag) { | 335 bool has_strong_validator) { |
| 336 int64 max = 1024 * 1024 * 1024; // One Terabyte. | 336 int64 max = 1024 * 1024 * 1024; // One Terabyte. |
| 337 download_len /= 1024; // In Kilobytes | 337 download_len /= 1024; // In Kilobytes |
| 338 static const int kBuckets = 50; | 338 static const int kBuckets = 50; |
| 339 | 339 |
| 340 if (LowerCaseEqualsASCII(accepts_ranges, "none")) { | 340 if (LowerCaseEqualsASCII(accepts_ranges, "none")) { |
| 341 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesNone.KBytes", | 341 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesNone.KBytes", |
| 342 download_len, | 342 download_len, |
| 343 1, | 343 1, |
| 344 max, | 344 max, |
| 345 kBuckets); | 345 kBuckets); |
| 346 } else if (LowerCaseEqualsASCII(accepts_ranges, "bytes")) { | 346 } else if (LowerCaseEqualsASCII(accepts_ranges, "bytes")) { |
| 347 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesBytes.KBytes", | 347 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesBytes.KBytes", |
| 348 download_len, | 348 download_len, |
| 349 1, | 349 1, |
| 350 max, | 350 max, |
| 351 kBuckets); | 351 kBuckets); |
| 352 // ETags that start with "W/" are considered weak ETags which don't imply | 352 if (has_strong_validator) |
| 353 // byte-wise equality. | 353 RecordDownloadCount(STRONG_VALIDATOR_AND_ACCEPTS_RANGES); |
| 354 if (!StartsWithASCII(etag, "w/", false)) | |
| 355 RecordDownloadCount(STRONG_ETAG_AND_ACCEPTS_RANGES); | |
| 356 } else { | 354 } else { |
| 357 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesMissingOrInvalid.KBytes", | 355 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.AcceptRangesMissingOrInvalid.KBytes", |
| 358 download_len, | 356 download_len, |
| 359 1, | 357 1, |
| 360 max, | 358 max, |
| 361 kBuckets); | 359 kBuckets); |
| 362 } | 360 } |
| 363 } | 361 } |
| 364 | 362 |
| 365 namespace { | 363 namespace { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 disk_write_time_ms * 100 / elapsed_time_ms); | 605 disk_write_time_ms * 100 / elapsed_time_ms); |
| 608 } | 606 } |
| 609 | 607 |
| 610 void RecordSavePackageEvent(SavePackageEvent event) { | 608 void RecordSavePackageEvent(SavePackageEvent event) { |
| 611 UMA_HISTOGRAM_ENUMERATION("Download.SavePackage", | 609 UMA_HISTOGRAM_ENUMERATION("Download.SavePackage", |
| 612 event, | 610 event, |
| 613 SAVE_PACKAGE_LAST_ENTRY); | 611 SAVE_PACKAGE_LAST_ENTRY); |
| 614 } | 612 } |
| 615 | 613 |
| 616 } // namespace content | 614 } // namespace content |
| OLD | NEW |