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

Unified Diff: chrome/browser/download/base_file.cc

Issue 6276002: Abstracts SHA256 context for NSS / OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implements SHA256Context abstracting NSS / OpenSSL. Created 9 years, 11 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: chrome/browser/download/base_file.cc
diff --git a/chrome/browser/download/base_file.cc b/chrome/browser/download/base_file.cc
index 4085f601df06db49ae89328452e2857960082601..3bf1987b62f7d5d52fdcfb280f722fdf440b503f 100644
--- a/chrome/browser/download/base_file.cc
+++ b/chrome/browser/download/base_file.cc
@@ -6,9 +6,8 @@
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/sha2.h"
#include "base/stringprintf.h"
-#include "base/third_party/nss/blapi.h"
-#include "base/third_party/nss/sha256.h"
#include "net/base/file_stream.h"
#include "net/base/net_errors.h"
#include "chrome/browser/browser_thread.h"
@@ -50,10 +49,8 @@ bool BaseFile::Initialize(bool calculate_hash) {
calculate_hash_ = calculate_hash;
- if (calculate_hash_) {
- sha_context_.reset(new SHA256Context);
- SHA256_Begin(sha_context_.get());
- }
+ if (calculate_hash_)
+ sha_context_.reset(base::SHA256Context::Create());
if (!full_path_.empty() ||
download_util::CreateTemporaryFileForDownload(&full_path_))
@@ -78,11 +75,8 @@ bool BaseFile::AppendDataToFile(const char* data, size_t data_len) {
if (written != data_len)
return false;
- if (calculate_hash_) {
- SHA256_Update(sha_context_.get(),
- reinterpret_cast<const unsigned char*>(data),
- data_len);
- }
+ if (calculate_hash_)
+ sha_context_->Update(std::string(data, data_len));
return true;
}
@@ -162,7 +156,7 @@ void BaseFile::Finish() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
if (calculate_hash_)
- SHA256_End(sha_context_.get(), sha256_hash_, NULL, kSha256HashLen);
+ sha_context_->Finish(sha256_hash_, kSha256HashLen);
Close();
}

Powered by Google App Engine
This is Rietveld 408576698