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

Unified Diff: net/quic/quic_utils.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_utils.h ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « net/quic/quic_utils.h ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698