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

Side by Side Diff: components/visitedlink/common/visitedlink_common.cc

Issue 1549993003: Switch to standard integer types in components/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/visitedlink/common/visitedlink_common.h" 5 #include "components/visitedlink/common/visitedlink_common.h"
6 6
7 #include <string.h> // for memset() 7 #include <string.h> // for memset()
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/md5.h" 10 #include "base/md5.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // 71 //
72 // FIXME: this uses the MD5SUM of the 16-bit character version. For systems 72 // FIXME: this uses the MD5SUM of the 16-bit character version. For systems
73 // where wchar_t is not 16 bits (Linux uses 32 bits, I think), this will not be 73 // where wchar_t is not 16 bits (Linux uses 32 bits, I think), this will not be
74 // compatable. We should define explicitly what should happen here across 74 // compatable. We should define explicitly what should happen here across
75 // platforms, and convert if necessary (probably to UTF-16). 75 // platforms, and convert if necessary (probably to UTF-16).
76 76
77 // static 77 // static
78 VisitedLinkCommon::Fingerprint VisitedLinkCommon::ComputeURLFingerprint( 78 VisitedLinkCommon::Fingerprint VisitedLinkCommon::ComputeURLFingerprint(
79 const char* canonical_url, 79 const char* canonical_url,
80 size_t url_len, 80 size_t url_len,
81 const uint8 salt[LINK_SALT_LENGTH]) { 81 const uint8_t salt[LINK_SALT_LENGTH]) {
82 DCHECK(url_len > 0) << "Canonical URLs should not be empty"; 82 DCHECK(url_len > 0) << "Canonical URLs should not be empty";
83 83
84 base::MD5Context ctx; 84 base::MD5Context ctx;
85 base::MD5Init(&ctx); 85 base::MD5Init(&ctx);
86 base::MD5Update(&ctx, base::StringPiece(reinterpret_cast<const char*>(salt), 86 base::MD5Update(&ctx, base::StringPiece(reinterpret_cast<const char*>(salt),
87 LINK_SALT_LENGTH)); 87 LINK_SALT_LENGTH));
88 base::MD5Update(&ctx, base::StringPiece(canonical_url, url_len)); 88 base::MD5Update(&ctx, base::StringPiece(canonical_url, url_len));
89 89
90 base::MD5Digest digest; 90 base::MD5Digest digest;
91 base::MD5Final(&digest, &ctx); 91 base::MD5Final(&digest, &ctx);
92 92
93 // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that 93 // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that
94 // direct cast the alignment could be wrong, and we can't access a 64-bit int 94 // direct cast the alignment could be wrong, and we can't access a 64-bit int
95 // on arbitrary alignment on some processors. This reinterpret_casts it 95 // on arbitrary alignment on some processors. This reinterpret_casts it
96 // down to a char array of the same size as fingerprint, and then does the 96 // down to a char array of the same size as fingerprint, and then does the
97 // bit cast, which amounts to a memcpy. This does not handle endian issues. 97 // bit cast, which amounts to a memcpy. This does not handle endian issues.
98 return bit_cast<Fingerprint, uint8[8]>( 98 return bit_cast<Fingerprint, uint8_t[8]>(
99 *reinterpret_cast<uint8(*)[8]>(&digest.a)); 99 *reinterpret_cast<uint8_t(*)[8]>(&digest.a));
100 } 100 }
101 101
102 } // namespace visitedlink 102 } // namespace visitedlink
OLDNEW
« no previous file with comments | « components/visitedlink/common/visitedlink_common.h ('k') | components/visitedlink/common/visitedlink_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698