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