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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 private: | 59 private: |
60 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero | 60 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero |
61 QuicPacketWriterWrapper* test_writer_; | 61 QuicPacketWriterWrapper* test_writer_; |
62 CachedNetworkParameters cached_network_paramaters_; | 62 CachedNetworkParameters cached_network_paramaters_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); | 64 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); |
65 }; | 65 }; |
66 | 66 |
67 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. | 67 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. |
68 class QuicTestClient : public SimpleClient, | 68 class QuicTestClient : public SimpleClient, public QuicSpdyStream::Visitor { |
69 public QuicDataStream::Visitor { | |
70 public: | 69 public: |
71 QuicTestClient(IPEndPoint server_address, | 70 QuicTestClient(IPEndPoint server_address, |
72 const std::string& server_hostname, | 71 const std::string& server_hostname, |
73 bool secure, | 72 bool secure, |
74 const QuicVersionVector& supported_versions); | 73 const QuicVersionVector& supported_versions); |
75 QuicTestClient(IPEndPoint server_address, | 74 QuicTestClient(IPEndPoint server_address, |
76 const std::string& server_hostname, | 75 const std::string& server_hostname, |
77 bool secure, | 76 bool secure, |
78 const QuicConfig& config, | 77 const QuicConfig& config, |
79 const QuicVersionVector& supported_versions); | 78 const QuicVersionVector& supported_versions); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // DFATAL if called by users of SimpleClient. | 131 // DFATAL if called by users of SimpleClient. |
133 ssize_t SendAndWaitForResponse(const void* buffer, size_t size) override; | 132 ssize_t SendAndWaitForResponse(const void* buffer, size_t size) override; |
134 void Bind(IPEndPoint* local_address) override; | 133 void Bind(IPEndPoint* local_address) override; |
135 void MigrateSocket(const IPAddressNumber& new_host) override; | 134 void MigrateSocket(const IPAddressNumber& new_host) override; |
136 std::string SerializeMessage(const HTTPMessage& message) override; | 135 std::string SerializeMessage(const HTTPMessage& message) override; |
137 IPAddressNumber bind_to_address() const override; | 136 IPAddressNumber bind_to_address() const override; |
138 void set_bind_to_address(IPAddressNumber address) override; | 137 void set_bind_to_address(IPAddressNumber address) override; |
139 const IPEndPoint& address() const override; | 138 const IPEndPoint& address() const override; |
140 size_t requests_sent() const override; | 139 size_t requests_sent() const override; |
141 | 140 |
142 // From QuicDataStream::Visitor | 141 // From QuicSpdyStream::Visitor |
143 void OnClose(QuicDataStream* stream) override; | 142 void OnClose(QuicSpdyStream* stream) override; |
144 | 143 |
145 // Configures client_ to take ownership of and use the writer. | 144 // Configures client_ to take ownership of and use the writer. |
146 // Must be called before initial connect. | 145 // Must be called before initial connect. |
147 void UseWriter(QuicPacketWriterWrapper* writer); | 146 void UseWriter(QuicPacketWriterWrapper* writer); |
148 // If the given ConnectionId is nonzero, configures client_ to use a specific | 147 // If the given ConnectionId is nonzero, configures client_ to use a specific |
149 // ConnectionId instead of a random one. | 148 // ConnectionId instead of a random one. |
150 void UseConnectionId(QuicConnectionId connection_id); | 149 void UseConnectionId(QuicConnectionId connection_id); |
151 | 150 |
152 // Returns nullptr if the maximum number of streams have already been created. | 151 // Returns nullptr if the maximum number of streams have already been created. |
153 QuicSpdyClientStream* GetOrCreateStream(); | 152 QuicSpdyClientStream* GetOrCreateStream(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 257 |
259 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); | 258 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); |
260 }; | 259 }; |
261 | 260 |
262 } // namespace test | 261 } // namespace test |
263 | 262 |
264 } // namespace tools | 263 } // namespace tools |
265 } // namespace net | 264 } // namespace net |
266 | 265 |
267 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 266 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
OLD | NEW |