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 // Some helpers for quic. | 5 // Some helpers for quic. |
6 | 6 |
7 #ifndef NET_QUIC_QUIC_UTILS_H_ | 7 #ifndef NET_QUIC_QUIC_UTILS_H_ |
8 #define NET_QUIC_QUIC_UTILS_H_ | 8 #define NET_QUIC_QUIC_UTILS_H_ |
9 | 9 |
10 #include "net/base/int128.h" | 10 #include "net/base/int128.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // returns the 128 bit FNV1a hash of the data. See | 27 // returns the 128 bit FNV1a hash of the data. See |
28 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param | 28 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param |
29 static uint128 FNV1a_128_Hash(const char* data, int len); | 29 static uint128 FNV1a_128_Hash(const char* data, int len); |
30 | 30 |
31 // FindMutualTag sets |out_result| to the first tag in the priority list that | 31 // FindMutualTag sets |out_result| to the first tag in the priority list that |
32 // is also in the other list and returns true. If there is no intersection it | 32 // is also in the other list and returns true. If there is no intersection it |
33 // returns false. | 33 // returns false. |
34 // | 34 // |
35 // Which list has priority is determined by |priority|. | 35 // Which list has priority is determined by |priority|. |
36 // | 36 // |
37 // If |out_index| is non-NULL and a match is found then the index of that | 37 // If |out_index| is non-nullptr and a match is found then the index of that |
38 // match in |their_tags| is written to |out_index|. | 38 // match in |their_tags| is written to |out_index|. |
39 static bool FindMutualTag(const QuicTagVector& our_tags, | 39 static bool FindMutualTag(const QuicTagVector& our_tags, |
40 const QuicTag* their_tags, | 40 const QuicTag* their_tags, |
41 size_t num_their_tags, | 41 size_t num_their_tags, |
42 Priority priority, | 42 Priority priority, |
43 QuicTag* out_result, | 43 QuicTag* out_result, |
44 size_t* out_index); | 44 size_t* out_index); |
45 | 45 |
46 // SerializeUint128 writes |v| in little-endian form to |out|. | 46 // SerializeUint128 writes |v| in little-endian form to |out|. |
47 static void SerializeUint128(uint128 v, uint8* out); | 47 static void SerializeUint128(uint128 v, uint8* out); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Utility function that returns an IOVector object wrapped around |str|. | 90 // Utility function that returns an IOVector object wrapped around |str|. |
91 inline IOVector MakeIOVector(base::StringPiece str) { | 91 inline IOVector MakeIOVector(base::StringPiece str) { |
92 IOVector iov; | 92 IOVector iov; |
93 iov.Append(const_cast<char*>(str.data()), str.size()); | 93 iov.Append(const_cast<char*>(str.data()), str.size()); |
94 return iov; | 94 return iov; |
95 } | 95 } |
96 | 96 |
97 } // namespace net | 97 } // namespace net |
98 | 98 |
99 #endif // NET_QUIC_QUIC_UTILS_H_ | 99 #endif // NET_QUIC_QUIC_UTILS_H_ |
OLD | NEW |