| 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 1dcaa0dbcc524de2d36b12245cf3df85d2f4afa3..282679f8c43d9bb857ff80ee140f00cc2652bb5e 100644
|
| --- a/content/browser/download/download_file_manager.cc
|
| +++ b/content/browser/download/download_file_manager.cc
|
| @@ -41,16 +41,18 @@ class DownloadFileFactoryImpl
|
|
|
| virtual DownloadFile* CreateFile(DownloadCreateInfo* info,
|
| const DownloadRequestHandle& request_handle,
|
| - DownloadManager* download_manager) OVERRIDE;
|
| + DownloadManager* download_manager,
|
| + bool calculate_hash) OVERRIDE;
|
| };
|
|
|
| DownloadFile* DownloadFileFactoryImpl::CreateFile(
|
| DownloadCreateInfo* info,
|
| const DownloadRequestHandle& request_handle,
|
| - DownloadManager* download_manager) {
|
| + DownloadManager* download_manager,
|
| + bool calculate_hash) {
|
| return new DownloadFileImpl(info,
|
| new DownloadRequestHandle(request_handle),
|
| - download_manager);
|
| + download_manager, calculate_hash);
|
| }
|
|
|
| } // namespace
|
| @@ -90,8 +92,8 @@ void DownloadFileManager::CreateDownloadFile(
|
| scoped_ptr<DownloadCreateInfo> infop(info);
|
|
|
| scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile(
|
| - info, request_handle, download_manager));
|
| - if (net::OK != download_file->Initialize(get_hash)) {
|
| + info, request_handle, download_manager, get_hash));
|
| + if (net::OK != download_file->Initialize()) {
|
| request_handle.CancelRequest();
|
| return;
|
| }
|
| @@ -139,9 +141,12 @@ void DownloadFileManager::UpdateInProgressDownloads() {
|
| DownloadManager* manager = download_file->GetDownloadManager();
|
| if (manager) {
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&DownloadManager::UpdateDownload, manager,
|
| - global_id.local(), download_file->BytesSoFar(),
|
| - download_file->CurrentSpeed()));
|
| + base::Bind(&DownloadManager::UpdateDownload,
|
| + manager,
|
| + global_id.local(),
|
| + download_file->BytesSoFar(),
|
| + download_file->CurrentSpeed(),
|
| + download_file->GetHashState()));
|
| }
|
| }
|
| }
|
| @@ -193,6 +198,8 @@ void DownloadFileManager::UpdateDownload(
|
| had_error = true;
|
|
|
| int64 bytes_downloaded = download_file->BytesSoFar();
|
| + std::string hash_state(download_file->GetHashState());
|
| +
|
| // 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.
|
| @@ -203,9 +210,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,
|
| + hash_state,
|
| ConvertNetErrorToInterruptReason(
|
| - write_result, DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| + write_result,
|
| + DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| }
|
| }
|
| }
|
| @@ -233,11 +244,13 @@ 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->GetHash(&hash) ||
|
| + BaseFile::IsEmptyHash(hash)) {
|
| + hash.clear();
|
| + }
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnResponseCompleted,
|
| @@ -247,8 +260,11 @@ void DownloadFileManager::OnResponseCompleted(
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnDownloadInterrupted,
|
| - download_manager, global_id.local(),
|
| - download_file->BytesSoFar(), reason));
|
| + download_manager,
|
| + global_id.local(),
|
| + download_file->BytesSoFar(),
|
| + download_file->GetHashState(),
|
| + reason));
|
| }
|
| // We need to keep the download around until the UI thread has finalized
|
| // the name.
|
| @@ -425,10 +441,13 @@ void DownloadFileManager::CancelDownloadOnRename(
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnDownloadInterrupted,
|
| - download_manager, global_id.local(),
|
| + download_manager,
|
| + global_id.local(),
|
| download_file->BytesSoFar(),
|
| + download_file->GetHashState(),
|
| ConvertNetErrorToInterruptReason(
|
| - rename_error, DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| + rename_error,
|
| + DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| }
|
|
|
| void DownloadFileManager::EraseDownload(DownloadId global_id) {
|
|
|