Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1027)

Unified Diff: content/browser/download/download_file_manager.cc

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DownloadSaveInfo::offset is now int64. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0c0304993d64deffceae51f2af1265c6614fae14 100644
--- a/content/browser/download/download_file_manager.cc
+++ b/content/browser/download/download_file_manager.cc
@@ -119,8 +119,11 @@ 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()));
+ base::Bind(&DownloadManager::UpdateDownload,
+ manager,
+ global_id.local(),
+ download_file->BytesSoFar(),
+ download_file->GetSha256HashState()));
}
}
}
@@ -175,6 +178,8 @@ void DownloadFileManager::UpdateDownload(
had_error = true;
int64 bytes_downloaded = download_file->BytesSoFar();
+ std::string hash_state(download_file->GetSha256HashState());
+
// 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 +190,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,11 +224,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->GetSha256Hash(&hash) ||
+ BaseFile::IsEmptySha256Hash(hash)) {
+ hash.clear();
+ }
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&DownloadManager::OnResponseCompleted,
@@ -229,8 +240,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->GetSha256HashState(),
+ reason));
}
// We need to keep the download around until the UI thread has finalized
// the name.
@@ -407,10 +421,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->GetSha256HashState(),
ConvertNetErrorToInterruptReason(
- rename_error, DOWNLOAD_INTERRUPT_FROM_DISK)));
+ rename_error,
+ DOWNLOAD_INTERRUPT_FROM_DISK)));
}
void DownloadFileManager::EraseDownload(DownloadId global_id) {

Powered by Google App Engine
This is Rietveld 408576698