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 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", | 382 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.DownloadSize", |
383 download_len, | 383 download_len, |
384 1, | 384 1, |
385 max, | 385 max, |
386 256); | 386 256); |
387 } | 387 } |
388 | 388 |
389 void RecordDownloadInterrupted(DownloadInterruptReason reason, | 389 void RecordDownloadInterrupted(DownloadInterruptReason reason, |
390 int64_t received, | 390 int64_t received, |
391 int64_t total, | 391 int64_t total, |
392 bool is_parallelizable, | |
392 bool uses_parallel_requests) { | 393 bool uses_parallel_requests) { |
393 RecordDownloadCount(INTERRUPTED_COUNT); | 394 RecordDownloadCount(INTERRUPTED_COUNT); |
394 if (uses_parallel_requests) | 395 if (is_parallelizable) { |
395 RecordParallelDownloadCount(INTERRUPTED_COUNT); | 396 RecordParallelizableDownloadCount(INTERRUPTED_COUNT, |
397 uses_parallel_requests); | |
398 } | |
396 | 399 |
397 std::vector<base::HistogramBase::Sample> samples = | 400 std::vector<base::HistogramBase::Sample> samples = |
398 base::CustomHistogram::ArrayToCustomRanges( | 401 base::CustomHistogram::ArrayToCustomRanges( |
399 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes)); | 402 kAllInterruptReasonCodes, arraysize(kAllInterruptReasonCodes)); |
400 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.InterruptedReason", reason, | 403 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.InterruptedReason", reason, |
401 samples); | 404 samples); |
402 if (uses_parallel_requests) { | 405 if (uses_parallel_requests) { |
403 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 406 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
404 "Download.InterruptedReason.ParallelDownload", reason, samples); | 407 "Download.InterruptedReason.ParallelDownload", reason, samples); |
405 } | 408 } |
(...skipping 26 matching lines...) Expand all Loading... | |
432 if (uses_parallel_requests) { | 435 if (uses_parallel_requests) { |
433 UMA_HISTOGRAM_CUSTOM_COUNTS( | 436 UMA_HISTOGRAM_CUSTOM_COUNTS( |
434 "Download.InterruptedTotalSizeK.ParallelDownload", total_kb, 1, | 437 "Download.InterruptedTotalSizeK.ParallelDownload", total_kb, 1, |
435 kMaxKb, kBuckets); | 438 kMaxKb, kBuckets); |
436 } | 439 } |
437 if (delta_bytes == 0) { | 440 if (delta_bytes == 0) { |
438 RecordDownloadCount(INTERRUPTED_AT_END_COUNT); | 441 RecordDownloadCount(INTERRUPTED_AT_END_COUNT); |
439 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.InterruptedAtEndReason", | 442 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Download.InterruptedAtEndReason", |
440 reason, samples); | 443 reason, samples); |
441 | 444 |
442 if (uses_parallel_requests) { | 445 if (is_parallelizable) { |
443 RecordParallelDownloadCount(INTERRUPTED_AT_END_COUNT); | 446 RecordParallelizableDownloadCount(INTERRUPTED_AT_END_COUNT, |
447 uses_parallel_requests); | |
444 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 448 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
445 "Download.InterruptedAtEndReason.ParallelDownload", reason, | 449 "Download.InterruptedAtEndReason.ParallelDownload", reason, |
446 samples); | 450 samples); |
447 } | 451 } |
448 } else if (delta_bytes > 0) { | 452 } else if (delta_bytes > 0) { |
449 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedOverrunBytes", | 453 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.InterruptedOverrunBytes", |
450 delta_bytes, | 454 delta_bytes, |
451 1, | 455 1, |
452 kMaxKb, | 456 kMaxKb, |
453 kBuckets); | 457 kBuckets); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 void RecordFileBandwidth(size_t length, | 764 void RecordFileBandwidth(size_t length, |
761 base::TimeDelta disk_write_time, | 765 base::TimeDelta disk_write_time, |
762 base::TimeDelta elapsed_time) { | 766 base::TimeDelta elapsed_time) { |
763 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond", | 767 RecordBandwidthMetric("Download.BandwidthOverallBytesPerSecond", |
764 CalculateBandwidthBytesPerSecond(length, elapsed_time)); | 768 CalculateBandwidthBytesPerSecond(length, elapsed_time)); |
765 RecordBandwidthMetric( | 769 RecordBandwidthMetric( |
766 "Download.BandwidthDiskBytesPerSecond", | 770 "Download.BandwidthDiskBytesPerSecond", |
767 CalculateBandwidthBytesPerSecond(length, disk_write_time)); | 771 CalculateBandwidthBytesPerSecond(length, disk_write_time)); |
768 } | 772 } |
769 | 773 |
770 void RecordParallelDownloadCount(DownloadCountTypes type) { | 774 void RecordParallelizableDownloadCount(DownloadCountTypes type, |
771 UMA_HISTOGRAM_ENUMERATION("Download.Counts.ParallelDownload", type, | 775 bool uses_parallel_requests) { |
776 std::string histogram_name = uses_parallel_requests | |
777 ? "Download.Counts.ParallelDownload" | |
778 : "Download.Counts.ParallelizableDownload"; | |
779 UMA_HISTOGRAM_ENUMERATION(histogram_name, type, | |
Ilya Sherman
2017/04/19 00:29:41
UMA_HISTOGRAM macros require a runtime-constant na
qinmin
2017/04/19 22:42:33
Done.
| |
772 DOWNLOAD_COUNT_TYPES_LAST_ENTRY); | 780 DOWNLOAD_COUNT_TYPES_LAST_ENTRY); |
773 } | 781 } |
774 | 782 |
775 void RecordParallelDownloadRequestCount(int request_count) { | 783 void RecordParallelDownloadRequestCount(int request_count) { |
776 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.ParallelDownloadRequestCount", | 784 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.ParallelDownloadRequestCount", |
777 request_count, 1, 10, 11); | 785 request_count, 1, 10, 11); |
778 } | 786 } |
779 | 787 |
780 void RecordParallelDownloadAddStreamSuccess(bool success) { | 788 void RecordParallelDownloadAddStreamSuccess(bool success) { |
781 UMA_HISTOGRAM_BOOLEAN("Download.ParallelDownloadAddStreamSuccess", success); | 789 UMA_HISTOGRAM_BOOLEAN("Download.ParallelDownloadAddStreamSuccess", success); |
782 } | 790 } |
783 | 791 |
784 void RecordParallelDownloadStats( | 792 void RecordParallelizableDownloadStats( |
785 size_t bytes_downloaded_with_parallel_streams, | 793 size_t bytes_downloaded_with_parallel_streams, |
786 base::TimeDelta time_with_parallel_streams, | 794 base::TimeDelta time_with_parallel_streams, |
787 size_t bytes_downloaded_without_parallel_streams, | 795 size_t bytes_downloaded_without_parallel_streams, |
788 base::TimeDelta time_without_parallel_streams) { | 796 base::TimeDelta time_without_parallel_streams, |
789 int64_t bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond( | 797 bool uses_parallel_requests) { |
790 bytes_downloaded_without_parallel_streams, time_without_parallel_streams); | 798 int64_t bandwidth_without_parallel_streams = 0; |
791 RecordBandwidthMetric( | 799 if (bytes_downloaded_without_parallel_streams > 0) { |
792 "Download.BandwidthWithoutParallelStreamsBytesPerSecond", | 800 bandwidth_without_parallel_streams = CalculateBandwidthBytesPerSecond( |
793 bandwidth_without_parallel_streams); | 801 bytes_downloaded_without_parallel_streams, |
794 RecordBandwidthMetric( | 802 time_without_parallel_streams); |
795 "Download.BandwidthWithParallelStreamsBytesPerSecond", | 803 if (uses_parallel_requests) { |
796 CalculateBandwidthBytesPerSecond(bytes_downloaded_with_parallel_streams, | 804 RecordBandwidthMetric( |
797 time_with_parallel_streams)); | 805 "Download.ParallelizableDownloadBandwidth." |
806 "WithParallelRequestsSingleStream", | |
807 bandwidth_without_parallel_streams); | |
808 } else { | |
809 RecordBandwidthMetric( | |
810 "Download.ParallelizableDownloadBandwidth." | |
811 "WithoutParallelRequests", | |
812 bandwidth_without_parallel_streams); | |
813 } | |
814 } | |
815 | |
816 if (!uses_parallel_requests) | |
817 return; | |
818 | |
819 if (bytes_downloaded_with_parallel_streams > 0) { | |
820 RecordBandwidthMetric( | |
821 "Download.ParallelizableDownloadBandwidth." | |
822 "WithParallelRequestsMultipleStreams", | |
823 CalculateBandwidthBytesPerSecond(bytes_downloaded_with_parallel_streams, | |
824 time_with_parallel_streams)); | |
825 } | |
798 | 826 |
799 base::TimeDelta time_saved; | 827 base::TimeDelta time_saved; |
800 if (bandwidth_without_parallel_streams > 0) { | 828 if (bandwidth_without_parallel_streams > 0) { |
801 time_saved = base::TimeDelta::FromMilliseconds( | 829 time_saved = base::TimeDelta::FromMilliseconds( |
802 1000.0 * bytes_downloaded_with_parallel_streams / | 830 1000.0 * bytes_downloaded_with_parallel_streams / |
803 bandwidth_without_parallel_streams) - | 831 bandwidth_without_parallel_streams) - |
804 time_with_parallel_streams; | 832 time_with_parallel_streams; |
805 } | 833 } |
806 int kMillisecondsPerHour = | 834 int kMillisecondsPerHour = |
807 base::checked_cast<int>(base::Time::kMillisecondsPerSecond * 60 * 60); | 835 base::checked_cast<int>(base::Time::kMillisecondsPerSecond * 60 * 60); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
898 if (!page_transition) | 926 if (!page_transition) |
899 return; | 927 return; |
900 | 928 |
901 UMA_HISTOGRAM_ENUMERATION( | 929 UMA_HISTOGRAM_ENUMERATION( |
902 "Download.PageTransition", | 930 "Download.PageTransition", |
903 ui::PageTransitionStripQualifier(page_transition.value()), | 931 ui::PageTransitionStripQualifier(page_transition.value()), |
904 ui::PAGE_TRANSITION_LAST_CORE + 1); | 932 ui::PAGE_TRANSITION_LAST_CORE + 1); |
905 } | 933 } |
906 | 934 |
907 } // namespace content | 935 } // namespace content |
OLD | NEW |