| OLD | NEW |
| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 base::Bind(&DownloadDestinationObserver::DestinationError, observer_, | 360 base::Bind(&DownloadDestinationObserver::DestinationError, observer_, |
| 361 reason, TotalBytesReceived(), base::Passed(&hash_state))); | 361 reason, TotalBytesReceived(), base::Passed(&hash_state))); |
| 362 } else if (state == ByteStreamReader::STREAM_COMPLETE || should_terminate) { | 362 } else if (state == ByteStreamReader::STREAM_COMPLETE || should_terminate) { |
| 363 // Signal successful completion or termination of the current stream. | 363 // Signal successful completion or termination of the current stream. |
| 364 source_stream->stream_reader()->RegisterCallback(base::Closure()); | 364 source_stream->stream_reader()->RegisterCallback(base::Closure()); |
| 365 source_stream->set_finished(true); | 365 source_stream->set_finished(true); |
| 366 | 366 |
| 367 // Inform observers. | 367 // Inform observers. |
| 368 SendUpdate(); | 368 SendUpdate(); |
| 369 | 369 |
| 370 // TODO(xingliu): Use slice info to determine if the file is fully |
| 371 // downloaded. |
| 370 bool all_stream_complete = true; | 372 bool all_stream_complete = true; |
| 371 for (auto& stream : source_streams_) { | 373 for (auto& stream : source_streams_) { |
| 372 if (!stream.second->is_finished()) { | 374 if (!stream.second->is_finished()) { |
| 373 all_stream_complete = false; | 375 all_stream_complete = false; |
| 374 break; | 376 break; |
| 375 } | 377 } |
| 376 } | 378 } |
| 377 | 379 |
| 378 // All the stream reader are completed, shut down file IO processing. | 380 // All the stream reader are completed, shut down file IO processing. |
| 379 if (all_stream_complete) { | 381 if (all_stream_complete) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 const base::FilePath& new_path, | 438 const base::FilePath& new_path, |
| 437 const RenameCompletionCallback& completion_callback) | 439 const RenameCompletionCallback& completion_callback) |
| 438 : option(option), | 440 : option(option), |
| 439 new_path(new_path), | 441 new_path(new_path), |
| 440 retries_left(kMaxRenameRetries), | 442 retries_left(kMaxRenameRetries), |
| 441 completion_callback(completion_callback) {} | 443 completion_callback(completion_callback) {} |
| 442 | 444 |
| 443 DownloadFileImpl::RenameParameters::~RenameParameters() {} | 445 DownloadFileImpl::RenameParameters::~RenameParameters() {} |
| 444 | 446 |
| 445 } // namespace content | 447 } // namespace content |
| OLD | NEW |