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

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: Incorporated Randy's comments. 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/base_file.cc
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 51121001de8b64534119d8a7fb99411b77f7e324..0c63fc7967ca8d79eba431b951abae0f95682f58 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -193,6 +193,7 @@ BaseFile::BaseFile(const FilePath& full_path,
const GURL& source_url,
const GURL& referrer_url,
int64 received_bytes,
+ const std::string& initial_hash,
const linked_ptr<net::FileStream>& file_stream)
: full_path_(full_path),
source_url_(source_url),
@@ -203,7 +204,10 @@ BaseFile::BaseFile(const FilePath& full_path,
calculate_hash_(false),
detached_(false) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- memcpy(sha256_hash_, kEmptySha256Hash, kSha256HashLen);
+ if (initial_hash.empty() || IsEmptySha256Hash(initial_hash))
+ memcpy(sha256_hash_, kEmptySha256Hash, kSha256HashLen);
+ else
+ memcpy(sha256_hash_, initial_hash.c_str(), kSha256HashLen);
if (file_stream_.get())
file_stream_->EnableErrorStatistics();
}
@@ -387,7 +391,7 @@ bool BaseFile::GetSha256Hash(std::string* hash) {
DCHECK(!detached_);
hash->assign(reinterpret_cast<const char*>(sha256_hash_),
sizeof(sha256_hash_));
- return (calculate_hash_ && !in_progress());
+ return (calculate_hash_);
}
bool BaseFile::IsEmptySha256Hash(const std::string& hash) {

Powered by Google App Engine
This is Rietveld 408576698