summaryrefslogtreecommitdiffstats
path: root/content/browser/download/download_file_manager.cc
diff options
context:
space:
mode:
authorahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-25 07:11:22 +0000
committerahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-25 07:11:22 +0000
commitb3c528aebd22c9162d17799205a8aa82061e2bf2 (patch)
tree954e3c00e2f15c4d15c73599d0a98f6bcb97c103 /content/browser/download/download_file_manager.cc
parenta0c136a0c23998b4a66679d1d8883ee057ef5060 (diff)
downloadchromium_src-b3c528aebd22c9162d17799205a8aa82061e2bf2.zip
chromium_src-b3c528aebd22c9162d17799205a8aa82061e2bf2.tar.gz
chromium_src-b3c528aebd22c9162d17799205a8aa82061e2bf2.tar.bz2
Fixed issues with interrupting a download at the start.
Added unit tests for direct and navigated download 404 errors. BUG= 114020 TEST=Set up a server with a web page that has an invalid link. Right click on the link and select Save As to download the file. Review URL: http://codereview.chromium.org/9378035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download/download_file_manager.cc')
-rw-r--r--content/browser/download/download_file_manager.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/content/browser/download/download_file_manager.cc b/content/browser/download/download_file_manager.cc
index a0a6c46..d6168e4 100644
--- a/content/browser/download/download_file_manager.cc
+++ b/content/browser/download/download_file_manager.cc
@@ -99,20 +99,33 @@ void DownloadFileManager::CreateDownloadFile(
// Life of |info| ends here. No more references to it after this method.
scoped_ptr<DownloadCreateInfo> infop(info);
+ // Create the download file.
scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile(
info, request_handle, download_manager, get_hash, bound_net_log));
- if (net::OK != download_file->Initialize()) {
- request_handle.CancelRequest();
- return;
- }
- DCHECK(GetDownloadFile(info->download_id) == NULL);
- downloads_[info->download_id] = download_file.release();
+ net::Error init_result = download_file->Initialize();
+ if (net::OK != init_result) {
+ // Error: Handle via download manager/item.
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(
+ &DownloadManager::OnDownloadInterrupted,
+ download_manager,
+ info->download_id.local(),
+ 0,
+ "",
+ ConvertNetErrorToInterruptReason(init_result,
+ DOWNLOAD_INTERRUPT_FROM_DISK)));
+ } else {
+ DCHECK(GetDownloadFile(info->download_id) == NULL);
+ downloads_[info->download_id] = download_file.release();
- // The file is now ready, we can un-pause the request and start saving data.
- request_handle.ResumeRequest();
+ // The file is now ready, we can un-pause the request and start saving data.
+ request_handle.ResumeRequest();
- StartUpdateTimer();
+ StartUpdateTimer();
+ }
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,