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

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

Issue 11150027: Handle the case where IAttachmentExecute::Save() deletes a downloaded file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Address comments + Update strings Created 8 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
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 01d0e8c40511ccc403ce94234f1ebe627f2d9059..f1bd1140328108d98201ba6f2323d2916a0c689a 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -100,7 +100,8 @@ class NullDownloadRequestHandle : public DownloadRequestHandleInterface {
// takes ownership of the DownloadFile and hence implicitly destroys it
// at the end of the function.
static void DownloadFileDetach(
- scoped_ptr<DownloadFile> download_file, base::Closure callback) {
+ scoped_ptr<DownloadFile> download_file,
+ const DownloadFile::DetachCompletionCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
download_file->Detach(callback);
}
@@ -827,7 +828,7 @@ void DownloadItemImpl::Interrupt(DownloadInterruptReason reason) {
// interrupts to race with cancels.
// Whatever happens, the first one to hit the UI thread wins.
- if (state_ != IN_PROGRESS_INTERNAL)
+ if (state_ != IN_PROGRESS_INTERNAL && state_ != COMPLETING_INTERNAL)
return;
last_reason_ = reason;
@@ -1179,7 +1180,7 @@ void DownloadItemImpl::ReadyForDownloadCompletionDone() {
if (is_save_package_download_) {
// Avoid doing anything on the file thread; there's nothing we control
// there.
- OnDownloadFileReleased();
+ OnDownloadFileReleased(DOWNLOAD_INTERRUPT_REASON_NONE);
return;
}
@@ -1246,7 +1247,11 @@ void DownloadItemImpl::ReleaseDownloadFile() {
TransitionTo(COMPLETING_INTERNAL);
}
-void DownloadItemImpl::OnDownloadFileReleased() {
+void DownloadItemImpl::OnDownloadFileReleased(DownloadInterruptReason reason) {
+ if (DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
+ Interrupt(reason);
+ return;
+ }
if (delegate_->ShouldOpenDownload(this))
Completed();
else
@@ -1290,8 +1295,9 @@ void DownloadItemImpl::Completed() {
void DownloadItemImpl::CancelDownloadFile() {
// TODO(rdsmith/benjhayden): Remove condition as part of
// SavePackage integration.
- if (!is_save_package_download_) {
- DCHECK(download_file_.get());
+ // download_file_ can be NULL if Interrupt() is called after the download file
+ // has been released.
+ if (!is_save_package_download_ && download_file_.get()) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
// Will be deleted at end of task execution.
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698