diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 01:07:43 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 01:07:43 +0000 |
commit | 6065748f99f48c4cc0d34600b7cc3c2de8d1c0e4 (patch) | |
tree | c3b3867b996821cc5ff1a029492c8d161b11f8f2 /content/browser/download | |
parent | 7a6900e7775c094f61970a2c4c93c1ec8f933ca0 (diff) | |
download | chromium_src-6065748f99f48c4cc0d34600b7cc3c2de8d1c0e4.zip chromium_src-6065748f99f48c4cc0d34600b7cc3c2de8d1c0e4.tar.gz chromium_src-6065748f99f48c4cc0d34600b7cc3c2de8d1c0e4.tar.bz2 |
Downloads: Avoid some redundant map lookups in DownloadMangerImpl.
Review URL: https://codereview.chromium.org/41553003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231469 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download')
-rw-r--r-- | content/browser/download/download_manager_impl.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index c80a2d0..36967c5 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -71,7 +71,7 @@ void BeginDownload(scoped_ptr<DownloadUrlParameters> params, // to do a re-POST without user consent, and currently don't have a good // plan on how to display the UI for that. DCHECK(params->prefer_cache()); - DCHECK(params->method() == "POST"); + DCHECK_EQ("POST", params->method()); ScopedVector<net::UploadElementReader> element_readers; request->set_upload(make_scoped_ptr( new net::UploadDataStream(element_readers.Pass(), params->post_id()))); @@ -108,7 +108,7 @@ void BeginDownload(scoped_ptr<DownloadUrlParameters> params, iter != params->request_headers_end(); ++iter) { request->SetExtraRequestHeaderByName( - iter->first, iter->second, false/*overwrite*/); + iter->first, iter->second, false /*overwrite*/); } scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); @@ -561,11 +561,9 @@ void DownloadManagerImpl::DownloadRemoved(DownloadItemImpl* download) { return; uint32 download_id = download->GetId(); - if (downloads_.find(download_id) == downloads_.end()) + if (downloads_.erase(download_id) == 0) return; - delete download; - downloads_.erase(download_id); } int DownloadManagerImpl::RemoveDownloadsBetween(base::Time remove_begin, @@ -605,7 +603,7 @@ void DownloadManagerImpl::DownloadUrl( if (params->post_id() >= 0) { // Check this here so that the traceback is more useful. DCHECK(params->prefer_cache()); - DCHECK(params->method() == "POST"); + DCHECK_EQ("POST", params->method()); } BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( &BeginDownload, base::Passed(¶ms), @@ -636,9 +634,10 @@ DownloadItem* DownloadManagerImpl::CreateDownloadItem( DownloadDangerType danger_type, DownloadInterruptReason interrupt_reason, bool opened) { - DCHECK(!ContainsKey(downloads_, id)); - if (ContainsKey(downloads_, id)) + if (ContainsKey(downloads_, id)) { + NOTREACHED(); return NULL; + } DownloadItemImpl* item = item_factory_->CreatePersistedItem( this, id, |