| 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 97a428075a882589d4a328a6a9a67a7c5054d251..a67ac56f2e2113325da91df82f94a141446a5ffe 100644
|
| --- a/content/browser/download/download_file_manager.cc
|
| +++ b/content/browser/download/download_file_manager.cc
|
| @@ -117,9 +117,15 @@ void DownloadFileManager::UpdateInProgressDownloads() {
|
| DownloadFile* download_file = i->second;
|
| DownloadManager* manager = download_file->GetDownloadManager();
|
| if (manager) {
|
| + std::string partial_hash;
|
| + if (!download_file->GetSha256Hash(&partial_hash) ||
|
| + BaseFile::IsEmptySha256Hash(partial_hash)) {
|
| + partial_hash.clear();
|
| + }
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::UpdateDownload, manager,
|
| - global_id.local(), download_file->bytes_so_far()));
|
| + global_id.local(), download_file->bytes_so_far(),
|
| + partial_hash));
|
| }
|
| }
|
| }
|
| @@ -174,6 +180,12 @@ void DownloadFileManager::UpdateDownload(
|
| had_error = true;
|
|
|
| int64 bytes_downloaded = download_file->bytes_so_far();
|
| + std::string partial_hash;
|
| + if (!download_file->GetSha256Hash(&partial_hash) ||
|
| + BaseFile::IsEmptySha256Hash(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.
|
| @@ -184,9 +196,13 @@ void DownloadFileManager::UpdateDownload(
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnDownloadInterrupted,
|
| - download_manager, global_id.local(), bytes_downloaded,
|
| + download_manager,
|
| + global_id.local(),
|
| + bytes_downloaded,
|
| + partial_hash,
|
| ConvertNetErrorToInterruptReason(
|
| - write_result, DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| + write_result,
|
| + DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| }
|
| }
|
| }
|
| @@ -214,22 +230,33 @@ void DownloadFileManager::OnResponseCompleted(
|
| return;
|
| }
|
|
|
| - std::string hash;
|
| - if (!download_file->GetSha256Hash(&hash) || BaseFile::IsEmptySha256Hash(hash))
|
| - hash.clear();
|
| -
|
| if (reason == DOWNLOAD_INTERRUPT_REASON_NONE) {
|
| + std::string hash;
|
| + if (!download_file->GetSha256Hash(&hash) ||
|
| + BaseFile::IsEmptySha256Hash(hash)) {
|
| + hash.clear();
|
| + }
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnResponseCompleted,
|
| download_manager, global_id.local(),
|
| download_file->bytes_so_far(), hash));
|
| } else {
|
| + std::string partial_hash;
|
| + if (!download_file->GetSha256Hash(&partial_hash) ||
|
| + BaseFile::IsEmptySha256Hash(partial_hash)) {
|
| + partial_hash.clear();
|
| + }
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnDownloadInterrupted,
|
| - download_manager, global_id.local(),
|
| - download_file->bytes_so_far(), reason));
|
| + download_manager,
|
| + global_id.local(),
|
| + download_file->bytes_so_far(),
|
| + partial_hash,
|
| + reason));
|
| }
|
| // We need to keep the download around until the UI thread has finalized
|
| // the name.
|
| @@ -403,13 +430,22 @@ void DownloadFileManager::CancelDownloadOnRename(
|
| return;
|
| }
|
|
|
| + std::string partial_hash;
|
| + if (!download_file->GetSha256Hash(&partial_hash) ||
|
| + BaseFile::IsEmptySha256Hash(partial_hash)) {
|
| + partial_hash.clear();
|
| + }
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnDownloadInterrupted,
|
| - download_manager, global_id.local(),
|
| + download_manager,
|
| + global_id.local(),
|
| download_file->bytes_so_far(),
|
| + partial_hash,
|
| ConvertNetErrorToInterruptReason(
|
| - rename_error, DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| + rename_error,
|
| + DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| }
|
|
|
| void DownloadFileManager::EraseDownload(DownloadId global_id) {
|
|
|