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

Unified Diff: content/browser/download/base_file.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/base_file.cc
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 9683b50db03cc0e0c87441fe7151630cd8c217d1..dbe3516296cf66776c19a444ea6fb3372916c553 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -375,13 +375,27 @@ void BaseFile::Finish() {
Close();
}
-bool BaseFile::GetSha256Hash(std::string* hash) {
+bool BaseFile::GetPartialSha256Hash(std::string* hash) {
+ DCHECK(!detached_);
+ if (calculate_hash_)
+ hash->assign(reinterpret_cast<const char*>(sha256_hash_), kSha256HashLen);
+ return calculate_hash_;
+}
+
+bool BaseFile::SetPartialSha256Hash(const std::string& hash) {
DCHECK(!detached_);
- if (!calculate_hash_ || in_progress())
+ DCHECK(hash.size() == kSha256HashLen);
+ if (calculate_hash_) {
+ memset(sha256_hash_, 0, kSha256HashLen);
+ memcpy(sha256_hash_, hash.c_str(), kSha256HashLen);
+ }
+ return calculate_hash_;
+}
+
+bool BaseFile::GetSha256Hash(std::string* hash) {
+ if (in_progress())
return false;
- hash->assign(reinterpret_cast<const char*>(sha256_hash_),
- sizeof(sha256_hash_));
- return true;
+ return GetPartialSha256Hash(hash);
}
void BaseFile::AnnotateWithSourceInformation() {

Powered by Google App Engine
This is Rietveld 408576698