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

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

Issue 11740026: Pull delegate check back into IsDownloadReadyForCompletion so that if (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed test. Created 7 years, 12 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_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index e2313415bed14f93b9d3fb2a09bf667cb6b0ef6d..6e53782c292c2e1f9facf71c4555318bf558172f 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -1062,7 +1062,9 @@ void DownloadItemImpl::MaybeCompleteDownload() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!is_save_package_download_);
- if (!IsDownloadReadyForCompletion())
+ if (!IsDownloadReadyForCompletion(
+ base::Bind(&DownloadItemImpl::MaybeCompleteDownload,
+ weak_ptr_factory_.GetWeakPtr())))
return;
// TODO(rdsmith): DCHECK that we only pass through this point
@@ -1086,16 +1088,6 @@ void DownloadItemImpl::OnDownloadCompleting() {
if (state_ != IN_PROGRESS_INTERNAL)
return;
- // Give the delegate a chance to override.
- delegate_->ReadyForDownloadCompletion(
- this, base::Bind(&DownloadItemImpl::ReadyForDownloadCompletionDone,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void DownloadItemImpl::ReadyForDownloadCompletionDone() {
- if (state_ != IN_PROGRESS_INTERNAL)
- return;
-
VLOG(20) << __FUNCTION__ << "()"
<< " " << DebugString(true);
DCHECK(!GetTargetFilePath().empty());
@@ -1247,12 +1239,8 @@ void DownloadItemImpl::CancelDownloadFile() {
}
}
-bool DownloadItemImpl::IsDownloadReadyForCompletion() {
- VLOG(20) << __FUNCTION__ << " " << AllDataSaved()
- << " " << (GetSafetyState() != DownloadItem::DANGEROUS)
- << " " << (state_ == IN_PROGRESS_INTERNAL)
- << " " << !GetTargetFilePath().empty()
- << " " << (target_path_.DirName() == current_path_.DirName());
+bool DownloadItemImpl::IsDownloadReadyForCompletion(
+ const base::Closure& state_change_notification) {
// If we don't have all the data, the download is not ready for
// completion.
if (!AllDataSaved())
@@ -1278,6 +1266,11 @@ bool DownloadItemImpl::IsDownloadReadyForCompletion() {
if (target_path_.DirName() != current_path_.DirName())
return false;
+ // Give the delegate a chance to hold up a stop sign. It'll call
+ // use back through the passed callback if it does and that state changes.
+ if (!delegate_->ShouldCompleteDownload(this, state_change_notification))
+ return false;
+
return true;
}
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698