| 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 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 BalsaHeaders& response_headers, | 46 const BalsaHeaders& response_headers, |
| 47 const string& response_body) = 0; | 47 const string& response_body) = 0; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 QuicClient(IPEndPoint server_address, | 50 // Create a quic client, which will have events managed by an externally owned |
| 51 const QuicServerId& server_id, | 51 // EpollServer. |
| 52 const QuicVersionVector& supported_versions, | |
| 53 bool print_response); | |
| 54 QuicClient(IPEndPoint server_address, | 52 QuicClient(IPEndPoint server_address, |
| 55 const QuicServerId& server_id, | 53 const QuicServerId& server_id, |
| 56 const QuicVersionVector& supported_versions, | 54 const QuicVersionVector& supported_versions, |
| 57 bool print_response, | 55 bool print_response, |
| 58 const QuicConfig& config); | 56 EpollServer* epoll_server); |
| 57 QuicClient(IPEndPoint server_address, |
| 58 const QuicServerId& server_id, |
| 59 const QuicVersionVector& supported_versions, |
| 60 bool print_response, |
| 61 const QuicConfig& config, |
| 62 EpollServer* epoll_server); |
| 59 | 63 |
| 60 virtual ~QuicClient(); | 64 virtual ~QuicClient(); |
| 61 | 65 |
| 62 // Initializes the client to create a connection. Should be called exactly | 66 // Initializes the client to create a connection. Should be called exactly |
| 63 // once before calling StartConnect or Connect. Returns true if the | 67 // once before calling StartConnect or Connect. Returns true if the |
| 64 // initialization succeeds, false otherwise. | 68 // initialization succeeds, false otherwise. |
| 65 bool Initialize(); | 69 bool Initialize(); |
| 66 | 70 |
| 67 // "Connect" to the QUIC server, including performing synchronous crypto | 71 // "Connect" to the QUIC server, including performing synchronous crypto |
| 68 // handshake. | 72 // handshake. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 128 } |
| 125 | 129 |
| 126 IPAddressNumber bind_to_address() const { return bind_to_address_; } | 130 IPAddressNumber bind_to_address() const { return bind_to_address_; } |
| 127 | 131 |
| 128 void set_local_port(int local_port) { local_port_ = local_port; } | 132 void set_local_port(int local_port) { local_port_ = local_port; } |
| 129 | 133 |
| 130 const IPEndPoint& server_address() const { return server_address_; } | 134 const IPEndPoint& server_address() const { return server_address_; } |
| 131 | 135 |
| 132 const IPEndPoint& client_address() const { return client_address_; } | 136 const IPEndPoint& client_address() const { return client_address_; } |
| 133 | 137 |
| 134 EpollServer* epoll_server() { return &epoll_server_; } | 138 EpollServer* epoll_server() { return epoll_server_; } |
| 135 | 139 |
| 136 int fd() { return fd_; } | 140 int fd() { return fd_; } |
| 137 | 141 |
| 138 const QuicServerId& server_id() const { return server_id_; } | 142 const QuicServerId& server_id() const { return server_id_; } |
| 139 | 143 |
| 140 // This should only be set before the initial Connect() | 144 // This should only be set before the initial Connect() |
| 141 void set_server_id(const QuicServerId& server_id) { | 145 void set_server_id(const QuicServerId& server_id) { |
| 142 server_id_ = server_id; | 146 server_id_ = server_id; |
| 143 } | 147 } |
| 144 | 148 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 IPEndPoint client_address_; | 205 IPEndPoint client_address_; |
| 202 | 206 |
| 203 // If initialized, the address to bind to. | 207 // If initialized, the address to bind to. |
| 204 IPAddressNumber bind_to_address_; | 208 IPAddressNumber bind_to_address_; |
| 205 // Local port to bind to. Initialize to 0. | 209 // Local port to bind to. Initialize to 0. |
| 206 int local_port_; | 210 int local_port_; |
| 207 | 211 |
| 208 // Session which manages streams. | 212 // Session which manages streams. |
| 209 scoped_ptr<QuicClientSession> session_; | 213 scoped_ptr<QuicClientSession> session_; |
| 210 // Listens for events on the client socket. | 214 // Listens for events on the client socket. |
| 211 EpollServer epoll_server_; | 215 EpollServer* epoll_server_; |
| 212 // UDP socket. | 216 // UDP socket. |
| 213 int fd_; | 217 int fd_; |
| 214 | 218 |
| 215 // Helper to be used by created connections. | 219 // Helper to be used by created connections. |
| 216 scoped_ptr<QuicEpollConnectionHelper> helper_; | 220 scoped_ptr<QuicEpollConnectionHelper> helper_; |
| 217 | 221 |
| 218 // Listens for full responses. | 222 // Listens for full responses. |
| 219 scoped_ptr<ResponseListener> response_listener_; | 223 scoped_ptr<ResponseListener> response_listener_; |
| 220 | 224 |
| 221 // Writer used to actually send packets to the wire. | 225 // Writer used to actually send packets to the wire. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 244 // when the stream is closed (in OnClose). | 248 // when the stream is closed (in OnClose). |
| 245 bool print_response_; | 249 bool print_response_; |
| 246 | 250 |
| 247 DISALLOW_COPY_AND_ASSIGN(QuicClient); | 251 DISALLOW_COPY_AND_ASSIGN(QuicClient); |
| 248 }; | 252 }; |
| 249 | 253 |
| 250 } // namespace tools | 254 } // namespace tools |
| 251 } // namespace net | 255 } // namespace net |
| 252 | 256 |
| 253 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 257 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
| OLD | NEW |