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

Unified Diff: content/browser/download/download_manager_impl.cc

Issue 41553003: Downloads: Avoid some redundant map lookups in DownloadMangerImpl. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_manager_impl.cc
===================================================================
--- content/browser/download/download_manager_impl.cc (revision 231124)
+++ content/browser/download/download_manager_impl.cc (working copy)
@@ -71,7 +71,7 @@
// 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 @@
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 @@
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 @@
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(&params),
@@ -636,9 +634,10 @@
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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698