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 <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "net/base/int128.h" | 17 #include "net/base/int128.h" |
18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
20 | 20 |
| 21 #ifdef _MSC_VER |
| 22 // MSVC 2013 and prior don't have alignof or aligned(); they have __alignof and |
| 23 // a __declspec instead. |
| 24 #define QUIC_ALIGN_OF __alignof |
| 25 #define QUIC_ALIGNED(X) __declspec(align(X)) |
| 26 #else |
| 27 #define QUIC_ALIGN_OF alignof |
| 28 #define QUIC_ALIGNED(X) __attribute__((aligned(X))) |
| 29 #endif // _MSC_VER |
| 30 |
21 namespace net { | 31 namespace net { |
22 | 32 |
23 class NET_EXPORT_PRIVATE QuicUtils { | 33 class NET_EXPORT_PRIVATE QuicUtils { |
24 public: | 34 public: |
25 enum Priority { | 35 enum Priority { |
26 LOCAL_PRIORITY, | 36 LOCAL_PRIORITY, |
27 PEER_PRIORITY, | 37 PEER_PRIORITY, |
28 }; | 38 }; |
29 | 39 |
30 // Returns the 64 bit FNV1a hash of the data. See | 40 // Returns the 64 bit FNV1a hash of the data. See |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 inline QuicIOVector MakeIOVector(base::StringPiece str, struct iovec* iov) { | 114 inline QuicIOVector MakeIOVector(base::StringPiece str, struct iovec* iov) { |
105 iov->iov_base = const_cast<char*>(str.data()); | 115 iov->iov_base = const_cast<char*>(str.data()); |
106 iov->iov_len = static_cast<size_t>(str.size()); | 116 iov->iov_len = static_cast<size_t>(str.size()); |
107 QuicIOVector quic_iov(iov, 1, str.size()); | 117 QuicIOVector quic_iov(iov, 1, str.size()); |
108 return quic_iov; | 118 return quic_iov; |
109 } | 119 } |
110 | 120 |
111 } // namespace net | 121 } // namespace net |
112 | 122 |
113 #endif // NET_QUIC_QUIC_UTILS_H_ | 123 #endif // NET_QUIC_QUIC_UTILS_H_ |
OLD | NEW |