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

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

Issue 2736613009: Initialize the download file with correct bytes_so_far value (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_file_impl.cc
diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc
index 8b2a9e8e81585fb36be77bd083558ba356fc8ffa..e4ec806f7718c8b4de357eb9977f329a852834a7 100644
--- a/content/browser/download/download_file_impl.cc
+++ b/content/browser/download/download_file_impl.cc
@@ -96,9 +96,17 @@ void DownloadFileImpl::Initialize(const InitializeCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
update_timer_.reset(new base::RepeatingTimer());
+ int64_t bytes_so_far = 0;
+ if (is_sparse_file_) {
+ for (const auto& received_slice : received_slices_) {
+ bytes_so_far += received_slice.received_bytes;
+ }
+ } else {
+ bytes_so_far = save_info_->offset;
+ }
DownloadInterruptReason result =
file_.Initialize(save_info_->file_path, default_download_directory_,
- std::move(save_info_->file), save_info_->offset,
+ std::move(save_info_->file), bytes_so_far,
save_info_->hash_of_partial_file,
std::move(save_info_->hash_state), is_sparse_file_);
if (result != DOWNLOAD_INTERRUPT_REASON_NONE) {
@@ -410,7 +418,6 @@ void DownloadFileImpl::RegisterAndActivateStream(SourceStream* source_stream) {
}
int64_t DownloadFileImpl::TotalBytesReceived() const {
- // TODO(xingliu): Use slice info to figure out total bytes received.
return file_.bytes_so_far();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698