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

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: Merged with trunk Created 9 years, 2 months 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 e6ecc9f81d49118e9e0b8301cba279c05d6eae05..84a7e1459b20a7a5fb9181283d0fddd31f5fbc3a 100644
--- a/content/browser/download/download_file_manager.cc
+++ b/content/browser/download/download_file_manager.cc
@@ -109,9 +109,13 @@ void DownloadFileManager::UpdateInProgressDownloads() {
DownloadFile* download_file = i->second;
DownloadManager* manager = download_file->GetDownloadManager();
if (manager) {
+ std::string partial_hash;
+ if (!download_file->GetPartialSha256Hash(&partial_hash))
+ partial_hash = "";
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
NewRunnableMethod(manager, &DownloadManager::UpdateDownload,
- global_id.local(), download_file->bytes_so_far()));
+ global_id.local(), download_file->bytes_so_far(),
+ partial_hash));
}
}
}
@@ -164,6 +168,10 @@ void DownloadFileManager::UpdateDownload(
had_error = true;
int64 bytes_downloaded = download_file->bytes_so_far();
+ std::string partial_hash;
+ if (!download_file->GetPartialSha256Hash(&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.
@@ -179,6 +187,7 @@ void DownloadFileManager::UpdateDownload(
&DownloadManager::OnDownloadInterrupted,
global_id.local(),
bytes_downloaded,
+ partial_hash,
ConvertNetErrorToInterruptReason(
write_result,
DOWNLOAD_INTERRUPT_FROM_DISK)));
@@ -209,11 +218,11 @@ void DownloadFileManager::OnResponseCompleted(
return;
}
- std::string hash;
- if (!download_file->GetSha256Hash(&hash))
- hash.clear();
-
if (reason == DOWNLOAD_INTERRUPT_REASON_NONE) {
+ std::string hash;
+ if (!download_file->GetSha256Hash(&hash))
+ hash.clear();
+
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
@@ -224,6 +233,10 @@ void DownloadFileManager::OnResponseCompleted(
download_file->bytes_so_far(),
hash));
} else {
+ std::string partial_hash;
+ if (!download_file->GetPartialSha256Hash(&partial_hash))
+ partial_hash.clear();
+
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
@@ -232,6 +245,7 @@ void DownloadFileManager::OnResponseCompleted(
&DownloadManager::OnDownloadInterrupted,
global_id.local(),
download_file->bytes_so_far(),
+ partial_hash,
reason));
}
// We need to keep the download around until the UI thread has finalized
@@ -407,12 +421,17 @@ void DownloadFileManager::CancelDownloadOnRename(
return;
}
+ std::string partial_hash;
+ if (!download_file->GetPartialSha256Hash(&partial_hash))
+ partial_hash.clear();
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(download_manager,
&DownloadManager::OnDownloadInterrupted,
global_id.local(),
download_file->bytes_so_far(),
+ partial_hash,
ConvertNetErrorToInterruptReason(
rename_error,
DOWNLOAD_INTERRUPT_FROM_DISK)));

Powered by Google App Engine
This is Rietveld 408576698