| 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 27c170796605127ddb40b24c0507a9dbc4d82c06..5c3620fa3e401210b4b1b134ca2fa6d98669c1bb 100644
|
| --- a/content/browser/download/download_item_impl.cc
|
| +++ b/content/browser/download/download_item_impl.cc
|
| @@ -68,9 +68,12 @@ void DeleteDownloadedFile(const base::FilePath& path) {
|
| // Wrapper around DownloadFile::Detach and DownloadFile::Cancel that
|
| // takes ownership of the DownloadFile and hence implicitly destroys it
|
| // at the end of the function.
|
| -static void DownloadFileDetach(scoped_ptr<DownloadFile> download_file) {
|
| +static base::FilePath DownloadFileDetach(
|
| + scoped_ptr<DownloadFile> download_file) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| + base::FilePath full_path = download_file->FullPath();
|
| download_file->Detach();
|
| + return full_path;
|
| }
|
|
|
| static void DownloadFileCancel(scoped_ptr<DownloadFile> download_file) {
|
| @@ -275,7 +278,7 @@ void DownloadItemImpl::UpdateObservers() {
|
| FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this));
|
| }
|
|
|
| -void DownloadItemImpl::DangerousDownloadValidated() {
|
| +void DownloadItemImpl::ValidateDangerousDownload() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| DCHECK_EQ(IN_PROGRESS, GetState());
|
| DCHECK(IsDangerous());
|
| @@ -372,9 +375,12 @@ void DownloadItemImpl::Cancel(bool user_cancel) {
|
| TransitionTo(CANCELLED_INTERNAL);
|
| }
|
|
|
| -void DownloadItemImpl::Delete(DeleteReason reason) {
|
| +void DownloadItemImpl::DiscardDangerousDownload(
|
| + DeleteReason reason,
|
| + const AcquireFileCallback& callback) {
|
| VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true);
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + DCHECK(IsDangerous());
|
|
|
| switch (reason) {
|
| case DELETE_DUE_TO_USER_DISCARD:
|
| @@ -391,6 +397,19 @@ void DownloadItemImpl::Delete(DeleteReason reason) {
|
| NOTREACHED();
|
| }
|
|
|
| + if (!callback.is_null()) {
|
| + if (download_file_) {
|
| + BrowserThread::PostTaskAndReplyWithResult(
|
| + BrowserThread::FILE,
|
| + FROM_HERE,
|
| + base::Bind(&DownloadFileDetach, base::Passed(&download_file_)),
|
| + callback);
|
| + } else {
|
| + callback.Run(current_path_);
|
| + }
|
| + current_path_.clear();
|
| + }
|
| +
|
| // Delete the file if it exists and is not owned by a DownloadFile object.
|
| // (In the latter case the DownloadFile object will delete it on cancel.)
|
| if (!current_path_.empty() && download_file_.get() == NULL) {
|
| @@ -1405,10 +1424,11 @@ void DownloadItemImpl::ReleaseDownloadFile(bool destroy_file) {
|
| // current_path_.
|
| current_path_.clear();
|
| } else {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::FILE, FROM_HERE,
|
| - // Will be deleted at end of task execution.
|
| - base::Bind(&DownloadFileDetach, base::Passed(&download_file_)));
|
| + BrowserThread::PostTask(BrowserThread::FILE,
|
| + FROM_HERE,
|
| + // Will be deleted at end of task execution.
|
| + base::Bind(base::IgnoreResult(&DownloadFileDetach),
|
| + base::Passed(&download_file_)));
|
| }
|
| // Don't accept any more messages from the DownloadFile, and null
|
| // out any previous "all data received". This also breaks links to
|
|
|