| 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 dfb915e4dbd54610fdc58882ad77a39c34dfbd97..5e98b3b5aef392c792ebdd361a16e0812fff5ea2 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) {
|
| @@ -388,6 +391,22 @@ void DownloadItemImpl::Delete(DeleteReason reason) {
|
| // We have now been deleted.
|
| }
|
|
|
| +void DownloadItemImpl::AcquireFileAndDeleteDownload(
|
| + const AcquireFileCallback& callback) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + 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(DELETE_DUE_TO_USER_DISCARD);
|
| +}
|
| +
|
| void DownloadItemImpl::Remove() {
|
| VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true);
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| @@ -1441,7 +1460,8 @@ void DownloadItemImpl::ReleaseDownloadFile(bool destroy_file) {
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| // Will be deleted at end of task execution.
|
| - base::Bind(&DownloadFileDetach, base::Passed(&download_file_)));
|
| + 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
|
|
|