Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: content/browser/download/download_stats.cc

Issue 2872943003: Reduce unnecessary download interruptions due to parallel requests (Closed)
Patch Set: more restrictions on DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/download/download_job.cc ('k') | content/browser/download/download_worker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 RecordBandwidthMetric( 810 RecordBandwidthMetric(
811 "Download.ParallelizableDownloadBandwidth." 811 "Download.ParallelizableDownloadBandwidth."
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 if (bytes_downloaded_with_parallel_streams > 0) { 821 if (bytes_downloaded_with_parallel_streams > 0) {
821 RecordBandwidthMetric( 822 RecordBandwidthMetric(
822 "Download.ParallelizableDownloadBandwidth." 823 "Download.ParallelizableDownloadBandwidth."
823 "WithParallelRequestsMultipleStreams", 824 "WithParallelRequestsMultipleStreams",
824 CalculateBandwidthBytesPerSecond(bytes_downloaded_with_parallel_streams, 825 CalculateBandwidthBytesPerSecond(bytes_downloaded_with_parallel_streams,
825 time_with_parallel_streams)); 826 time_with_parallel_streams));
827 if (bandwidth_without_parallel_streams > 0) {
828 time_saved = base::TimeDelta::FromMilliseconds(
829 1000.0 * bytes_downloaded_with_parallel_streams /
830 bandwidth_without_parallel_streams) -
831 time_with_parallel_streams;
832 }
826 } 833 }
827 834
828 base::TimeDelta time_saved;
829 if (bandwidth_without_parallel_streams > 0) {
830 time_saved = base::TimeDelta::FromMilliseconds(
831 1000.0 * bytes_downloaded_with_parallel_streams /
832 bandwidth_without_parallel_streams) -
833 time_with_parallel_streams;
834 }
835 int kMillisecondsPerHour = 835 int kMillisecondsPerHour =
836 base::checked_cast<int>(base::Time::kMillisecondsPerSecond * 60 * 60); 836 base::checked_cast<int>(base::Time::kMillisecondsPerSecond * 60 * 60);
837 if (time_saved >= base::TimeDelta()) { 837 if (time_saved >= base::TimeDelta()) {
838 UMA_HISTOGRAM_CUSTOM_COUNTS( 838 UMA_HISTOGRAM_CUSTOM_COUNTS(
839 "Download.EstimatedTimeSavedWithParallelDownload", 839 "Download.EstimatedTimeSavedWithParallelDownload",
840 time_saved.InMilliseconds(), 0, kMillisecondsPerHour, 50); 840 time_saved.InMilliseconds(), 0, kMillisecondsPerHour, 50);
841 } else { 841 } else {
842 UMA_HISTOGRAM_CUSTOM_COUNTS( 842 UMA_HISTOGRAM_CUSTOM_COUNTS(
843 "Download.EstimatedTimeWastedWithParallelDownload", 843 "Download.EstimatedTimeWastedWithParallelDownload",
844 -time_saved.InMilliseconds(), 0, kMillisecondsPerHour, 50); 844 -time_saved.InMilliseconds(), 0, kMillisecondsPerHour, 50);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 } 934 }
935 935
936 void RecordDownloadHttpResponseCode(int response_code) { 936 void RecordDownloadHttpResponseCode(int response_code) {
937 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 937 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
938 "Download.HttpResponseCode", 938 "Download.HttpResponseCode",
939 net::HttpUtil::MapStatusCodeForHistogram(response_code), 939 net::HttpUtil::MapStatusCodeForHistogram(response_code),
940 net::HttpUtil::GetStatusCodesForHistogram()); 940 net::HttpUtil::GetStatusCodesForHistogram());
941 } 941 }
942 942
943 } // namespace content 943 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_job.cc ('k') | content/browser/download/download_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698