• cbentzel@chromium.org's avatar
    downloads: Improve download rate estimation. · 30ae7644
    cbentzel@chromium.org authored
    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
    30ae7644
base_file.cc 11.9 KB