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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
6 | 6 |
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <cstdint> | 13 #include <cstdint> |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
21 #include "net/base/ip_address.h" | 21 #include "net/base/ip_address.h" |
22 #include "net/quic/core/congestion_control/loss_detection_interface.h" | 22 #include "net/quic/core/congestion_control/loss_detection_interface.h" |
23 #include "net/quic/core/congestion_control/send_algorithm_interface.h" | 23 #include "net/quic/core/congestion_control/send_algorithm_interface.h" |
24 #include "net/quic/core/quic_client_push_promise_index.h" | 24 #include "net/quic/core/quic_client_push_promise_index.h" |
25 #include "net/quic/core/quic_connection.h" | 25 #include "net/quic/core/quic_connection.h" |
26 #include "net/quic/core/quic_framer.h" | 26 #include "net/quic/core/quic_framer.h" |
| 27 #include "net/quic/core/quic_iovector.h" |
27 #include "net/quic/core/quic_protocol.h" | 28 #include "net/quic/core/quic_protocol.h" |
28 #include "net/quic/core/quic_sent_packet_manager_interface.h" | 29 #include "net/quic/core/quic_sent_packet_manager_interface.h" |
29 #include "net/quic/core/quic_server_session_base.h" | 30 #include "net/quic/core/quic_server_session_base.h" |
30 #include "net/quic/core/quic_session.h" | 31 #include "net/quic/core/quic_session.h" |
31 #include "net/quic/core/quic_simple_buffer_allocator.h" | 32 #include "net/quic/core/quic_simple_buffer_allocator.h" |
32 #include "net/quic/test_tools/mock_clock.h" | 33 #include "net/quic/test_tools/mock_clock.h" |
33 #include "net/quic/test_tools/mock_random.h" | 34 #include "net/quic/test_tools/mock_random.h" |
34 #include "net/spdy/spdy_framer.h" | 35 #include "net/spdy/spdy_framer.h" |
35 #include "net/tools/quic/quic_dispatcher.h" | 36 #include "net/tools/quic/quic_dispatcher.h" |
36 #include "net/tools/quic/quic_per_connection_packet_writer.h" | 37 #include "net/tools/quic/quic_per_connection_packet_writer.h" |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 l.OnHeaderBlockStart(); | 1041 l.OnHeaderBlockStart(); |
1041 size_t total_size = 0; | 1042 size_t total_size = 0; |
1042 for (auto p : container) { | 1043 for (auto p : container) { |
1043 total_size += p.first.size() + p.second.size(); | 1044 total_size += p.first.size() + p.second.size(); |
1044 l.OnHeader(p.first, p.second); | 1045 l.OnHeader(p.first, p.second); |
1045 } | 1046 } |
1046 l.OnHeaderBlockEnd(total_size); | 1047 l.OnHeaderBlockEnd(total_size); |
1047 return l; | 1048 return l; |
1048 } | 1049 } |
1049 | 1050 |
| 1051 // Utility function that returns an QuicIOVector object wrapped around |str|. |
| 1052 // // |str|'s data is stored in |iov|. |
| 1053 inline QuicIOVector MakeIOVector(base::StringPiece str, struct iovec* iov) { |
| 1054 iov->iov_base = const_cast<char*>(str.data()); |
| 1055 iov->iov_len = static_cast<size_t>(str.size()); |
| 1056 QuicIOVector quic_iov(iov, 1, str.size()); |
| 1057 return quic_iov; |
| 1058 } |
| 1059 |
1050 } // namespace test | 1060 } // namespace test |
1051 } // namespace net | 1061 } // namespace net |
1052 | 1062 |
1053 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 1063 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |