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

Side by Side Diff: content/browser/download/download_file_impl.cc

Issue 2881463003: Reduce unnecessary download interruptions due to parallel requests (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/download/download_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/download_file_impl.h" 5 #include "content/browser/download/download_file_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 AddNewSlice(source_stream->offset(), bytes_to_write); 434 AddNewSlice(source_stream->offset(), bytes_to_write);
435 } else { 435 } else {
436 received_slices_[source_stream->index()].received_bytes += 436 received_slices_[source_stream->index()].received_bytes +=
437 bytes_to_write; 437 bytes_to_write;
438 } 438 }
439 } 439 }
440 } 440 }
441 break; 441 break;
442 case ByteStreamReader::STREAM_COMPLETE: 442 case ByteStreamReader::STREAM_COMPLETE:
443 { 443 {
444 reason = static_cast<DownloadInterruptReason>( 444 reason = static_cast<DownloadInterruptReason>(
445 source_stream->stream_reader()->GetStatus()); 445 source_stream->stream_reader()->GetStatus());
446 SendUpdate(); 446 if (source_stream->length() == DownloadSaveInfo::kLengthFullContent &&
447 !received_slices_.empty() &&
448 (source_stream->offset() == received_slices_.back().offset +
449 received_slices_.back().received_bytes) &&
450 reason == DownloadInterruptReason::
451 DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE) {
452 // We are probably reaching the end of the stream, don't treat this
453 // as an error.
454 reason = DOWNLOAD_INTERRUPT_REASON_NONE;
455 }
456 SendUpdate();
447 } 457 }
448 break; 458 break;
449 default: 459 default:
450 NOTREACHED(); 460 NOTREACHED();
451 break; 461 break;
452 } 462 }
453 now = base::TimeTicks::Now(); 463 now = base::TimeTicks::Now();
454 } while (state == ByteStreamReader::STREAM_HAS_DATA && 464 } while (state == ByteStreamReader::STREAM_HAS_DATA &&
455 reason == DOWNLOAD_INTERRUPT_REASON_NONE && now - start <= delta && 465 reason == DOWNLOAD_INTERRUPT_REASON_NONE && now - start <= delta &&
456 !should_terminate); 466 !should_terminate);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 const base::FilePath& new_path, 726 const base::FilePath& new_path,
717 const RenameCompletionCallback& completion_callback) 727 const RenameCompletionCallback& completion_callback)
718 : option(option), 728 : option(option),
719 new_path(new_path), 729 new_path(new_path),
720 retries_left(kMaxRenameRetries), 730 retries_left(kMaxRenameRetries),
721 completion_callback(completion_callback) {} 731 completion_callback(completion_callback) {}
722 732
723 DownloadFileImpl::RenameParameters::~RenameParameters() {} 733 DownloadFileImpl::RenameParameters::~RenameParameters() {}
724 734
725 } // namespace content 735 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698