Chromium Code Reviews| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/histogram_functions.h" | 8 #include "base/metrics/histogram_functions.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 download_len /= 1024; // In Kilobytes | 382 download_len /= 1024; // In Kilobytes |
| 383 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", | 383 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", |
| 384 download_len, | 384 download_len, |
| 385 1, | 385 1, |
| 386 max, | 386 max, |
| 387 256); | 387 256); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void RecordDownloadInterrupted(DownloadInterruptReason reason, | 390 void RecordDownloadInterrupted(DownloadInterruptReason reason, |
| 391 int64_t received, | 391 int64_t received, |
| 392 int64_t total) { | 392 int64_t total, |
| 393 bool uses_parallel_requests) { | |
| 393 RecordDownloadCount(INTERRUPTED_COUNT); | 394 RecordDownloadCount(INTERRUPTED_COUNT); |
| 394 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 395 if (uses_parallel_requests) |
| 395 "Download.InterruptedReason", | 396 RecordParallelDownloadCount(PARALLEL_DOWNLOAD_INTERRUPTED_COUNT); |
| 396 reason, | 397 |
| 398 std::vector<base::HistogramBase::Sample> samples = | |
| 397 base::CustomHistogram::ArrayToCustomRanges( | 399 base::CustomHistogram::ArrayToCustomRanges( |
| 398 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes))); | 400 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes)); |
| 401 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.InterruptedReason", reason, | |
| 402 samples); | |
| 403 if (uses_parallel_requests) { | |
| 404 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | |
| 405 "Download.ParallelDownloadInterruptedReason", reason, samples); | |
| 406 } | |
| 399 | 407 |
| 400 // The maximum should be 2^kBuckets, to have the logarithmic bucket | 408 // The maximum should be 2^kBuckets, to have the logarithmic bucket |
| 401 // boundaries fall on powers of 2. | 409 // boundaries fall on powers of 2. |
| 402 static const int kBuckets = 30; | 410 static const int kBuckets = 30; |
| 403 static const int64_t kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes. | 411 static const int64_t kMaxKb = 1 << kBuckets; // One Terabyte, in Kilobytes. |
| 404 int64_t delta_bytes = total - received; | 412 int64_t delta_bytes = total - received; |
| 405 bool unknown_size = total <= 0; | 413 bool unknown_size = total <= 0; |
| 406 int64_t received_kb = received / 1024; | 414 int64_t received_kb = received / 1024; |
| 407 int64_t total_kb = total / 1024; | 415 int64_t total_kb = total / 1024; |
| 408 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedReceivedSizeK", | 416 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedReceivedSizeK", |
| 409 received_kb, | 417 received_kb, |
| 410 1, | 418 1, |
| 411 kMaxKb, | 419 kMaxKb, |
| 412 kBuckets); | 420 kBuckets); |
| 421 if (uses_parallel_requests) { | |
| 422 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 423 "Download.ParallelDownloadInterruptedReceivedSizeK", received_kb, 1, | |
|
Ilya Sherman
2017/03/24 00:52:59
Optional: You might want to move "ParallelDownload
Ilya Sherman
2017/03/24 00:52:59
nit: I'd use an extra dot to separate "ParallelDow
qinmin
2017/03/24 19:54:39
uses .ParallelDownload suffix now
qinmin
2017/03/24 19:54:40
Done.
| |
| 424 kMaxKb, kBuckets); | |
| 425 } | |
| 426 | |
| 413 if (!unknown_size) { | 427 if (!unknown_size) { |
| 414 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedTotalSizeK", | 428 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedTotalSizeK", |
| 415 total_kb, | 429 total_kb, |
| 416 1, | 430 1, |
| 417 kMaxKb, | 431 kMaxKb, |
| 418 kBuckets); | 432 kBuckets); |
| 433 if (uses_parallel_requests) { | |
| 434 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 435 "Download.ParallelDownloadInterruptedTotalSizeK", total_kb, 1, kMaxKb, | |
| 436 kBuckets); | |
| 437 } | |
| 419 if (delta_bytes == 0) { | 438 if (delta_bytes == 0) { |
| 420 RecordDownloadCount(INTERRUPTED_AT_END_COUNT); | 439 RecordDownloadCount(INTERRUPTED_AT_END_COUNT); |
| 421 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 440 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
| 422 "Download.InterruptedAtEndReason", | 441 "Download.InterruptedAtEndReason", reason, samples); |
| 423 reason, | 442 |
| 424 base::CustomHistogram::ArrayToCustomRanges( | 443 if (uses_parallel_requests) { |
| 425 kAllInterruptReasonCodes, | 444 RecordParallelDownloadCount(PARALLEL_DOWNLOAD_INTERRUPTED_AT_END_COUNT); |
| 426 arraysize(kAllInterruptReasonCodes))); | 445 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
| 446 "Download.ParallelDownloadInterruptedAtEndReason", reason, samples); | |
| 447 } | |
| 427 } else if (delta_bytes > 0) { | 448 } else if (delta_bytes > 0) { |
| 428 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedOverrunBytes", | 449 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedOverrunBytes", |
| 429 delta_bytes, | 450 delta_bytes, |
| 430 1, | 451 1, |
| 431 kMaxKb, | 452 kMaxKb, |
| 432 kBuckets); | 453 kBuckets); |
| 454 if (uses_parallel_requests) { | |
| 455 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 456 "Download.ParallelDownloadInterruptedOverrunBytes", delta_bytes, 1, | |
| 457 kMaxKb, kBuckets); | |
| 458 } | |
| 433 } else { | 459 } else { |
| 434 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedUnderrunBytes", | 460 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedUnderrunBytes", |
| 435 -delta_bytes, | 461 -delta_bytes, |
| 436 1, | 462 1, |
| 437 kMaxKb, | 463 kMaxKb, |
| 438 kBuckets); | 464 kBuckets); |
| 465 if (uses_parallel_requests) { | |
| 466 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 467 "Download.ParallelDownloadInterruptedUnderrunBytes", -delta_bytes, | |
| 468 1, kMaxKb, kBuckets); | |
| 469 } | |
| 439 } | 470 } |
| 440 } | 471 } |
| 441 | 472 |
| 442 UMA_HISTOGRAM_BOOLEAN("Download.InterruptedUnknownSize", unknown_size); | 473 UMA_HISTOGRAM_BOOLEAN("Download.InterruptedUnknownSize", unknown_size); |
| 443 } | 474 } |
| 444 | 475 |
| 445 void RecordMaliciousDownloadClassified(DownloadDangerType danger_type) { | 476 void RecordMaliciousDownloadClassified(DownloadDangerType danger_type) { |
| 446 UMA_HISTOGRAM_ENUMERATION("Download.MaliciousDownloadClassified", | 477 UMA_HISTOGRAM_ENUMERATION("Download.MaliciousDownloadClassified", |
| 447 danger_type, | 478 danger_type, |
| 448 DOWNLOAD_DANGER_TYPE_MAX); | 479 DOWNLOAD_DANGER_TYPE_MAX); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 void RecordFileBandwidth(size_t length, | 750 void RecordFileBandwidth(size_t length, |
| 720 base::TimeDelta disk_write_time, | 751 base::TimeDelta disk_write_time, |
| 721 base::TimeDelta elapsed_time) { | 752 base::TimeDelta elapsed_time) { |
| 722 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond", | 753 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond", |
| 723 CalculateBandwidthBytesPerSecond(length, elapsed_time)); | 754 CalculateBandwidthBytesPerSecond(length, elapsed_time)); |
| 724 RecordBandwidthMetric( | 755 RecordBandwidthMetric( |
| 725 "Download.BandwidthDiskBytesPerSecond", | 756 "Download.BandwidthDiskBytesPerSecond", |
| 726 CalculateBandwidthBytesPerSecond(length, disk_write_time)); | 757 CalculateBandwidthBytesPerSecond(length, disk_write_time)); |
| 727 } | 758 } |
| 728 | 759 |
| 760 void RecordParallelDownloadCount(ParallelDownloadCountTypes type) { | |
| 761 UMA_HISTOGRAM_ENUMERATION("Download.ParallelDownloadCounts", type, | |
| 762 PARALLEL_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); | |
| 763 } | |
| 764 | |
| 729 void RecordParallelDownloadStats( | 765 void RecordParallelDownloadStats( |
| 730 size_t bytes_downloaded_with_parallel_streams, | 766 size_t bytes_downloaded_with_parallel_streams, |
| 731 base::TimeDelta time_with_parallel_streams, | 767 base::TimeDelta time_with_parallel_streams, |
| 732 size_t bytes_downloaded_without_parallel_streams, | 768 size_t bytes_downloaded_without_parallel_streams, |
| 733 base::TimeDelta time_without_parallel_streams) { | 769 base::TimeDelta time_without_parallel_streams) { |
| 734 int bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond( | 770 int bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond( |
| 735 bytes_downloaded_without_parallel_streams, time_without_parallel_streams); | 771 bytes_downloaded_without_parallel_streams, time_without_parallel_streams); |
| 736 RecordBandwidthMetric( | 772 RecordBandwidthMetric( |
| 737 "Download.BandwidthWithoutParallelStreamsBytesPerSecond", | 773 "Download.BandwidthWithoutParallelStreamsBytesPerSecond", |
| 738 bandwidth_without_parallel_streams); | 774 bandwidth_without_parallel_streams); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 838 if (!page_transition) | 874 if (!page_transition) |
| 839 return; | 875 return; |
| 840 | 876 |
| 841 UMA_HISTOGRAM_ENUMERATION( | 877 UMA_HISTOGRAM_ENUMERATION( |
| 842 "Download.PageTransition", | 878 "Download.PageTransition", |
| 843 ui::PageTransitionStripQualifier(page_transition.value()), | 879 ui::PageTransitionStripQualifier(page_transition.value()), |
| 844 ui::PAGE_TRANSITION_LAST_CORE + 1); | 880 ui::PAGE_TRANSITION_LAST_CORE + 1); |
| 845 } | 881 } |
| 846 | 882 |
| 847 } // namespace content | 883 } // namespace content |
| OLD | NEW |