| 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..982acea3bdbf9701ed3b268d773d856a7d4cedac 100644
|
| --- a/content/browser/download/download_file_manager.cc
|
| +++ b/content/browser/download/download_file_manager.cc
|
| @@ -70,7 +70,8 @@ void DownloadFileManager::CreateDownloadFile(
|
| scoped_ptr<DownloadFile>
|
| download_file(new DownloadFile(info,
|
| new DownloadRequestHandle(request_handle),
|
| - download_manager));
|
| + download_manager,
|
| + ""));
|
| if (net::OK != download_file->Initialize(get_hash)) {
|
| request_handle.CancelRequest();
|
| return;
|
| @@ -117,9 +118,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 +181,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 +197,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 +231,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 +431,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) {
|
|
|