| 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 16 matching lines...) Expand all Loading... |
| 27 class ProofVerifier; | 27 class ProofVerifier; |
| 28 | 28 |
| 29 namespace tools { | 29 namespace tools { |
| 30 | 30 |
| 31 class QuicEpollConnectionHelper; | 31 class QuicEpollConnectionHelper; |
| 32 | 32 |
| 33 namespace test { | 33 namespace test { |
| 34 class QuicClientPeer; | 34 class QuicClientPeer; |
| 35 } // namespace test | 35 } // namespace test |
| 36 | 36 |
| 37 class QuicClient : public EpollCallbackInterface { | 37 class QuicClient : public EpollCallbackInterface, |
| 38 public ReliableQuicStream::Visitor { |
| 38 public: | 39 public: |
| 39 QuicClient(IPEndPoint server_address, const std::string& server_hostname, | 40 QuicClient(IPEndPoint server_address, |
| 40 const QuicVersion version); | 41 const string& server_hostname, |
| 42 const QuicVersion version, |
| 43 bool print_response); |
| 41 QuicClient(IPEndPoint server_address, | 44 QuicClient(IPEndPoint server_address, |
| 42 const std::string& server_hostname, | 45 const std::string& server_hostname, |
| 43 const QuicConfig& config, | 46 const QuicConfig& config, |
| 44 const QuicVersion version); | 47 const QuicVersion version); |
| 45 | 48 |
| 46 virtual ~QuicClient(); | 49 virtual ~QuicClient(); |
| 47 | 50 |
| 48 // Initializes the client to create a connection. Should be called exactly | 51 // Initializes the client to create a connection. Should be called exactly |
| 49 // once before calling StartConnect or Connect. Returns true if the | 52 // once before calling StartConnect or Connect. Returns true if the |
| 50 // initialization succeeds, false otherwise. | 53 // initialization succeeds, false otherwise. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 virtual void OnRegistration( | 92 virtual void OnRegistration( |
| 90 EpollServer* eps, int fd, int event_mask) OVERRIDE {} | 93 EpollServer* eps, int fd, int event_mask) OVERRIDE {} |
| 91 virtual void OnModification(int fd, int event_mask) OVERRIDE {} | 94 virtual void OnModification(int fd, int event_mask) OVERRIDE {} |
| 92 virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE; | 95 virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE; |
| 93 // |fd_| can be unregistered without the client being disconnected. This | 96 // |fd_| can be unregistered without the client being disconnected. This |
| 94 // happens in b3m QuicProber where we unregister |fd_| to feed in events to | 97 // happens in b3m QuicProber where we unregister |fd_| to feed in events to |
| 95 // the client from the SelectServer. | 98 // the client from the SelectServer. |
| 96 virtual void OnUnregistration(int fd, bool replaced) OVERRIDE {} | 99 virtual void OnUnregistration(int fd, bool replaced) OVERRIDE {} |
| 97 virtual void OnShutdown(EpollServer* eps, int fd) OVERRIDE {} | 100 virtual void OnShutdown(EpollServer* eps, int fd) OVERRIDE {} |
| 98 | 101 |
| 102 // ReliableQuicStream::Visitor |
| 103 virtual void OnClose(ReliableQuicStream* stream) OVERRIDE; |
| 104 |
| 99 QuicPacketCreator::Options* options(); | 105 QuicPacketCreator::Options* options(); |
| 100 | 106 |
| 101 QuicClientSession* session() { return session_.get(); } | 107 QuicClientSession* session() { return session_.get(); } |
| 102 | 108 |
| 103 bool connected() const; | 109 bool connected() const; |
| 104 | 110 |
| 105 void set_bind_to_address(IPAddressNumber address) { | 111 void set_bind_to_address(IPAddressNumber address) { |
| 106 bind_to_address_ = address; | 112 bind_to_address_ = address; |
| 107 } | 113 } |
| 108 | 114 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // are dropped. | 189 // are dropped. |
| 184 int packets_dropped_; | 190 int packets_dropped_; |
| 185 | 191 |
| 186 // True if the kernel supports SO_RXQ_OVFL, the number of packets dropped | 192 // True if the kernel supports SO_RXQ_OVFL, the number of packets dropped |
| 187 // because the socket would otherwise overflow. | 193 // because the socket would otherwise overflow. |
| 188 bool overflow_supported_; | 194 bool overflow_supported_; |
| 189 | 195 |
| 190 // Which QUIC version does this client talk? | 196 // Which QUIC version does this client talk? |
| 191 QuicVersion version_; | 197 QuicVersion version_; |
| 192 | 198 |
| 199 // If true, then the contents of each response will be printed to stdout |
| 200 // when the stream is closed (in OnClose). |
| 201 bool print_response_; |
| 202 |
| 193 DISALLOW_COPY_AND_ASSIGN(QuicClient); | 203 DISALLOW_COPY_AND_ASSIGN(QuicClient); |
| 194 }; | 204 }; |
| 195 | 205 |
| 196 } // namespace tools | 206 } // namespace tools |
| 197 } // namespace net | 207 } // namespace net |
| 198 | 208 |
| 199 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 209 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
| OLD | NEW |