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 // A toy client, which connects to a specified port and sends QUIC | 5 // A toy client, which connects to a specified port and sends QUIC |
6 // request to that endpoint. | 6 // request to that endpoint. |
7 | 7 |
8 #ifndef NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ |
9 #define NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ | 9 #define NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
18 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
19 #include "net/log/net_log.h" | 19 #include "net/log/net_log.h" |
20 #include "net/quic/quic_config.h" | 20 #include "net/quic/quic_config.h" |
21 #include "net/quic/quic_data_stream.h" | |
22 #include "net/quic/quic_packet_reader.h" | 21 #include "net/quic/quic_packet_reader.h" |
| 22 #include "net/quic/quic_spdy_stream.h" |
23 #include "net/tools/quic/quic_client_base.h" | 23 #include "net/tools/quic/quic_client_base.h" |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 | 26 |
27 struct HttpRequestInfo; | 27 struct HttpRequestInfo; |
28 class QuicConnectionHelper; | 28 class QuicConnectionHelper; |
29 class UDPClientSocket; | 29 class UDPClientSocket; |
30 | 30 |
31 namespace tools { | 31 namespace tools { |
32 | 32 |
33 namespace test { | 33 namespace test { |
34 class QuicClientPeer; | 34 class QuicClientPeer; |
35 } // namespace test | 35 } // namespace test |
36 | 36 |
37 class QuicSimpleClient : public QuicClientBase, | 37 class QuicSimpleClient : public QuicClientBase, |
38 public QuicDataStream::Visitor, | 38 public QuicSpdyStream::Visitor, |
39 public QuicPacketReader::Visitor { | 39 public QuicPacketReader::Visitor { |
40 public: | 40 public: |
41 class ResponseListener { | 41 class ResponseListener { |
42 public: | 42 public: |
43 ResponseListener() {} | 43 ResponseListener() {} |
44 virtual ~ResponseListener() {} | 44 virtual ~ResponseListener() {} |
45 virtual void OnCompleteResponse(QuicStreamId id, | 45 virtual void OnCompleteResponse(QuicStreamId id, |
46 const HttpResponseHeaders& response_headers, | 46 const HttpResponseHeaders& response_headers, |
47 const std::string& response_body) = 0; | 47 const std::string& response_body) = 0; |
48 }; | 48 }; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // Migrate to a new socket during an active connection. | 124 // Migrate to a new socket during an active connection. |
125 bool MigrateSocket(const IPAddressNumber& new_host); | 125 bool MigrateSocket(const IPAddressNumber& new_host); |
126 | 126 |
127 // QuicPacketReader::Visitor | 127 // QuicPacketReader::Visitor |
128 void OnReadError(int result) override; | 128 void OnReadError(int result) override; |
129 bool OnPacket(const QuicEncryptedPacket& packet, | 129 bool OnPacket(const QuicEncryptedPacket& packet, |
130 IPEndPoint local_address, | 130 IPEndPoint local_address, |
131 IPEndPoint peer_address) override; | 131 IPEndPoint peer_address) override; |
132 | 132 |
133 // QuicDataStream::Visitor | 133 // QuicSpdyStream::Visitor |
134 void OnClose(QuicDataStream* stream) override; | 134 void OnClose(QuicSpdyStream* stream) override; |
135 | 135 |
136 // If the crypto handshake has not yet been confirmed, adds the data to the | 136 // If the crypto handshake has not yet been confirmed, adds the data to the |
137 // queue of data to resend if the client receives a stateless reject. | 137 // queue of data to resend if the client receives a stateless reject. |
138 // Otherwise, deletes the data. Takes ownerership of |data_to_resend|. | 138 // Otherwise, deletes the data. Takes ownerership of |data_to_resend|. |
139 void MaybeAddQuicDataToResend(QuicDataToResend* data_to_resend); | 139 void MaybeAddQuicDataToResend(QuicDataToResend* data_to_resend); |
140 | 140 |
141 void set_bind_to_address(IPAddressNumber address) { | 141 void set_bind_to_address(IPAddressNumber address) { |
142 bind_to_address_ = address; | 142 bind_to_address_ = address; |
143 } | 143 } |
144 | 144 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 base::WeakPtrFactory<QuicSimpleClient> weak_factory_; | 260 base::WeakPtrFactory<QuicSimpleClient> weak_factory_; |
261 | 261 |
262 DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient); | 262 DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient); |
263 }; | 263 }; |
264 | 264 |
265 } // namespace tools | 265 } // namespace tools |
266 } // namespace net | 266 } // namespace net |
267 | 267 |
268 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ | 268 #endif // NET_TOOLS_QUIC_QUIC_SIMPLE_CLIENT_H_ |
OLD | NEW |