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 <string> | 10 #include <string> |
(...skipping 10 matching lines...) Expand all Loading... |
21 LOCAL_PRIORITY, | 21 LOCAL_PRIORITY, |
22 PEER_PRIORITY, | 22 PEER_PRIORITY, |
23 }; | 23 }; |
24 | 24 |
25 // Returns the 64 bit FNV1a hash of the data. See | 25 // Returns the 64 bit FNV1a hash of the data. See |
26 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param | 26 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param |
27 static uint64 FNV1a_64_Hash(const char* data, int len); | 27 static uint64 FNV1a_64_Hash(const char* data, int len); |
28 | 28 |
29 // returns the 128 bit FNV1a hash of the data. See | 29 // returns the 128 bit FNV1a hash of the data. See |
30 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param | 30 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param |
31 static uint128 FNV1a_128_Hash(const char* data, int len); | 31 static uint128 FNV1a_128_Hash(const char* data1, int len1); |
| 32 |
| 33 // returns the 128 bit FNV1a hash of the two sequences of data. See |
| 34 // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param |
| 35 static uint128 FNV1a_128_Hash_Two(const char* data1, |
| 36 int len1, |
| 37 const char* data2, |
| 38 int len2); |
| 39 |
| 40 // returns the 128 bit FNV1a hash of the |data|, starting with the |
| 41 // previous hash. |
| 42 static uint128 IncrementalHash(uint128 hash, const char* data, size_t len); |
32 | 43 |
33 // FindMutualTag sets |out_result| to the first tag in the priority list that | 44 // FindMutualTag sets |out_result| to the first tag in the priority list that |
34 // is also in the other list and returns true. If there is no intersection it | 45 // is also in the other list and returns true. If there is no intersection it |
35 // returns false. | 46 // returns false. |
36 // | 47 // |
37 // Which list has priority is determined by |priority|. | 48 // Which list has priority is determined by |priority|. |
38 // | 49 // |
39 // If |out_index| is non-nullptr and a match is found then the index of that | 50 // If |out_index| is non-nullptr and a match is found then the index of that |
40 // match in |their_tags| is written to |out_index|. | 51 // match in |their_tags| is written to |out_index|. |
41 static bool FindMutualTag(const QuicTagVector& our_tags, | 52 static bool FindMutualTag(const QuicTagVector& our_tags, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Utility function that returns an IOVector object wrapped around |str|. | 108 // Utility function that returns an IOVector object wrapped around |str|. |
98 inline IOVector MakeIOVector(base::StringPiece str) { | 109 inline IOVector MakeIOVector(base::StringPiece str) { |
99 IOVector iov; | 110 IOVector iov; |
100 iov.Append(const_cast<char*>(str.data()), str.size()); | 111 iov.Append(const_cast<char*>(str.data()), str.size()); |
101 return iov; | 112 return iov; |
102 } | 113 } |
103 | 114 |
104 } // namespace net | 115 } // namespace net |
105 | 116 |
106 #endif // NET_QUIC_QUIC_UTILS_H_ | 117 #endif // NET_QUIC_QUIC_UTILS_H_ |
OLD | NEW |