| 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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 "WithoutParallelRequests", | 812 "WithoutParallelRequests", |
| 813 bandwidth_without_parallel_streams); | 813 bandwidth_without_parallel_streams); |
| 814 } | 814 } |
| 815 } | 815 } |
| 816 | 816 |
| 817 if (!uses_parallel_requests) | 817 if (!uses_parallel_requests) |
| 818 return; | 818 return; |
| 819 | 819 |
| 820 base::TimeDelta time_saved; | 820 base::TimeDelta time_saved; |
| 821 if (bytes_downloaded_with_parallel_streams > 0) { | 821 if (bytes_downloaded_with_parallel_streams > 0) { |
| 822 int64_t bandwidth_with_parallel_streams = CalculateBandwidthBytesPerSecond( |
| 823 bytes_downloaded_with_parallel_streams, time_with_parallel_streams); |
| 822 RecordBandwidthMetric( | 824 RecordBandwidthMetric( |
| 823 "Download.ParallelizableDownloadBandwidth." | 825 "Download.ParallelizableDownloadBandwidth." |
| 824 "WithParallelRequestsMultipleStreams", | 826 "WithParallelRequestsMultipleStreams", |
| 825 CalculateBandwidthBytesPerSecond(bytes_downloaded_with_parallel_streams, | 827 bandwidth_with_parallel_streams); |
| 826 time_with_parallel_streams)); | |
| 827 if (bandwidth_without_parallel_streams > 0) { | 828 if (bandwidth_without_parallel_streams > 0) { |
| 828 time_saved = base::TimeDelta::FromMilliseconds( | 829 time_saved = base::TimeDelta::FromMilliseconds( |
| 829 1000.0 * bytes_downloaded_with_parallel_streams / | 830 1000.0 * bytes_downloaded_with_parallel_streams / |
| 830 bandwidth_without_parallel_streams) - | 831 bandwidth_without_parallel_streams) - |
| 831 time_with_parallel_streams; | 832 time_with_parallel_streams; |
| 833 int bandwidth_ratio_percentage = |
| 834 (100.0 * bandwidth_with_parallel_streams) / |
| 835 bandwidth_without_parallel_streams; |
| 836 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 837 "Download.ParallelDownload.BandwidthRatioPercentage", |
| 838 bandwidth_ratio_percentage, 0, 400, 101); |
| 839 base::TimeDelta total_time = |
| 840 time_with_parallel_streams + time_without_parallel_streams; |
| 841 size_t total_size = bytes_downloaded_with_parallel_streams + |
| 842 bytes_downloaded_without_parallel_streams; |
| 843 base::TimeDelta non_parallel_time = base::TimeDelta::FromSecondsD( |
| 844 static_cast<double>(total_size) / bandwidth_without_parallel_streams); |
| 845 int time_ratio_percentage = |
| 846 100.0 * total_time.InSecondsF() / non_parallel_time.InSecondsF(); |
| 847 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 848 "Download.ParallelDownload.TotalTimeRatioPercentage", |
| 849 time_ratio_percentage, 0, 200, 101); |
| 832 } | 850 } |
| 833 } | 851 } |
| 834 | 852 |
| 835 int kMillisecondsPerHour = | 853 int kMillisecondsPerHour = |
| 836 base::checked_cast<int>(base::Time::kMillisecondsPerSecond * 60 * 60); | 854 base::checked_cast<int>(base::Time::kMillisecondsPerSecond * 60 * 60); |
| 837 if (time_saved >= base::TimeDelta()) { | 855 if (time_saved >= base::TimeDelta()) { |
| 838 UMA_HISTOGRAM_CUSTOM_COUNTS( | 856 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 839 "Download.EstimatedTimeSavedWithParallelDownload", | 857 "Download.EstimatedTimeSavedWithParallelDownload", |
| 840 time_saved.InMilliseconds(), 0, kMillisecondsPerHour, 50); | 858 time_saved.InMilliseconds(), 0, kMillisecondsPerHour, 50); |
| 841 } else { | 859 } else { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 } | 952 } |
| 935 | 953 |
| 936 void RecordDownloadHttpResponseCode(int response_code) { | 954 void RecordDownloadHttpResponseCode(int response_code) { |
| 937 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 955 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
| 938 "Download.HttpResponseCode", | 956 "Download.HttpResponseCode", |
| 939 net::HttpUtil::MapStatusCodeForHistogram(response_code), | 957 net::HttpUtil::MapStatusCodeForHistogram(response_code), |
| 940 net::HttpUtil::GetStatusCodesForHistogram()); | 958 net::HttpUtil::GetStatusCodesForHistogram()); |
| 941 } | 959 } |
| 942 | 960 |
| 943 } // namespace content | 961 } // namespace content |
| OLD | NEW |