OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/quic/quic_utils.h" | 5 #include "net/quic/quic_utils.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/port.h" | 8 #include "base/port.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 // static | 12 // static |
13 size_t QuicUtils::StreamFramePacketOverhead(int num_frames) { | 13 size_t QuicUtils::StreamFramePacketOverhead(int num_frames) { |
14 // TODO(jar): Use sizeof(some name). | 14 // TODO(jar): Use sizeof(some name). |
15 return kPacketHeaderSize + | 15 return kPacketHeaderSize + |
16 1 + // frame count | 16 1 + // frame count |
17 (1 + // 8 bit type | 17 (1 + // 8 bit type |
18 2 + // 16 bit length | |
19 kMinStreamFrameLength) * num_frames; | 18 kMinStreamFrameLength) * num_frames; |
20 } | 19 } |
21 | 20 |
22 uint128 QuicUtils::FNV1a_128_Hash(const char* data, int len) { | 21 uint128 QuicUtils::FNV1a_128_Hash(const char* data, int len) { |
23 // The following two constants are defined as part of the hash algorithm. | 22 // The following two constants are defined as part of the hash algorithm. |
24 // 309485009821345068724781371 | 23 // 309485009821345068724781371 |
25 const uint128 kPrime(16777216, 315); | 24 const uint128 kPrime(16777216, 315); |
26 // 14406626329776981559649562966706236762 | 25 // 14406626329776981559649562966706236762 |
27 const uint128 kOffset(GG_UINT64_C(780984778246553632), | 26 const uint128 kOffset(GG_UINT64_C(780984778246553632), |
28 GG_UINT64_C(4400696054689967450)); | 27 GG_UINT64_C(4400696054689967450)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 RETURN_STRING_LITERAL(QUIC_INVALID_STREAM_ID); | 69 RETURN_STRING_LITERAL(QUIC_INVALID_STREAM_ID); |
71 RETURN_STRING_LITERAL(QUIC_TOO_MANY_OPEN_STREAMS); | 70 RETURN_STRING_LITERAL(QUIC_TOO_MANY_OPEN_STREAMS); |
72 RETURN_STRING_LITERAL(QUIC_CONNECTION_TIMED_OUT); | 71 RETURN_STRING_LITERAL(QUIC_CONNECTION_TIMED_OUT); |
73 // Intentionally have no default case, so we'll break the build | 72 // Intentionally have no default case, so we'll break the build |
74 // if we add errors and don't put them here. | 73 // if we add errors and don't put them here. |
75 } | 74 } |
76 return ""; | 75 return ""; |
77 } | 76 } |
78 | 77 |
79 } // namespace net | 78 } // namespace net |
OLD | NEW |