| 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() {
|
|
|