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