| 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..5dc5aa17b59f3220bc75a47090b8335bd226c7f9 100644
|
| --- a/content/browser/download/download_manager_impl.cc
|
| +++ b/content/browser/download/download_manager_impl.cc
|
| @@ -247,12 +247,14 @@ DownloadManagerImpl::~DownloadManagerImpl() {
|
| DCHECK(!shutdown_needed_);
|
| }
|
|
|
| -void DownloadManagerImpl::CreateActiveItem(
|
| +DownloadItemImpl* DownloadManagerImpl::CreateActiveItem(
|
| DownloadId id, const DownloadCreateInfo& info) {
|
| net::BoundNetLog bound_net_log =
|
| net::BoundNetLog::Make(net_log_, net::NetLog::SOURCE_DOWNLOAD);
|
| - downloads_[id.local()] =
|
| + DownloadItemImpl* download =
|
| item_factory_->CreateActiveItem(this, id, info, bound_net_log);
|
| + downloads_[id.local()] = download;
|
| + return download;
|
| }
|
|
|
| DownloadId DownloadManagerImpl::GetNextId() {
|
| @@ -377,6 +379,26 @@ DownloadItem* DownloadManagerImpl::StartDownload(
|
| scoped_ptr<ByteStreamReader> stream) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| + DownloadId id(info->download_id);
|
| + const bool new_download = !id.IsValid();
|
| + DownloadItemImpl* download = NULL;
|
| +
|
| + if (new_download) {
|
| + id = GetNextId();
|
| + download = CreateActiveItem(id, *info);
|
| + } else {
|
| + DownloadMap::iterator item_iterator = downloads_.find(id.local());
|
| + // Trying to resume an interrupted download.
|
| + if (item_iterator == downloads_.end()) {
|
| + // 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 = item_iterator->second;
|
| + DCHECK(download->IsInterrupted());
|
| + }
|
| +
|
| base::FilePath default_download_directory;
|
| if (delegate_) {
|
| base::FilePath website_save_directory; // Unused
|
| @@ -385,20 +407,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(
|
|
|