| Index: net/quic/quic_utils.cc
|
| diff --git a/net/quic/quic_utils.cc b/net/quic/quic_utils.cc
|
| index f8b31c4002d4de413d4c8e8baa8959729577021c..17e74618708dafcbd6b97ee81bcca731cf1e0d0c 100644
|
| --- a/net/quic/quic_utils.cc
|
| +++ b/net/quic/quic_utils.cc
|
| @@ -42,23 +42,36 @@ uint64 QuicUtils::FNV1a_64_Hash(const char* data, int len) {
|
|
|
| // static
|
| uint128 QuicUtils::FNV1a_128_Hash(const char* data, int len) {
|
| - // The following two constants are defined as part of the hash algorithm.
|
| + return FNV1a_128_Hash_Two(data, len, nullptr, 0);
|
| +}
|
| +
|
| +// static
|
| +uint128 QuicUtils::FNV1a_128_Hash_Two(const char* data1,
|
| + int len1,
|
| + const char* data2,
|
| + int len2) {
|
| + // The two constants are defined as part of the hash algorithm.
|
| // see http://www.isthe.com/chongo/tech/comp/fnv/
|
| - // 309485009821345068724781371
|
| - const uint128 kPrime(16777216, 315);
|
| // 144066263297769815596495629667062367629
|
| const uint128 kOffset(GG_UINT64_C(7809847782465536322),
|
| GG_UINT64_C(7113472399480571277));
|
|
|
| - const uint8* octets = reinterpret_cast<const uint8*>(data);
|
| -
|
| - uint128 hash = kOffset;
|
| + uint128 hash = IncrementalHash(kOffset, data1, len1);
|
| + if (data2 == nullptr) {
|
| + return hash;
|
| + }
|
| + return IncrementalHash(hash, data2, len2);
|
| +}
|
|
|
| - for (int i = 0; i < len; ++i) {
|
| +// static
|
| +uint128 QuicUtils::IncrementalHash(uint128 hash, const char* data, size_t len) {
|
| + // 309485009821345068724781371
|
| + const uint128 kPrime(16777216, 315);
|
| + const uint8* octets = reinterpret_cast<const uint8*>(data);
|
| + for (size_t i = 0; i < len; ++i) {
|
| hash = hash ^ uint128(0, octets[i]);
|
| hash = hash * kPrime;
|
| }
|
| -
|
| return hash;
|
| }
|
|
|
| @@ -221,6 +234,7 @@ const char* QuicUtils::ErrorToString(QuicErrorCode error) {
|
| RETURN_STRING_LITERAL(QUIC_VERSION_NEGOTIATION_MISMATCH);
|
| RETURN_STRING_LITERAL(QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS);
|
| RETURN_STRING_LITERAL(QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS);
|
| + RETURN_STRING_LITERAL(QUIC_CONNECTION_CANCELLED);
|
| RETURN_STRING_LITERAL(QUIC_LAST_ERROR);
|
| // Intentionally have no default case, so we'll break the build
|
| // if we add errors and don't put them here.
|
|
|