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

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

Issue 2811293004: Fix an issue that we didn't clean url request properly. (Closed)
Patch Set: Fixed compiling for unit tests. Created 3 years, 8 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/download_file_impl.cc
diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc
index f65534b2c0783a97d5f587a70711d2d625077644..a4a150681a555b0ffdb9b15815497a8444297c9b 100644
--- a/content/browser/download/download_file_impl.cc
+++ b/content/browser/download/download_file_impl.cc
@@ -328,6 +328,8 @@ void DownloadFileImpl::RenameWithRetryInternal(
SendUpdate();
// Null out callback so that we don't do any more stream processing.
+ // The request that writes to the pipe should be canceled after
+ // download interrupted.
for (auto& stream : source_streams_) {
ByteStreamReader* stream_reader = stream.second->stream_reader();
if (stream_reader)
@@ -469,6 +471,7 @@ void DownloadFileImpl::StreamActive(SourceStream* source_stream) {
// Signal successful completion or termination of the current stream.
source_stream->stream_reader()->RegisterCallback(base::Closure());
source_stream->set_finished(true);
+ streams_to_close_.emplace(source_stream->offset());
if (source_stream->length() == DownloadSaveInfo::kLengthFullContent) {
SetPotentialFileLength(source_stream->offset() +
source_stream->bytes_written());
@@ -533,7 +536,8 @@ void DownloadFileImpl::SendUpdate() {
BrowserThread::UI, FROM_HERE,
base::Bind(&DownloadDestinationObserver::DestinationUpdate, observer_,
TotalBytesReceived(), rate_estimator_.GetCountPerSecond(),
- received_slices_));
+ received_slices_, streams_to_close_));
+ streams_to_close_.clear();
}
void DownloadFileImpl::WillWriteToDisk(size_t data_len) {
@@ -641,6 +645,7 @@ void DownloadFileImpl::HandleStreamError(SourceStream* source_stream,
DCHECK_EQ(stream.second->bytes_written(), 0);
stream.second->stream_reader()->RegisterCallback(base::Closure());
stream.second->set_finished(true);
+ streams_to_close_.emplace(stream.second->offset());
num_active_streams_--;
}
}

Powered by Google App Engine
This is Rietveld 408576698