Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 10702151: Revert 146162 - Move Rename functionality from DownloadFileManager to DownloadFileImple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 make_scoped_refptr(this), 421 make_scoped_refptr(this),
422 GenerateFileHash(), bound_net_log, 422 GenerateFileHash(), bound_net_log,
423 callback)); 423 callback));
424 424
425 return download_id; 425 return download_id;
426 } 426 }
427 427
428 void DownloadManagerImpl::OnDownloadFileCreated( 428 void DownloadManagerImpl::OnDownloadFileCreated(
429 int32 download_id, content::DownloadInterruptReason reason) { 429 int32 download_id, content::DownloadInterruptReason reason) {
430 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) { 430 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) {
431 OnDownloadInterrupted(download_id, reason); 431 OnDownloadInterrupted(download_id, 0, "", reason);
432 // TODO(rdsmith): It makes no sense to continue along the 432 // TODO(rdsmith): It makes no sense to continue along the
433 // regular download path after we've gotten an error. But it's 433 // regular download path after we've gotten an error. But it's
434 // the way the code has historically worked, and this allows us 434 // the way the code has historically worked, and this allows us
435 // to get the download persisted and observers of the download manager 435 // to get the download persisted and observers of the download manager
436 // notified, so tests work. When we execute all side effects of cancel 436 // notified, so tests work. When we execute all side effects of cancel
437 // (including queue removal) immedately rather than waiting for 437 // (including queue removal) immedately rather than waiting for
438 // persistence we should replace this comment with a "return;". 438 // persistence we should replace this comment with a "return;".
439 } 439 }
440 440
441 if (!delegate_ || delegate_->ShouldStartDownload(download_id)) 441 if (!delegate_ || delegate_->ShouldStartDownload(download_id))
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 // This function is called from the DownloadItem, so DI state 764 // This function is called from the DownloadItem, so DI state
765 // should already have been updated. 765 // should already have been updated.
766 AssertStateConsistent(download); 766 AssertStateConsistent(download);
767 767
768 DCHECK(file_manager_); 768 DCHECK(file_manager_);
769 download->OffThreadCancel(file_manager_); 769 download->OffThreadCancel(file_manager_);
770 } 770 }
771 771
772 void DownloadManagerImpl::OnDownloadInterrupted( 772 void DownloadManagerImpl::OnDownloadInterrupted(
773 int32 download_id, 773 int32 download_id,
774 int64 size,
775 const std::string& hash_state,
774 content::DownloadInterruptReason reason) { 776 content::DownloadInterruptReason reason) {
775 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 777 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
776 778
777 DownloadItem* download = GetActiveDownload(download_id); 779 DownloadItem* download = GetActiveDownload(download_id);
778 if (!download) 780 if (!download)
779 return; 781 return;
782 download->UpdateProgress(size, 0, hash_state);
780 download->Interrupt(reason); 783 download->Interrupt(reason);
781 } 784 }
782 785
783 DownloadItem* DownloadManagerImpl::GetActiveDownload(int32 download_id) { 786 DownloadItem* DownloadManagerImpl::GetActiveDownload(int32 download_id) {
784 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 787 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
785 DownloadMap::iterator it = active_downloads_.find(download_id); 788 DownloadMap::iterator it = active_downloads_.find(download_id);
786 if (it == active_downloads_.end()) 789 if (it == active_downloads_.end())
787 return NULL; 790 return NULL;
788 791
789 DownloadItem* download = it->second; 792 DownloadItem* download = it->second;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 void DownloadManagerImpl::DownloadRenamedToFinalName( 1186 void DownloadManagerImpl::DownloadRenamedToFinalName(
1184 DownloadItem* download) { 1187 DownloadItem* download) {
1185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1186 // If the rename failed, we receive an OnDownloadInterrupted() call before we 1189 // If the rename failed, we receive an OnDownloadInterrupted() call before we
1187 // receive the DownloadRenamedToFinalName() call. 1190 // receive the DownloadRenamedToFinalName() call.
1188 if (delegate_) { 1191 if (delegate_) {
1189 delegate_->UpdatePathForItemInPersistentStore( 1192 delegate_->UpdatePathForItemInPersistentStore(
1190 download, download->GetFullPath()); 1193 download, download->GetFullPath());
1191 } 1194 }
1192 } 1195 }
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698