downloads: Improve download rate estimation.
commit30ae76441edc1625333188cd924a5a20d456fdbc
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Wed, 29 May 2013 15:19:18 +0000 (29 15:19 +0000)
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Wed, 29 May 2013 15:19:18 +0000 (29 15:19 +0000)
tree6eacf0775d3788b40f04db670b45fe9cea49b48c
parente20fbed2f4ab2a62d95dea67a119a2c1c8a14bf7
downloads: Improve download rate estimation.

Previously, download rate was estimated as bytes_received/(current_time - download_start_time)

Although simple, this would react slowly to dynamic changes in download time, or user initiated pauses.

With this change, a ring buffer of the past 10 seconds of download time is used instead, and estimates are derived from that. It handles dynamic changes to bandwidth well. Pauses are handled reasonably well, as estimates are accurate after ten seconds - a better solution would be to clear the data rates when the user resumes from a pause. The main downside with this approach is it takes about 100 bytes of memory per active download, as well as adds some complexity.

BUG=16390
TEST=content_unittests

Review URL: https://chromiumcodereview.appspot.com/14697023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202874 0039d316-1c4b-4281-b951-d872f2087c98
content/browser/download/base_file.cc
content/browser/download/base_file.h
content/browser/download/base_file_unittest.cc
content/browser/download/download_file_impl.cc
content/browser/download/download_file_impl.h
content/browser/download/rate_estimator.cc [new file with mode: 0644]
content/browser/download/rate_estimator.h [new file with mode: 0644]
content/browser/download/rate_estimator_unittest.cc [new file with mode: 0644]
content/content_browser.gypi
content/content_tests.gypi