| 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 3c9521d314180cf38803328d6e5e1da5d7dda4e0..7b92c69fc0dc9bce19d3d6cda9907ef124d29126 100644
|
| --- a/content/browser/download/download_item_impl.cc
|
| +++ b/content/browser/download/download_item_impl.cc
|
| @@ -867,21 +867,35 @@ DownloadItem::TargetDisposition DownloadItemImpl::GetTargetDisposition() const {
|
| return target_disposition_;
|
| }
|
|
|
| -void DownloadItemImpl::OnTargetPathDetermined(
|
| +void DownloadItemImpl::OnDownloadTargetDetermined(
|
| const FilePath& target_path,
|
| TargetDisposition disposition,
|
| - content::DownloadDangerType danger_type) {
|
| + content::DownloadDangerType danger_type,
|
| + const FilePath& intermediate_path) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| target_path_ = target_path;
|
| target_disposition_ = disposition;
|
| SetDangerType(danger_type);
|
| -}
|
|
|
| -void DownloadItemImpl::OnTargetPathSelected(const FilePath& target_path) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - DCHECK_EQ(TARGET_DISPOSITION_PROMPT, target_disposition_);
|
| - target_path_ = target_path;
|
| + // We want the intermediate and target paths to refer to the same directory so
|
| + // that they are both on the same device and subject to same
|
| + // space/permission/availability constraints.
|
| + DCHECK(intermediate_path.DirName() == target_path.DirName());
|
| +
|
| + // Rename to intermediate name.
|
| + // TODO(asanka): Skip this rename if AllDataSaved() is true. This avoids a
|
| + // spurious rename when we can just rename to the final
|
| + // filename. Unnecessary renames may cause bugs like
|
| + // http://crbug.com/74187.
|
| + DownloadFileManager::RenameCompletionCallback callback =
|
| + base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName,
|
| + weak_ptr_factory_.GetWeakPtr());
|
| + BrowserThread::PostTask(
|
| + BrowserThread::FILE, FROM_HERE,
|
| + base::Bind(&DownloadFileManager::RenameDownloadFile,
|
| + delegate_->GetDownloadFileManager(), GetGlobalId(),
|
| + intermediate_path, false, callback));
|
| }
|
|
|
| void DownloadItemImpl::OnContentCheckCompleted(
|
| @@ -892,19 +906,6 @@ void DownloadItemImpl::OnContentCheckCompleted(
|
| SetDangerType(danger_type);
|
| }
|
|
|
| -void DownloadItemImpl::OnIntermediatePathDetermined(
|
| - DownloadFileManager* file_manager,
|
| - const FilePath& intermediate_path) {
|
| - DownloadFileManager::RenameCompletionCallback callback =
|
| - base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName,
|
| - weak_ptr_factory_.GetWeakPtr());
|
| - BrowserThread::PostTask(
|
| - BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(&DownloadFileManager::RenameDownloadFile,
|
| - file_manager, GetGlobalId(), intermediate_path,
|
| - false, callback));
|
| -}
|
| -
|
| const FilePath& DownloadItemImpl::GetFullPath() const {
|
| return current_path_;
|
| }
|
|
|