OLD | NEW |
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/bit_cast.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/md5.h" | 11 #include "base/md5.h" |
11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
12 | 13 |
13 namespace visitedlink { | 14 namespace visitedlink { |
14 | 15 |
15 const VisitedLinkCommon::Fingerprint VisitedLinkCommon::null_fingerprint_ = 0; | 16 const VisitedLinkCommon::Fingerprint VisitedLinkCommon::null_fingerprint_ = 0; |
16 const VisitedLinkCommon::Hash VisitedLinkCommon::null_hash_ = -1; | 17 const VisitedLinkCommon::Hash VisitedLinkCommon::null_hash_ = -1; |
17 | 18 |
18 VisitedLinkCommon::VisitedLinkCommon() | 19 VisitedLinkCommon::VisitedLinkCommon() |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // This is the same as "return *(Fingerprint*)&digest.a;" but if we do that | 94 // 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 | 95 // 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 | 96 // 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 | 97 // 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. | 98 // bit cast, which amounts to a memcpy. This does not handle endian issues. |
98 return bit_cast<Fingerprint, uint8_t[8]>( | 99 return bit_cast<Fingerprint, uint8_t[8]>( |
99 *reinterpret_cast<uint8_t(*)[8]>(&digest.a)); | 100 *reinterpret_cast<uint8_t(*)[8]>(&digest.a)); |
100 } | 101 } |
101 | 102 |
102 } // namespace visitedlink | 103 } // namespace visitedlink |
OLD | NEW |