Index: content/browser/download/download_manager_impl.cc |
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc |
index 3fa90438b7db8c1af0c9fc03f3f253fddd3c644e..3e970bd16fd5ad344b037c2bd4779a39217c70ed 100644 |
--- a/content/browser/download/download_manager_impl.cc |
+++ b/content/browser/download/download_manager_impl.cc |
@@ -247,14 +247,6 @@ DownloadManagerImpl::~DownloadManagerImpl() { |
DCHECK(!shutdown_needed_); |
} |
-void DownloadManagerImpl::CreateActiveItem( |
- DownloadId id, const DownloadCreateInfo& info) { |
- net::BoundNetLog bound_net_log = |
- net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); |
- downloads_[id.local()] = |
- item_factory_->CreateActiveItem(this, id, info, bound_net_log); |
-} |
- |
DownloadId DownloadManagerImpl::GetNextId() { |
DownloadId id; |
if (delegate_) |
@@ -377,6 +369,28 @@ DownloadItem* DownloadManagerImpl::StartDownload( |
scoped_ptr<ByteStreamReader> stream) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ DownloadId id(info->download_id); |
+ bool new_download = !id.IsValid(); |
+ DownloadItemImpl* download = NULL; |
+ |
+ if (new_download) { |
+ id = GetNextId(); |
+ net::BoundNetLog bound_net_log = |
+ net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD); |
+ download = item_factory_->CreateActiveItem(this, id, *info, bound_net_log); |
+ downloads_[id.local()] = download; |
+ } else { |
+ // Trying to resume an interrupted download. |
+ if (!ContainsKey(downloads_, id.local())) { |
+ // If the download is no longer known to the DownloadManager, then it was |
+ // removed after it was resumed. Ignore. |
+ info->request_handle.CancelRequest(); |
+ return NULL; |
+ } |
+ download = downloads_[id.local()]; |
Randy Smith (Not in Mondays)
2013/05/13 15:59:26
I'm tempted to suggest you explicitly look up the
asanka
2013/05/13 19:19:01
Done.
|
+ DCHECK(download->IsInterrupted()); |
+ } |
+ |
base::FilePath default_download_directory; |
if (delegate_) { |
base::FilePath website_save_directory; // Unused |
@@ -385,20 +399,6 @@ DownloadItem* DownloadManagerImpl::StartDownload( |
&default_download_directory, &skip_dir_check); |
} |
- // If we don't have a valid id, that's a signal to generate one. |
- DownloadId id(info->download_id); |
- if (!id.IsValid()) |
- id = GetNextId(); |
- |
- // Create a new download item if this isn't a resumption. |
- bool new_download(!ContainsKey(downloads_, id.local())); |
- if (new_download) |
- CreateActiveItem(id, *info); |
- |
- DownloadItemImpl* download(downloads_[id.local()]); |
- DCHECK(download); |
- DCHECK(new_download || download->IsInterrupted()); |
- |
// Create the download file and start the download. |
scoped_ptr<DownloadFile> download_file( |
file_factory_->CreateFile( |