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

Side by Side Diff: chrome/common/visitedlink_common.cc

Issue 40226: Fix files with lines > 80 cols. Part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/visitedlink_common.h ('k') | chrome/common/win_safe_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/common/visitedlink_common.h" 5 #include "chrome/common/visitedlink_common.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/md5.h" 8 #include "base/md5.h"
9 9
10 const VisitedLinkCommon::Fingerprint VisitedLinkCommon::null_fingerprint_ = 0; 10 const VisitedLinkCommon::Fingerprint VisitedLinkCommon::null_fingerprint_ = 0;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // infinite loop because AddFingerprint didn't do its job resizing. 55 // infinite loop because AddFingerprint didn't do its job resizing.
56 NOTREACHED(); 56 NOTREACHED();
57 return false; 57 return false;
58 } 58 }
59 } 59 }
60 } 60 }
61 61
62 // Uses the top 64 bits of the MD5 sum of the canonical URL as the fingerprint, 62 // Uses the top 64 bits of the MD5 sum of the canonical URL as the fingerprint,
63 // this is as random as any other subset of the MD5SUM. 63 // this is as random as any other subset of the MD5SUM.
64 // 64 //
65 // FIXME: this uses the MD5SUM of the 16-bit character version. For systems wher e 65 // FIXME: this uses the MD5SUM of the 16-bit character version. For systems
66 // wchar_t is not 16 bits (Linux uses 32 bits, I think), this will not be 66 // where wchar_t is not 16 bits (Linux uses 32 bits, I think), this will not be
67 // compatable. We should define explicitly what should happen here across 67 // compatable. We should define explicitly what should happen here across
68 // platforms, and convert if necessary (probably to UTF-16). 68 // platforms, and convert if necessary (probably to UTF-16).
69 69
70 // static 70 // static
71 VisitedLinkCommon::Fingerprint VisitedLinkCommon::ComputeURLFingerprint( 71 VisitedLinkCommon::Fingerprint VisitedLinkCommon::ComputeURLFingerprint(
72 const char* canonical_url, 72 const char* canonical_url,
73 size_t url_len, 73 size_t url_len,
74 const uint8 salt[LINK_SALT_LENGTH]) { 74 const uint8 salt[LINK_SALT_LENGTH]) {
75 DCHECK(url_len > 0) << "Canonical URLs should not be empty"; 75 DCHECK(url_len > 0) << "Canonical URLs should not be empty";
76 76
77 MD5Context ctx; 77 MD5Context ctx;
78 MD5Init(&ctx); 78 MD5Init(&ctx);
79 MD5Update(&ctx, salt, sizeof(salt)); 79 MD5Update(&ctx, salt, sizeof(salt));
80 MD5Update(&ctx, canonical_url, url_len * sizeof(char)); 80 MD5Update(&ctx, canonical_url, url_len * sizeof(char));
81 81
82 MD5Digest digest; 82 MD5Digest digest;
83 MD5Final(&digest, &ctx); 83 MD5Final(&digest, &ctx);
84 84
85 // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that 85 // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that
86 // direct cast the alignment could be wrong, and we can't access a 64-bit int 86 // direct cast the alignment could be wrong, and we can't access a 64-bit int
87 // on arbitrary alignment on some processors. This reinterpret_casts it 87 // on arbitrary alignment on some processors. This reinterpret_casts it
88 // down to a char array of the same size as fingerprint, and then does the 88 // down to a char array of the same size as fingerprint, and then does the
89 // bit cast, which amounts to a memcpy. This does not handle endian issues. 89 // bit cast, which amounts to a memcpy. This does not handle endian issues.
90 return bit_cast<Fingerprint, uint8[8]>( 90 return bit_cast<Fingerprint, uint8[8]>(
91 *reinterpret_cast<uint8(*)[8]>(&digest.a)); 91 *reinterpret_cast<uint8(*)[8]>(&digest.a));
92 } 92 }
OLDNEW
« no previous file with comments | « chrome/common/visitedlink_common.h ('k') | chrome/common/win_safe_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698