diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-18 16:54:58 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-18 16:54:58 +0000 |
commit | 0ad1d2d6eb6f1e4edff72dabb8e2b2f9ba051f88 (patch) | |
tree | 34d232d10e6415100d5b660317c23a14e157ba83 /chrome | |
parent | dac096590a0f00f124eb71b12ff6a32cee439fca (diff) | |
download | chromium_src-0ad1d2d6eb6f1e4edff72dabb8e2b2f9ba051f88.zip chromium_src-0ad1d2d6eb6f1e4edff72dabb8e2b2f9ba051f88.tar.gz chromium_src-0ad1d2d6eb6f1e4edff72dabb8e2b2f9ba051f88.tar.bz2 |
base: Put md5.* into base namespace.
BUG=89274
TEST=None
R=evan@chromium.org
Review URL: http://codereview.chromium.org/7395021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92861 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
18 files changed, 114 insertions, 110 deletions
diff --git a/chrome/browser/bookmarks/bookmark_codec.cc b/chrome/browser/bookmarks/bookmark_codec.cc index 50cd3fcc..23bd411 100644 --- a/chrome/browser/bookmarks/bookmark_codec.cc +++ b/chrome/browser/bookmarks/bookmark_codec.cc @@ -337,11 +337,11 @@ void BookmarkCodec::ReassignIDsHelper(BookmarkNode* node) { } void BookmarkCodec::UpdateChecksum(const std::string& str) { - MD5Update(&md5_context_, str.data(), str.length() * sizeof(char)); + base::MD5Update(&md5_context_, str.data(), str.length() * sizeof(char)); } void BookmarkCodec::UpdateChecksum(const string16& str) { - MD5Update(&md5_context_, str.data(), str.length() * sizeof(char16)); + base::MD5Update(&md5_context_, str.data(), str.length() * sizeof(char16)); } void BookmarkCodec::UpdateChecksumWithUrlNode(const std::string& id, @@ -362,11 +362,11 @@ void BookmarkCodec::UpdateChecksumWithFolderNode(const std::string& id, } void BookmarkCodec::InitializeChecksum() { - MD5Init(&md5_context_); + base::MD5Init(&md5_context_); } void BookmarkCodec::FinalizeChecksum() { - MD5Digest digest; - MD5Final(&digest, &md5_context_); - computed_checksum_ = MD5DigestToBase16(digest); + base::MD5Digest digest; + base::MD5Final(&digest, &md5_context_); + computed_checksum_ = base::MD5DigestToBase16(digest); } diff --git a/chrome/browser/bookmarks/bookmark_codec.h b/chrome/browser/bookmarks/bookmark_codec.h index fa2da5a..daa2e91 100644 --- a/chrome/browser/bookmarks/bookmark_codec.h +++ b/chrome/browser/bookmarks/bookmark_codec.h @@ -159,7 +159,7 @@ class BookmarkCodec { std::set<int64> ids_; // MD5 context used to compute MD5 hash of all bookmark data. - MD5Context md5_context_; + base::MD5Context md5_context_; // Checksums. std::string computed_checksum_; diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc index d0e3619..1c6f67f 100644 --- a/chrome/browser/history/top_sites.cc +++ b/chrome/browser/history/top_sites.cc @@ -766,7 +766,7 @@ std::string TopSites::GetURLString(const GURL& url) { std::string TopSites::GetURLHash(const GURL& url) { // We don't use canonical URLs here to be able to blacklist only one of // the two 'duplicate' sites, e.g. 'gmail.com' and 'mail.google.com'. - return MD5String(url.spec()); + return base::MD5String(url.spec()); } base::TimeDelta TopSites::GetUpdateDelay() { diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 19d18084..e5fbe6f 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -1122,8 +1122,8 @@ MetricsService::LogRecallStatus MetricsService::RecallUnsentLogsHelper( list.GetSize() - kChecksumEntryCount) return MakeRecallStatusHistogram(LIST_SIZE_CORRUPTION); - MD5Context ctx; - MD5Init(&ctx); + base::MD5Context ctx; + base::MD5Init(&ctx); std::string encoded_log; std::string decoded_log; for (ListValue::const_iterator it = list.begin() + 1; @@ -1134,7 +1134,7 @@ MetricsService::LogRecallStatus MetricsService::RecallUnsentLogsHelper( return MakeRecallStatusHistogram(LOG_STRING_CORRUPTION); } - MD5Update(&ctx, encoded_log.data(), encoded_log.length()); + base::MD5Update(&ctx, encoded_log.data(), encoded_log.length()); if (!base::Base64Decode(encoded_log, &decoded_log)) { local_list->clear(); @@ -1144,8 +1144,8 @@ MetricsService::LogRecallStatus MetricsService::RecallUnsentLogsHelper( } // Verify checksum. - MD5Digest digest; - MD5Final(&digest, &ctx); + base::MD5Digest digest; + base::MD5Final(&digest, &ctx); std::string recovered_md5; // We store the hash at the end of the list. valid = (*(list.end() - 1))->GetAsString(&recovered_md5); @@ -1153,7 +1153,7 @@ MetricsService::LogRecallStatus MetricsService::RecallUnsentLogsHelper( local_list->clear(); return MakeRecallStatusHistogram(CHECKSUM_STRING_CORRUPTION); } - if (recovered_md5 != MD5DigestToBase16(digest)) { + if (recovered_md5 != base::MD5DigestToBase16(digest)) { local_list->clear(); return MakeRecallStatusHistogram(CHECKSUM_CORRUPTION); } @@ -1188,8 +1188,8 @@ void MetricsService::StoreUnsentLogsHelper( // Store size at the beginning of the list. list->Append(Value::CreateIntegerValue(local_list.size() - start)); - MD5Context ctx; - MD5Init(&ctx); + base::MD5Context ctx; + base::MD5Init(&ctx); std::string encoded_log; for (std::vector<std::string>::const_iterator it = local_list.begin() + start; it != local_list.end(); ++it) { @@ -1200,14 +1200,14 @@ void MetricsService::StoreUnsentLogsHelper( list->Clear(); return; } - MD5Update(&ctx, encoded_log.data(), encoded_log.length()); + base::MD5Update(&ctx, encoded_log.data(), encoded_log.length()); list->Append(Value::CreateStringValue(encoded_log)); } // Append hash to the end of the list. - MD5Digest digest; - MD5Final(&digest, &ctx); - list->Append(Value::CreateStringValue(MD5DigestToBase16(digest))); + base::MD5Digest digest; + base::MD5Final(&digest, &ctx); + list->Append(Value::CreateStringValue(base::MD5DigestToBase16(digest))); DCHECK(list->GetSize() >= 3); // Minimum of 3 elements (size, data, hash). MakeStoreStatusHistogram(STORE_SUCCESS); } diff --git a/chrome/browser/metrics/metrics_service_unittest.cc b/chrome/browser/metrics/metrics_service_unittest.cc index 9e7b463..2ddb2f8 100644 --- a/chrome/browser/metrics/metrics_service_unittest.cc +++ b/chrome/browser/metrics/metrics_service_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -76,7 +76,7 @@ TEST(MetricsServiceTest, SingleElementLogList) { ++it; (*it)->GetAsString(&str); // MD5 for encoded "Hello world!" string. - EXPECT_TRUE(MD5String(encoded) == str); + EXPECT_TRUE(base::MD5String(encoded) == str); ++it; EXPECT_TRUE(it == list.end()); // Reached end of list. diff --git a/chrome/browser/safe_browsing/malware_details_cache.cc b/chrome/browser/safe_browsing/malware_details_cache.cc index 72ba461..481b972 100644 --- a/chrome/browser/safe_browsing/malware_details_cache.cc +++ b/chrome/browser/safe_browsing/malware_details_cache.cc @@ -12,8 +12,8 @@ #include "base/string_util.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/safe_browsing/malware_details_cache.h" -#include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/safe_browsing/report.pb.h" +#include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "content/browser/browser_thread.h" #include "net/base/host_port_pair.h" #include "net/base/load_flags.h" @@ -186,9 +186,9 @@ void MalwareDetailsCacheCollector::ReadData( pb_response->set_body(data); } pb_response->set_bodylength(data.size()); - MD5Digest digest; - MD5Sum(data.c_str(), data.size(), &digest); - pb_response->set_bodydigest(MD5DigestToBase16(digest)); + base::MD5Digest digest; + base::MD5Sum(data.c_str(), data.size(), &digest); + pb_response->set_bodydigest(base::MD5DigestToBase16(digest)); } void MalwareDetailsCacheCollector::AdvanceEntry() { diff --git a/chrome/browser/safe_browsing/prefix_set.cc b/chrome/browser/safe_browsing/prefix_set.cc index c61cdad..13890a0 100644 --- a/chrome/browser/safe_browsing/prefix_set.cc +++ b/chrome/browser/safe_browsing/prefix_set.cc @@ -161,6 +161,7 @@ PrefixSet* PrefixSet::LoadFile(const FilePath& filter_name) { int64 size_64; if (!file_util::GetFileSize(filter_name, &size_64)) return NULL; + using base::MD5Digest; if (size_64 < static_cast<int64>(sizeof(FileHeader) + sizeof(MD5Digest))) return NULL; @@ -189,9 +190,9 @@ PrefixSet* PrefixSet::LoadFile(const FilePath& filter_name) { return NULL; // The file looks valid, start building the digest. - MD5Context context; - MD5Init(&context); - MD5Update(&context, &header, sizeof(header)); + base::MD5Context context; + base::MD5Init(&context); + base::MD5Update(&context, &header, sizeof(header)); // Read the index vector. Herb Sutter indicates that vectors are // guaranteed to be contiuguous, so reading to where element 0 lives @@ -200,19 +201,19 @@ PrefixSet* PrefixSet::LoadFile(const FilePath& filter_name) { read = fread(&(index[0]), sizeof(index[0]), index.size(), file.get()); if (read != index.size()) return NULL; - MD5Update(&context, &(index[0]), index_bytes); + base::MD5Update(&context, &(index[0]), index_bytes); // Read vector of deltas. deltas.resize(header.deltas_size); read = fread(&(deltas[0]), sizeof(deltas[0]), deltas.size(), file.get()); if (read != deltas.size()) return NULL; - MD5Update(&context, &(deltas[0]), deltas_bytes); + base::MD5Update(&context, &(deltas[0]), deltas_bytes); - MD5Digest calculated_digest; - MD5Final(&calculated_digest, &context); + base::MD5Digest calculated_digest; + base::MD5Final(&calculated_digest, &context); - MD5Digest file_digest; + base::MD5Digest file_digest; read = fread(&file_digest, sizeof(file_digest), 1, file.get()); if (read != 1) return NULL; @@ -242,15 +243,15 @@ bool PrefixSet::WriteFile(const FilePath& filter_name) const { if (!file.get()) return false; - MD5Context context; - MD5Init(&context); + base::MD5Context context; + base::MD5Init(&context); // TODO(shess): The I/O code in safe_browsing_store_file.cc would // sure be useful about now. size_t written = fwrite(&header, sizeof(header), 1, file.get()); if (written != 1) return false; - MD5Update(&context, &header, sizeof(header)); + base::MD5Update(&context, &header, sizeof(header)); // As for reads, the standard guarantees the ability to access the // contents of the vector by a pointer to an element. @@ -258,17 +259,17 @@ bool PrefixSet::WriteFile(const FilePath& filter_name) const { written = fwrite(&(index_[0]), sizeof(index_[0]), index_.size(), file.get()); if (written != index_.size()) return false; - MD5Update(&context, &(index_[0]), index_bytes); + base::MD5Update(&context, &(index_[0]), index_bytes); const size_t deltas_bytes = sizeof(deltas_[0]) * deltas_.size(); written = fwrite(&(deltas_[0]), sizeof(deltas_[0]), deltas_.size(), file.get()); if (written != deltas_.size()) return false; - MD5Update(&context, &(deltas_[0]), deltas_bytes); + base::MD5Update(&context, &(deltas_[0]), deltas_bytes); - MD5Digest digest; - MD5Final(&digest, &context); + base::MD5Digest digest; + base::MD5Final(&digest, &context); written = fwrite(&digest, sizeof(digest), 1, file.get()); if (written != 1) return false; diff --git a/chrome/browser/safe_browsing/prefix_set_unittest.cc b/chrome/browser/safe_browsing/prefix_set_unittest.cc index 62c0427..22d26d8 100644 --- a/chrome/browser/safe_browsing/prefix_set_unittest.cc +++ b/chrome/browser/safe_browsing/prefix_set_unittest.cc @@ -99,12 +99,13 @@ class PrefixSetTest : public PlatformTest { // Helper function to re-generated |fp|'s checksum to be correct for // the file's contents. |fp| should be opened in r+ mode. static void CleanChecksum(FILE* fp) { - MD5Context context; - MD5Init(&context); + base::MD5Context context; + base::MD5Init(&context); ASSERT_NE(-1, fseek(fp, 0, SEEK_END)); long file_size = ftell(fp); + using base::MD5Digest; size_t payload_size = static_cast<size_t>(file_size) - sizeof(MD5Digest); size_t digested_size = 0; ASSERT_NE(-1, fseek(fp, 0, SEEK_SET)); @@ -112,14 +113,14 @@ class PrefixSetTest : public PlatformTest { char buf[1024]; size_t nitems = std::min(payload_size - digested_size, sizeof(buf)); ASSERT_EQ(nitems, fread(buf, 1, nitems, fp)); - MD5Update(&context, &buf, nitems); + base::MD5Update(&context, &buf, nitems); digested_size += nitems; } ASSERT_EQ(digested_size, payload_size); ASSERT_EQ(static_cast<long>(digested_size), ftell(fp)); - MD5Digest new_digest; - MD5Final(&new_digest, &context); + base::MD5Digest new_digest; + base::MD5Final(&new_digest, &context); ASSERT_NE(-1, fseek(fp, digested_size, SEEK_SET)); ASSERT_EQ(1U, fwrite(&new_digest, sizeof(new_digest), 1, fp)); ASSERT_EQ(file_size, ftell(fp)); @@ -409,7 +410,7 @@ TEST_F(PrefixSetTest, CorruptionDigest) { int64 size_64; ASSERT_TRUE(file_util::GetFileSize(filename, &size_64)); file_util::ScopedFILE file(file_util::OpenFile(filename, "r+b")); - long digest_offset = static_cast<long>(size_64 - sizeof(MD5Digest)); + long digest_offset = static_cast<long>(size_64 - sizeof(base::MD5Digest)); ASSERT_NO_FATAL_FAILURE(IncrementIntAt(file.get(), digest_offset, 1)); file.reset(); scoped_ptr<safe_browsing::PrefixSet> diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file.cc b/chrome/browser/safe_browsing/safe_browsing_store_file.cc index bfb6062..110fa54 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_file.cc @@ -1,12 +1,12 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" #include "base/callback.h" -#include "base/metrics/histogram.h" #include "base/md5.h" +#include "base/metrics/histogram.h" namespace { @@ -53,13 +53,13 @@ bool FileSkip(size_t bytes, FILE* fp) { // input data into the checksum in |context|, if non-NULL. Return // true on success. template <class T> -bool ReadArray(T* ptr, size_t nmemb, FILE* fp, MD5Context* context) { +bool ReadArray(T* ptr, size_t nmemb, FILE* fp, base::MD5Context* context) { const size_t ret = fread(ptr, sizeof(T), nmemb, fp); if (ret != nmemb) return false; if (context) - MD5Update(context, ptr, sizeof(T) * nmemb); + base::MD5Update(context, ptr, sizeof(T) * nmemb); return true; } @@ -67,13 +67,14 @@ bool ReadArray(T* ptr, size_t nmemb, FILE* fp, MD5Context* context) { // output data into the checksum in |context|, if non-NULL. Return // true on success. template <class T> -bool WriteArray(const T* ptr, size_t nmemb, FILE* fp, MD5Context* context) { +bool WriteArray(const T* ptr, size_t nmemb, FILE* fp, + base::MD5Context* context) { const size_t ret = fwrite(ptr, sizeof(T), nmemb, fp); if (ret != nmemb) return false; if (context) - MD5Update(context, ptr, sizeof(T) * nmemb); + base::MD5Update(context, ptr, sizeof(T) * nmemb); return true; } @@ -82,8 +83,8 @@ bool WriteArray(const T* ptr, size_t nmemb, FILE* fp, MD5Context* context) { // |fp| and fold them into the checksum in |context|. Returns true on // success. template <class T> -bool ReadToVector(std::vector<T>* values, size_t count, - FILE* fp, MD5Context* context) { +bool ReadToVector(std::vector<T>* values, size_t count, FILE* fp, + base::MD5Context* context) { // Pointers into an empty vector may not be valid. if (!count) return true; @@ -107,7 +108,8 @@ bool ReadToVector(std::vector<T>* values, size_t count, // Write all of |values| to |fp|, and fold the data into the checksum // in |context|, if non-NULL. Returns true on succsess. template <class T> -bool WriteVector(const std::vector<T>& values, FILE* fp, MD5Context* context) { +bool WriteVector(const std::vector<T>& values, FILE* fp, + base::MD5Context* context) { // Pointers into empty vectors may not be valid. if (values.empty()) return true; @@ -120,8 +122,8 @@ bool WriteVector(const std::vector<T>& values, FILE* fp, MD5Context* context) { // Read an array of |count| integers and add them to |values|. // Returns true on success. -bool ReadToChunkSet(std::set<int32>* values, size_t count, - FILE* fp, MD5Context* context) { +bool ReadToChunkSet(std::set<int32>* values, size_t count, FILE* fp, + base::MD5Context* context) { if (!count) return true; @@ -135,8 +137,8 @@ bool ReadToChunkSet(std::set<int32>* values, size_t count, // Write the contents of |values| as an array of integers. Returns // true on success. -bool WriteChunkSet(const std::set<int32>& values, - FILE* fp, MD5Context* context) { +bool WriteChunkSet(const std::set<int32>& values, FILE* fp, + base::MD5Context* context) { if (values.empty()) return true; @@ -171,7 +173,7 @@ bool FileHeaderSanityCheck(const FilePath& filename, expected_size += header.sub_prefix_count * sizeof(SBSubPrefix); expected_size += header.add_hash_count * sizeof(SBAddFullHash); expected_size += header.sub_hash_count * sizeof(SBSubFullHash); - expected_size += sizeof(MD5Digest); + expected_size += sizeof(base::MD5Digest); if (size != expected_size) return false; @@ -183,7 +185,7 @@ bool FileHeaderSanityCheck(const FilePath& filename, bool ReadAndVerifyHeader(const FilePath& filename, FILE* fp, FileHeader* header, - MD5Context* context) { + base::MD5Context* context) { if (!ReadArray(header, 1, fp, context)) return false; if (header->magic != kFileMagic || header->version != kFileVersion) @@ -493,8 +495,8 @@ bool SafeBrowsingStoreFile::DoUpdate( if (!FileRewind(file_.get())) return OnCorruptDatabase(); - MD5Context context; - MD5Init(&context); + base::MD5Context context; + base::MD5Init(&context); // Read the file header and make sure it looks right. FileHeader header; @@ -521,11 +523,11 @@ bool SafeBrowsingStoreFile::DoUpdate( return OnCorruptDatabase(); // Calculate the digest to this point. - MD5Digest calculated_digest; - MD5Final(&calculated_digest, &context); + base::MD5Digest calculated_digest; + base::MD5Final(&calculated_digest, &context); // Read the stored checksum and verify it. - MD5Digest file_digest; + base::MD5Digest file_digest; if (!ReadArray(&file_digest, 1, file_.get(), NULL)) return OnCorruptDatabase(); @@ -612,8 +614,8 @@ bool SafeBrowsingStoreFile::DoUpdate( if (!FileRewind(new_file_.get())) return false; - MD5Context context; - MD5Init(&context); + base::MD5Context context; + base::MD5Init(&context); // Write a file header. FileHeader header; @@ -638,8 +640,8 @@ bool SafeBrowsingStoreFile::DoUpdate( return false; // Write the checksum at the end. - MD5Digest digest; - MD5Final(&digest, &context); + base::MD5Digest digest; + base::MD5Final(&digest, &context); if (!WriteArray(&digest, 1, new_file_.get(), NULL)) return false; diff --git a/chrome/browser/spellcheck_host_metrics.cc b/chrome/browser/spellcheck_host_metrics.cc index 220c42b..1e91e93 100644 --- a/chrome/browser/spellcheck_host_metrics.cc +++ b/chrome/browser/spellcheck_host_metrics.cc @@ -52,10 +52,10 @@ void SpellCheckHostMetrics::RecordCheckedWordStats(const string16& word, UMA_HISTOGRAM_PERCENTAGE("SpellCheck.MisspellRatio", percentage); // Collects actual number of checked words, excluding duplication. - MD5Digest digest; - MD5Sum(reinterpret_cast<const unsigned char*>(word.c_str()), + base::MD5Digest digest; + base::MD5Sum(reinterpret_cast<const unsigned char*>(word.c_str()), word.size() * sizeof(char16), &digest); - checked_word_hashes_.insert(MD5DigestToBase16(digest)); + checked_word_hashes_.insert(base::MD5DigestToBase16(digest)); RecordWordCounts(); } diff --git a/chrome/browser/sync/util/user_settings.cc b/chrome/browser/sync/util/user_settings.cc index b842c43..df8ab6b 100644 --- a/chrome/browser/sync/util/user_settings.cc +++ b/chrome/browser/sync/util/user_settings.cc @@ -272,7 +272,7 @@ const int32 kInvalidHash = 0xFFFFFFFF; // We use 10 bits of data from the MD5 digest as the hash. const int32 kHashMask = 0x3FF; -int32 GetHashFromDigest(MD5Digest& digest) { +int32 GetHashFromDigest(base::MD5Digest& digest) { int32 hash = 0; int32 mask = kHashMask; for (size_t i = 0; i < sizeof(digest.a); ++i) { @@ -355,12 +355,12 @@ void UserSettings::StoreHashedPassword(const string& email, base::RandBytes(binary_salt, sizeof(binary_salt)); const string salt = APEncode(string(binary_salt, sizeof(binary_salt))); - MD5Context md5_context; - MD5Init(&md5_context); - MD5Update(&md5_context, salt.data(), salt.size()); - MD5Update(&md5_context, password.data(), password.size()); - MD5Digest md5_digest; - MD5Final(&md5_digest, &md5_context); + base::MD5Context md5_context; + base::MD5Init(&md5_context); + base::MD5Update(&md5_context, salt.data(), salt.size()); + base::MD5Update(&md5_context, password.data(), password.size()); + base::MD5Digest md5_digest; + base::MD5Final(&md5_digest, &md5_context); ScopedDBHandle dbhandle(this); SQLTransaction transaction(dbhandle.get()); @@ -418,12 +418,12 @@ bool UserSettings::VerifyAgainstStoredHash(const string& email, CHECK(SQLITE_DONE == query_result); if (salt.empty() || hash == kInvalidHash) return false; - MD5Context md5_context; - MD5Init(&md5_context); - MD5Update(&md5_context, salt.data(), salt.size()); - MD5Update(&md5_context, password.data(), password.size()); - MD5Digest md5_digest; - MD5Final(&md5_digest, &md5_context); + base::MD5Context md5_context; + base::MD5Init(&md5_context); + base::MD5Update(&md5_context, salt.data(), salt.size()); + base::MD5Update(&md5_context, password.data(), password.size()); + base::MD5Digest md5_digest; + base::MD5Final(&md5_digest, &md5_context); return hash == GetHashFromDigest(md5_digest); } diff --git a/chrome/browser/ui/webui/ntp/most_visited_handler.cc b/chrome/browser/ui/webui/ntp/most_visited_handler.cc index 98446f2..73a1363 100644 --- a/chrome/browser/ui/webui/ntp/most_visited_handler.cc +++ b/chrome/browser/ui/webui/ntp/most_visited_handler.cc @@ -329,7 +329,7 @@ void MostVisitedHandler::BlacklistURL(const GURL& url) { } std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) { - return MD5String(url); + return base::MD5String(url); } // static diff --git a/chrome/common/metrics_helpers.cc b/chrome/common/metrics_helpers.cc index 55c28bd..c7aef5b 100644 --- a/chrome/common/metrics_helpers.cc +++ b/chrome/common/metrics_helpers.cc @@ -11,15 +11,15 @@ #endif #include "base/base64.h" -#include "base/time.h" #include "base/basictypes.h" #include "base/file_util.h" #include "base/md5.h" #include "base/perftimer.h" #include "base/string_number_conversions.h" #include "base/sys_info.h" -#include "base/utf_string_conversions.h" #include "base/third_party/nspr/prtime.h" +#include "base/time.h" +#include "base/utf_string_conversions.h" #include "chrome/common/logging_chrome.h" #include "googleurl/src/gurl.h" #include "libxml/xmlwriter.h" @@ -175,12 +175,12 @@ int MetricsLogBase::GetElapsedSeconds() { } std::string MetricsLogBase::CreateHash(const std::string& value) { - MD5Context ctx; - MD5Init(&ctx); - MD5Update(&ctx, value.data(), value.length()); + base::MD5Context ctx; + base::MD5Init(&ctx); + base::MD5Update(&ctx, value.data(), value.length()); - MD5Digest digest; - MD5Final(&digest, &ctx); + base::MD5Digest digest; + base::MD5Final(&digest, &ctx); uint64 reverse_uint64; // UMA only uses first 8 chars of hash. We use the above uint64 instead diff --git a/chrome/common/visitedlink_common.cc b/chrome/common/visitedlink_common.cc index 92a6743..7fb254e 100644 --- a/chrome/common/visitedlink_common.cc +++ b/chrome/common/visitedlink_common.cc @@ -79,13 +79,13 @@ VisitedLinkCommon::Fingerprint VisitedLinkCommon::ComputeURLFingerprint( const uint8 salt[LINK_SALT_LENGTH]) { DCHECK(url_len > 0) << "Canonical URLs should not be empty"; - MD5Context ctx; - MD5Init(&ctx); - MD5Update(&ctx, salt, LINK_SALT_LENGTH * sizeof(uint8)); - MD5Update(&ctx, canonical_url, url_len * sizeof(char)); + base::MD5Context ctx; + base::MD5Init(&ctx); + base::MD5Update(&ctx, salt, LINK_SALT_LENGTH * sizeof(uint8)); + base::MD5Update(&ctx, canonical_url, url_len * sizeof(char)); - MD5Digest digest; - MD5Final(&digest, &ctx); + base::MD5Digest digest; + base::MD5Final(&digest, &ctx); // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that // direct cast the alignment could be wrong, and we can't access a 64-bit int diff --git a/chrome/service/cloud_print/cloud_print_helpers.cc b/chrome/service/cloud_print/cloud_print_helpers.cc index f7db653..71bfea7 100644 --- a/chrome/service/cloud_print/cloud_print_helpers.cc +++ b/chrome/service/cloud_print/cloud_print_helpers.cc @@ -218,7 +218,7 @@ std::string CloudPrintHelpers::GenerateHashOfStringMap( values_list.append(it->first); values_list.append(it->second); } - return MD5String(values_list); + return base::MD5String(values_list); } void CloudPrintHelpers::GenerateMultipartPostDataForPrinterTags( @@ -251,7 +251,7 @@ void CloudPrintHelpers::GenerateMultipartPostDataForPrinterTags( AddMultipartValueForUpload(kPrinterTagValue, msg, mime_boundary, std::string(), post_data); } - std::string tags_hash = MD5String(tags_list); + std::string tags_hash = base::MD5String(tags_list); std::string tags_hash_msg(kTagsHashTagName); tags_hash_msg += "="; tags_hash_msg += tags_hash; diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc index 92250c8..7e6b3b1 100644 --- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc +++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc @@ -10,9 +10,9 @@ #include "base/file_util.h" #include "base/md5.h" #include "base/rand_util.h" -#include "base/stringprintf.h" #include "base/string_number_conversions.h" #include "base/string_split.h" +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/common/net/gaia/gaia_oauth_client.h" @@ -682,7 +682,7 @@ void CloudPrintProxyBackend::Core::OnReceivePrinterCaps( // later to check if the capabilities have changed CloudPrintHelpers::AddMultipartValueForUpload( kPrinterCapsHashValue, - MD5String(last_uploaded_printer_info_.printer_capabilities), + base::MD5String(last_uploaded_printer_info_.printer_capabilities), mime_boundary, std::string(), &post_data); GURL post_url = CloudPrintHelpers::GetUrlForPrinterRegistration( cloud_print_server_url_); diff --git a/chrome/service/cloud_print/print_system_cups.cc b/chrome/service/cloud_print/print_system_cups.cc index 22ebdfc..3387334 100644 --- a/chrome/service/cloud_print/print_system_cups.cc +++ b/chrome/service/cloud_print/print_system_cups.cc @@ -23,8 +23,8 @@ #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/task.h" -#include "base/values.h" #include "base/utf_string_conversions.h" +#include "base/values.h" #include "chrome/service/cloud_print/cloud_print_consts.h" #include "chrome/service/cloud_print/cloud_print_helpers.h" #include "googleurl/src/gurl.h" @@ -224,7 +224,7 @@ class PrintServerWatcherCUPS for (size_t i = 0; i < printers.size(); i++) to_hash += printers[i]; - return MD5String(to_hash); + return base::MD5String(to_hash); } scoped_refptr<PrintSystemCUPS> print_system_; @@ -329,7 +329,7 @@ class PrinterWatcherCUPS to_hash += caps.printer_defaults; to_hash += caps.defaults_mime_type; - return MD5String(to_hash); + return base::MD5String(to_hash); } std::string printer_name_; @@ -818,4 +818,3 @@ void PrintSystemCUPS::RunCapsCallback( } } // namespace cloud_print - diff --git a/chrome/service/cloud_print/printer_job_handler.cc b/chrome/service/cloud_print/printer_job_handler.cc index 6c4b50c..0d883d8 100644 --- a/chrome/service/cloud_print/printer_job_handler.cc +++ b/chrome/service/cloud_print/printer_job_handler.cc @@ -194,7 +194,8 @@ void PrinterJobHandler::OnReceivePrinterCaps( CloudPrintHelpers::CreateMimeBoundaryForUpload(&mime_boundary); if (succeeded) { - std::string caps_hash = MD5String(caps_and_defaults.printer_capabilities); + std::string caps_hash = + base::MD5String(caps_and_defaults.printer_capabilities); if (caps_hash != printer_info_cloud_.caps_hash) { // Hashes don't match, we need to upload new capabilities (the defaults // go for free along with the capabilities) |