| Index: content/browser/download/download_file_manager.cc
|
| diff --git a/content/browser/download/download_file_manager.cc b/content/browser/download/download_file_manager.cc
|
| index e6ecc9f81d49118e9e0b8301cba279c05d6eae05..84a7e1459b20a7a5fb9181283d0fddd31f5fbc3a 100644
|
| --- a/content/browser/download/download_file_manager.cc
|
| +++ b/content/browser/download/download_file_manager.cc
|
| @@ -109,9 +109,13 @@ void DownloadFileManager::UpdateInProgressDownloads() {
|
| DownloadFile* download_file = i->second;
|
| DownloadManager* manager = download_file->GetDownloadManager();
|
| if (manager) {
|
| + std::string partial_hash;
|
| + if (!download_file->GetPartialSha256Hash(&partial_hash))
|
| + partial_hash = "";
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| NewRunnableMethod(manager, &DownloadManager::UpdateDownload,
|
| - global_id.local(), download_file->bytes_so_far()));
|
| + global_id.local(), download_file->bytes_so_far(),
|
| + partial_hash));
|
| }
|
| }
|
| }
|
| @@ -164,6 +168,10 @@ void DownloadFileManager::UpdateDownload(
|
| had_error = true;
|
|
|
| int64 bytes_downloaded = download_file->bytes_so_far();
|
| + std::string partial_hash;
|
| + if (!download_file->GetPartialSha256Hash(&partial_hash))
|
| + partial_hash.clear();
|
| +
|
| // Calling this here in case we get more data, to avoid
|
| // processing data after an error. That could lead to
|
| // files that are corrupted if the later processing succeeded.
|
| @@ -179,6 +187,7 @@ void DownloadFileManager::UpdateDownload(
|
| &DownloadManager::OnDownloadInterrupted,
|
| global_id.local(),
|
| bytes_downloaded,
|
| + partial_hash,
|
| ConvertNetErrorToInterruptReason(
|
| write_result,
|
| DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| @@ -209,11 +218,11 @@ void DownloadFileManager::OnResponseCompleted(
|
| return;
|
| }
|
|
|
| - std::string hash;
|
| - if (!download_file->GetSha256Hash(&hash))
|
| - hash.clear();
|
| -
|
| if (reason == DOWNLOAD_INTERRUPT_REASON_NONE) {
|
| + std::string hash;
|
| + if (!download_file->GetSha256Hash(&hash))
|
| + hash.clear();
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| @@ -224,6 +233,10 @@ void DownloadFileManager::OnResponseCompleted(
|
| download_file->bytes_so_far(),
|
| hash));
|
| } else {
|
| + std::string partial_hash;
|
| + if (!download_file->GetPartialSha256Hash(&partial_hash))
|
| + partial_hash.clear();
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| @@ -232,6 +245,7 @@ void DownloadFileManager::OnResponseCompleted(
|
| &DownloadManager::OnDownloadInterrupted,
|
| global_id.local(),
|
| download_file->bytes_so_far(),
|
| + partial_hash,
|
| reason));
|
| }
|
| // We need to keep the download around until the UI thread has finalized
|
| @@ -407,12 +421,17 @@ void DownloadFileManager::CancelDownloadOnRename(
|
| return;
|
| }
|
|
|
| + std::string partial_hash;
|
| + if (!download_file->GetPartialSha256Hash(&partial_hash))
|
| + partial_hash.clear();
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| NewRunnableMethod(download_manager,
|
| &DownloadManager::OnDownloadInterrupted,
|
| global_id.local(),
|
| download_file->bytes_so_far(),
|
| + partial_hash,
|
| ConvertNetErrorToInterruptReason(
|
| rename_error,
|
| DOWNLOAD_INTERRUPT_FROM_DISK)));
|
|
|