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

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

Issue 10263019: DownloadManagerDelegate::ShouldCompleteDownload(callback) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 8 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
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 9bdb48aa7bfbe2382d1e3b34056dbf0f6c79d308..22b4ea4416781811b6f36ce25a4a641e0e6ea991 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -639,7 +639,12 @@ void DownloadManagerImpl::MaybeCompleteDownload(DownloadItem* download) {
DCHECK_EQ(1u, history_downloads_.count(download->GetDbHandle()));
// Give the delegate a chance to override.
- if (!delegate_->ShouldCompleteDownload(download))
+ // It's ok to keep re-setting the delegate's |maybe_complete_download| cb as
+ // long as there isn't another call-point trying to set it to a different cb.
+ // TODO(benjhayden): Change the callback to point directly to the item instead
+ // of |this| when DownloadItem supports weak-ptrs.
+ if (!delegate_->ShouldCompleteDownload(download, base::Bind(
+ &DownloadManagerImpl::MaybeCompleteDownload, this, download)))
asanka 2012/05/01 15:54:10 The download item could go away before the callbac
benjhayden 2012/05/01 18:02:52 Done.
return;
VLOG(20) << __FUNCTION__ << "()" << " executing: download = "

Powered by Google App Engine
This is Rietveld 408576698