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 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 5 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
13 #include "net/quic/quic_framer.h" | 13 #include "net/quic/quic_framer.h" |
14 #include "net/quic/quic_packet_creator.h" | 14 #include "net/quic/quic_packet_creator.h" |
15 #include "net/quic/quic_protocol.h" | 15 #include "net/quic/quic_protocol.h" |
16 #include "net/tools/balsa/balsa_frame.h" | 16 #include "net/tools/balsa/balsa_frame.h" |
| 17 #include "net/tools/epoll_server/epoll_server.h" |
17 #include "net/tools/quic/quic_client.h" | 18 #include "net/tools/quic/quic_client.h" |
18 #include "net/tools/quic/test_tools/simple_client.h" | 19 #include "net/tools/quic/test_tools/simple_client.h" |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 class ProofVerifier; | 23 class ProofVerifier; |
23 | 24 |
24 namespace tools { | 25 namespace tools { |
25 | 26 |
26 class QuicPacketWriterWrapper; | 27 class QuicPacketWriterWrapper; |
27 | 28 |
28 namespace test { | 29 namespace test { |
29 | 30 |
30 class HTTPMessage; | 31 class HTTPMessage; |
31 class MockableQuicClient; | 32 class MockableQuicClient; |
32 | 33 |
33 // A quic client which allows mocking out writes. | 34 // A quic client which allows mocking out writes. |
34 class MockableQuicClient : public QuicClient { | 35 class MockableQuicClient : public QuicClient { |
35 public: | 36 public: |
36 MockableQuicClient(IPEndPoint server_address, | 37 MockableQuicClient(IPEndPoint server_address, |
37 const QuicServerId& server_id, | 38 const QuicServerId& server_id, |
38 const QuicVersionVector& supported_versions); | 39 const QuicVersionVector& supported_versions, |
| 40 EpollServer* epoll_server); |
39 | 41 |
40 MockableQuicClient(IPEndPoint server_address, | 42 MockableQuicClient(IPEndPoint server_address, |
41 const QuicServerId& server_id, | 43 const QuicServerId& server_id, |
42 const QuicConfig& config, | 44 const QuicConfig& config, |
43 const QuicVersionVector& supported_versions); | 45 const QuicVersionVector& supported_versions, |
| 46 EpollServer* epoll_server); |
44 | 47 |
45 virtual ~MockableQuicClient() OVERRIDE; | 48 virtual ~MockableQuicClient() OVERRIDE; |
46 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE; | 49 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE; |
47 virtual QuicConnectionId GenerateConnectionId() OVERRIDE; | 50 virtual QuicConnectionId GenerateConnectionId() OVERRIDE; |
48 void UseWriter(QuicPacketWriterWrapper* writer); | 51 void UseWriter(QuicPacketWriterWrapper* writer); |
49 void UseConnectionId(QuicConnectionId connection_id); | 52 void UseConnectionId(QuicConnectionId connection_id); |
50 | 53 |
51 private: | 54 private: |
52 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero | 55 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero |
53 QuicPacketWriterWrapper* test_writer_; | 56 QuicPacketWriterWrapper* test_writer_; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; } | 153 void set_auto_reconnect(bool reconnect) { auto_reconnect_ = reconnect; } |
151 | 154 |
152 void set_priority(QuicPriority priority) { priority_ = priority; } | 155 void set_priority(QuicPriority priority) { priority_ = priority; } |
153 | 156 |
154 // Sets client's FEC policy. This policy applies to the data stream(s), and | 157 // Sets client's FEC policy. This policy applies to the data stream(s), and |
155 // also to the headers and crypto streams. | 158 // also to the headers and crypto streams. |
156 void SetFecPolicy(FecPolicy fec_policy); | 159 void SetFecPolicy(FecPolicy fec_policy); |
157 | 160 |
158 void WaitForWriteToFlush(); | 161 void WaitForWriteToFlush(); |
159 | 162 |
| 163 EpollServer* epoll_server() { return &epoll_server_; } |
| 164 |
160 protected: | 165 protected: |
161 QuicTestClient(); | 166 QuicTestClient(); |
162 | 167 |
163 void Initialize(bool secure); | 168 void Initialize(bool secure); |
164 | 169 |
165 void set_client(MockableQuicClient* client) { client_.reset(client); } | 170 void set_client(MockableQuicClient* client) { client_.reset(client); } |
166 | 171 |
167 private: | 172 private: |
| 173 EpollServer epoll_server_; |
168 scoped_ptr<MockableQuicClient> client_; // The actual client | 174 scoped_ptr<MockableQuicClient> client_; // The actual client |
169 QuicSpdyClientStream* stream_; | 175 QuicSpdyClientStream* stream_; |
170 | 176 |
171 QuicRstStreamErrorCode stream_error_; | 177 QuicRstStreamErrorCode stream_error_; |
172 | 178 |
173 bool response_complete_; | 179 bool response_complete_; |
174 bool response_headers_complete_; | 180 bool response_headers_complete_; |
175 BalsaHeaders headers_; | 181 BalsaHeaders headers_; |
176 QuicPriority priority_; | 182 QuicPriority priority_; |
177 string response_; | 183 string response_; |
(...skipping 20 matching lines...) Expand all Loading... |
198 | 204 |
199 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); | 205 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); |
200 }; | 206 }; |
201 | 207 |
202 } // namespace test | 208 } // namespace test |
203 | 209 |
204 } // namespace tools | 210 } // namespace tools |
205 } // namespace net | 211 } // namespace net |
206 | 212 |
207 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 213 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
OLD | NEW |