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

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

Issue 2861443005: Clear callback when a parallel request can no longer write any data (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | content/browser/download/download_file_unittest.cc » ('j') | 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 dd2cb8578dd13fa15b00e9327421e4082dc2395b..cbba3aaf097089b3486b80e25c3fcd5c4022427a 100644
--- a/content/browser/download/download_file_impl.cc
+++ b/content/browser/download/download_file_impl.cc
@@ -407,6 +407,7 @@ void DownloadFileImpl::StreamActive(SourceStream* source_stream) {
switch (state) {
case ByteStreamReader::STREAM_EMPTY:
+ should_terminate = (source_stream->length() == kNoBytesToWrite);
break;
case ByteStreamReader::STREAM_HAS_DATA:
{
@@ -526,8 +527,8 @@ void DownloadFileImpl::RegisterAndActivateStream(SourceStream* source_stream) {
source_stream->TruncateLengthWithWrittenDataBlock(
received_slice.offset, received_slice.received_bytes);
}
- StreamActive(source_stream);
num_active_streams_++;
+ StreamActive(source_stream);
}
}
@@ -610,9 +611,9 @@ void DownloadFileImpl::HandleStreamError(SourceStream* source_stream,
source_stream->set_finished(true);
num_active_streams_--;
- bool can_recover_from_error = false;
+ bool can_recover_from_error = (source_stream->length() == kNoBytesToWrite);
- if (IsSparseFile() && source_stream->length() != kNoBytesToWrite) {
+ if (IsSparseFile() && !can_recover_from_error) {
// If a neighboring stream request is available, check if it can help
// download all the data left by |source stream| or has already done so. We
// want to avoid the situation that a server always fail additional requests
« no previous file with comments | « no previous file | content/browser/download/download_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698