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_CLIENT_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
9 #define NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 9 #define NET_TOOLS_QUIC_QUIC_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/quic/quic_config.h" | 18 #include "net/quic/quic_config.h" |
19 #include "net/quic/quic_data_stream.h" | 19 #include "net/quic/quic_spdy_stream.h" |
20 #include "net/tools/balsa/balsa_headers.h" | 20 #include "net/tools/balsa/balsa_headers.h" |
21 #include "net/tools/epoll_server/epoll_server.h" | 21 #include "net/tools/epoll_server/epoll_server.h" |
22 #include "net/tools/quic/quic_client_base.h" | 22 #include "net/tools/quic/quic_client_base.h" |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 | 25 |
26 class QuicServerId; | 26 class QuicServerId; |
27 | 27 |
28 namespace tools { | 28 namespace tools { |
29 | 29 |
30 class QuicEpollConnectionHelper; | 30 class QuicEpollConnectionHelper; |
31 | 31 |
32 namespace test { | 32 namespace test { |
33 class QuicClientPeer; | 33 class QuicClientPeer; |
34 } // namespace test | 34 } // namespace test |
35 | 35 |
36 class QuicClient : public QuicClientBase, | 36 class QuicClient : public QuicClientBase, |
37 public EpollCallbackInterface, | 37 public EpollCallbackInterface, |
38 public QuicDataStream::Visitor { | 38 public QuicSpdyStream::Visitor { |
39 public: | 39 public: |
40 class ResponseListener { | 40 class ResponseListener { |
41 public: | 41 public: |
42 ResponseListener() {} | 42 ResponseListener() {} |
43 virtual ~ResponseListener() {} | 43 virtual ~ResponseListener() {} |
44 virtual void OnCompleteResponse(QuicStreamId id, | 44 virtual void OnCompleteResponse(QuicStreamId id, |
45 const BalsaHeaders& response_headers, | 45 const BalsaHeaders& response_headers, |
46 const std::string& response_body) = 0; | 46 const std::string& response_body) = 0; |
47 }; | 47 }; |
48 | 48 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // From EpollCallbackInterface | 125 // From EpollCallbackInterface |
126 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} | 126 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} |
127 void OnModification(int fd, int event_mask) override {} | 127 void OnModification(int fd, int event_mask) override {} |
128 void OnEvent(int fd, EpollEvent* event) override; | 128 void OnEvent(int fd, EpollEvent* event) override; |
129 // |fd_| can be unregistered without the client being disconnected. This | 129 // |fd_| can be unregistered without the client being disconnected. This |
130 // happens in b3m QuicProber where we unregister |fd_| to feed in events to | 130 // happens in b3m QuicProber where we unregister |fd_| to feed in events to |
131 // the client from the SelectServer. | 131 // the client from the SelectServer. |
132 void OnUnregistration(int fd, bool replaced) override {} | 132 void OnUnregistration(int fd, bool replaced) override {} |
133 void OnShutdown(EpollServer* eps, int fd) override {} | 133 void OnShutdown(EpollServer* eps, int fd) override {} |
134 | 134 |
135 // QuicDataStream::Visitor | 135 // QuicSpdyStream::Visitor |
136 void OnClose(QuicDataStream* stream) override; | 136 void OnClose(QuicSpdyStream* stream) override; |
137 | 137 |
138 // If the crypto handshake has not yet been confirmed, adds the data to the | 138 // If the crypto handshake has not yet been confirmed, adds the data to the |
139 // queue of data to resend if the client receives a stateless reject. | 139 // queue of data to resend if the client receives a stateless reject. |
140 // Otherwise, deletes the data. Takes ownerership of |data_to_resend|. | 140 // Otherwise, deletes the data. Takes ownerership of |data_to_resend|. |
141 void MaybeAddQuicDataToResend(QuicDataToResend* data_to_resend); | 141 void MaybeAddQuicDataToResend(QuicDataToResend* data_to_resend); |
142 | 142 |
143 void set_bind_to_address(IPAddressNumber address) { | 143 void set_bind_to_address(IPAddressNumber address) { |
144 bind_to_address_ = address; | 144 bind_to_address_ = address; |
145 } | 145 } |
146 | 146 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // must be resent upon a subsequent successful connection. | 264 // must be resent upon a subsequent successful connection. |
265 std::vector<QuicDataToResend*> data_to_resend_on_connect_; | 265 std::vector<QuicDataToResend*> data_to_resend_on_connect_; |
266 | 266 |
267 DISALLOW_COPY_AND_ASSIGN(QuicClient); | 267 DISALLOW_COPY_AND_ASSIGN(QuicClient); |
268 }; | 268 }; |
269 | 269 |
270 } // namespace tools | 270 } // namespace tools |
271 } // namespace net | 271 } // namespace net |
272 | 272 |
273 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 273 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
OLD | NEW |