| 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 e4ec806f7718c8b4de357eb9977f329a852834a7..88eb1f5ab3e8b68cdc345626197bab6c6a58d7e7 100644
|
| --- a/content/browser/download/download_file_impl.cc
|
| +++ b/content/browser/download/download_file_impl.cc
|
| @@ -120,7 +120,7 @@ void DownloadFileImpl::Initialize(const InitializeCallback& callback) {
|
| // Primarily to make reset to zero in restart visible to owner.
|
| SendUpdate();
|
|
|
| - // Initial pull from the straw.
|
| + // Initial pull from the straw from all source streams.
|
| for (auto& source_stream : source_streams_)
|
| RegisterAndActivateStream(source_stream.second.get());
|
|
|
| @@ -131,16 +131,18 @@ void DownloadFileImpl::Initialize(const InitializeCallback& callback) {
|
|
|
| void DownloadFileImpl::AddByteStream(
|
| std::unique_ptr<ByteStreamReader> stream_reader,
|
| - int64_t offset) {
|
| + int64_t offset,
|
| + int64_t length) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
| + DCHECK(source_streams_.find(offset) == source_streams_.end());
|
|
|
| - // The |source_streams_| must have an existing entry for the stream reader.
|
| - auto current_source_stream = source_streams_.find(offset);
|
| - DCHECK(current_source_stream != source_streams_.end());
|
| - SourceStream* stream = current_source_stream->second.get();
|
| + source_streams_[offset] = base::MakeUnique<SourceStream>(offset, length);
|
| + SourceStream* stream = source_streams_[offset].get();
|
| stream->SetByteStream(std::move(stream_reader));
|
|
|
| - RegisterAndActivateStream(stream);
|
| + // If the file is initialized, start to write data, or wait until file opened.
|
| + if (file_.in_progress())
|
| + RegisterAndActivateStream(stream);
|
| }
|
|
|
| DownloadInterruptReason DownloadFileImpl::WriteDataToFile(int64_t offset,
|
|
|