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_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 make_scoped_refptr(this), | 401 make_scoped_refptr(this), |
402 GenerateFileHash(), bound_net_log, | 402 GenerateFileHash(), bound_net_log, |
403 callback)); | 403 callback)); |
404 | 404 |
405 return download_id; | 405 return download_id; |
406 } | 406 } |
407 | 407 |
408 void DownloadManagerImpl::OnDownloadFileCreated( | 408 void DownloadManagerImpl::OnDownloadFileCreated( |
409 int32 download_id, content::DownloadInterruptReason reason) { | 409 int32 download_id, content::DownloadInterruptReason reason) { |
410 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) { | 410 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) { |
411 OnDownloadInterrupted(download_id, 0, "", reason); | 411 OnDownloadInterrupted(download_id, reason); |
412 // TODO(rdsmith): It makes no sense to continue along the | 412 // TODO(rdsmith): It makes no sense to continue along the |
413 // regular download path after we've gotten an error. But it's | 413 // regular download path after we've gotten an error. But it's |
414 // the way the code has historically worked, and this allows us | 414 // the way the code has historically worked, and this allows us |
415 // to get the download persisted and observers of the download manager | 415 // to get the download persisted and observers of the download manager |
416 // notified, so tests work. When we execute all side effects of cancel | 416 // notified, so tests work. When we execute all side effects of cancel |
417 // (including queue removal) immedately rather than waiting for | 417 // (including queue removal) immedately rather than waiting for |
418 // persistence we should replace this comment with a "return;". | 418 // persistence we should replace this comment with a "return;". |
419 } | 419 } |
420 | 420 |
421 if (!delegate_ || delegate_->ShouldStartDownload(download_id)) | 421 if (!delegate_ || delegate_->ShouldStartDownload(download_id)) |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // This function is called from the DownloadItem, so DI state | 743 // This function is called from the DownloadItem, so DI state |
744 // should already have been updated. | 744 // should already have been updated. |
745 AssertStateConsistent(download); | 745 AssertStateConsistent(download); |
746 | 746 |
747 DCHECK(file_manager_); | 747 DCHECK(file_manager_); |
748 download->OffThreadCancel(file_manager_); | 748 download->OffThreadCancel(file_manager_); |
749 } | 749 } |
750 | 750 |
751 void DownloadManagerImpl::OnDownloadInterrupted( | 751 void DownloadManagerImpl::OnDownloadInterrupted( |
752 int32 download_id, | 752 int32 download_id, |
753 int64 size, | |
754 const std::string& hash_state, | |
755 content::DownloadInterruptReason reason) { | 753 content::DownloadInterruptReason reason) { |
756 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 754 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
757 | 755 |
758 DownloadItem* download = GetActiveDownload(download_id); | 756 DownloadItem* download = GetActiveDownload(download_id); |
759 if (!download) | 757 if (!download) |
760 return; | 758 return; |
761 download->UpdateProgress(size, 0, hash_state); | |
762 download->Interrupt(reason); | 759 download->Interrupt(reason); |
763 } | 760 } |
764 | 761 |
765 DownloadItem* DownloadManagerImpl::GetActiveDownload(int32 download_id) { | 762 DownloadItem* DownloadManagerImpl::GetActiveDownload(int32 download_id) { |
766 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 763 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
767 DownloadMap::iterator it = active_downloads_.find(download_id); | 764 DownloadMap::iterator it = active_downloads_.find(download_id); |
768 if (it == active_downloads_.end()) | 765 if (it == active_downloads_.end()) |
769 return NULL; | 766 return NULL; |
770 | 767 |
771 DownloadItem* download = it->second; | 768 DownloadItem* download = it->second; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 void DownloadManagerImpl::DownloadRenamedToFinalName( | 1182 void DownloadManagerImpl::DownloadRenamedToFinalName( |
1186 DownloadItem* download) { | 1183 DownloadItem* download) { |
1187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1188 // If the rename failed, we receive an OnDownloadInterrupted() call before we | 1185 // If the rename failed, we receive an OnDownloadInterrupted() call before we |
1189 // receive the DownloadRenamedToFinalName() call. | 1186 // receive the DownloadRenamedToFinalName() call. |
1190 if (delegate_) { | 1187 if (delegate_) { |
1191 delegate_->UpdatePathForItemInPersistentStore( | 1188 delegate_->UpdatePathForItemInPersistentStore( |
1192 download, download->GetFullPath()); | 1189 download, download->GetFullPath()); |
1193 } | 1190 } |
1194 } | 1191 } |
OLD | NEW |