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

Unified Diff: content/browser/download/base_file.cc

Issue 14697023: downloads: Improve download rate estimation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve unit tests Created 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/base_file.cc
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 687c321c9c8d212d983b4492399ef8de41a0ad80..f31a0646761361b07206481f739ecf300029766e 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -137,6 +137,7 @@ DownloadInterruptReason BaseFile::AppendDataToFile(const char* data,
len -= write_size;
current_data += write_size;
bytes_so_far_ += write_size;
+ rate_estimator_.AddBytes(write_size);
}
RecordDownloadWriteSize(data_len);
@@ -340,9 +341,7 @@ void BaseFile::ClearStream() {
}
int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const {
- base::TimeDelta diff = current_time - start_tick_;
- int64 diff_ms = diff.InMilliseconds();
- return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
+ return rate_estimator_.GetBytesPerSecond();
}
DownloadInterruptReason BaseFile::LogNetError(

Powered by Google App Engine
This is Rietveld 408576698