| 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 55d4097d037df1cfc836f121369d273376b0d006..e37e5088b258e9c07ccb5988e0589032181bd38e 100644
|
| --- a/content/browser/download/download_file_manager.cc
|
| +++ b/content/browser/download/download_file_manager.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/bind.h"
|
| #include "base/file_util.h"
|
| #include "base/logging.h"
|
| +#include "base/pickle.h"
|
| #include "base/stl_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "content/browser/download/base_file.h"
|
| @@ -70,7 +71,8 @@ void DownloadFileManager::CreateDownloadFile(
|
| scoped_ptr<DownloadFile> download_file(
|
| new DownloadFileImpl(info,
|
| new DownloadRequestHandle(request_handle),
|
| - download_manager));
|
| + download_manager,
|
| + Pickle()));
|
| if (net::OK != download_file->Initialize(get_hash)) {
|
| request_handle.CancelRequest();
|
| return;
|
| @@ -118,9 +120,15 @@ void DownloadFileManager::UpdateInProgressDownloads() {
|
| DownloadFile* download_file = i->second;
|
| DownloadManager* manager = download_file->GetDownloadManager();
|
| if (manager) {
|
| + Pickle hash_state;
|
| + download_file->GetSha256HashState(&hash_state);
|
| +
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&DownloadManager::UpdateDownload, manager,
|
| - global_id.local(), download_file->BytesSoFar()));
|
| + base::Bind(&DownloadManager::UpdateDownload,
|
| + manager,
|
| + global_id.local(),
|
| + download_file->BytesSoFar(),
|
| + hash_state));
|
| }
|
| }
|
| }
|
| @@ -175,6 +183,9 @@ void DownloadFileManager::UpdateDownload(
|
| had_error = true;
|
|
|
| int64 bytes_downloaded = download_file->BytesSoFar();
|
| + Pickle hash_state;
|
| + download_file->GetSha256HashState(&hash_state);
|
| +
|
| // 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.
|
| @@ -185,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,
|
| + hash_state,
|
| ConvertNetErrorToInterruptReason(
|
| - write_result, DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| + write_result,
|
| + DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| }
|
| }
|
| }
|
| @@ -215,22 +230,30 @@ 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->BytesSoFar(), hash));
|
| } else {
|
| + Pickle hash_state;
|
| + download_file->GetSha256HashState(&hash_state);
|
| +
|
| 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(),
|
| + hash_state,
|
| + reason));
|
| }
|
| // We need to keep the download around until the UI thread has finalized
|
| // the name.
|
| @@ -404,13 +427,19 @@ void DownloadFileManager::CancelDownloadOnRename(
|
| return;
|
| }
|
|
|
| + Pickle hash_state;
|
| + download_file->GetSha256HashState(&hash_state);
|
| +
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DownloadManager::OnDownloadInterrupted,
|
| - download_manager, global_id.local(),
|
| + download_manager,
|
| + global_id.local(),
|
| download_file->BytesSoFar(),
|
| + hash_state,
|
| ConvertNetErrorToInterruptReason(
|
| - rename_error, DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| + rename_error,
|
| + DOWNLOAD_INTERRUPT_FROM_DISK)));
|
| }
|
|
|
| void DownloadFileManager::EraseDownload(DownloadId global_id) {
|
|
|