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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 class QuicClient : public EpollCallbackInterface, | 38 class QuicClient : public EpollCallbackInterface, |
39 public QuicDataStream::Visitor { | 39 public QuicDataStream::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 BalsaHeaders& response_headers, | 46 const BalsaHeaders& response_headers, |
47 const string& response_body) = 0; | 47 const std::string& response_body) = 0; |
48 }; | 48 }; |
49 | 49 |
50 // Create a quic client, which will have events managed by an externally owned | 50 // Create a quic client, which will have events managed by an externally owned |
51 // EpollServer. | 51 // EpollServer. |
52 QuicClient(IPEndPoint server_address, | 52 QuicClient(IPEndPoint server_address, |
53 const QuicServerId& server_id, | 53 const QuicServerId& server_id, |
54 const QuicVersionVector& supported_versions, | 54 const QuicVersionVector& supported_versions, |
55 bool print_response, | 55 bool print_response, |
56 EpollServer* epoll_server); | 56 EpollServer* epoll_server); |
57 QuicClient(IPEndPoint server_address, | 57 QuicClient(IPEndPoint server_address, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // the client from the SelectServer. | 113 // the client from the SelectServer. |
114 void OnUnregistration(int fd, bool replaced) override {} | 114 void OnUnregistration(int fd, bool replaced) override {} |
115 void OnShutdown(EpollServer* eps, int fd) override {} | 115 void OnShutdown(EpollServer* eps, int fd) override {} |
116 | 116 |
117 // QuicDataStream::Visitor | 117 // QuicDataStream::Visitor |
118 void OnClose(QuicDataStream* stream) override; | 118 void OnClose(QuicDataStream* stream) override; |
119 | 119 |
120 QuicClientSession* session() { return session_.get(); } | 120 QuicClientSession* session() { return session_.get(); } |
121 | 121 |
122 bool connected() const; | 122 bool connected() const; |
| 123 bool goaway_received() const; |
123 | 124 |
124 void set_bind_to_address(IPAddressNumber address) { | 125 void set_bind_to_address(IPAddressNumber address) { |
125 bind_to_address_ = address; | 126 bind_to_address_ = address; |
126 } | 127 } |
127 | 128 |
128 IPAddressNumber bind_to_address() const { return bind_to_address_; } | 129 IPAddressNumber bind_to_address() const { return bind_to_address_; } |
129 | 130 |
130 void set_local_port(int local_port) { local_port_ = local_port; } | 131 void set_local_port(int local_port) { local_port_ = local_port; } |
131 | 132 |
132 const IPEndPoint& server_address() const { return server_address_; } | 133 const IPEndPoint& server_address() const { return server_address_; } |
133 | 134 |
134 const IPEndPoint& client_address() const { return client_address_; } | 135 const IPEndPoint& client_address() const { return client_address_; } |
135 | 136 |
136 int fd() { return fd_; } | 137 int fd() { return fd_; } |
137 | 138 |
138 const QuicServerId& server_id() const { return server_id_; } | 139 const QuicServerId& server_id() const { return server_id_; } |
139 | 140 |
140 // This should only be set before the initial Connect() | 141 // This should only be set before the initial Connect() |
141 void set_server_id(const QuicServerId& server_id) { | 142 void set_server_id(const QuicServerId& server_id) { |
142 server_id_ = server_id; | 143 server_id_ = server_id; |
143 } | 144 } |
144 | 145 |
145 void SetUserAgentID(const string& user_agent_id) { | 146 void SetUserAgentID(const std::string& user_agent_id) { |
146 crypto_config_.set_user_agent_id(user_agent_id); | 147 crypto_config_.set_user_agent_id(user_agent_id); |
147 } | 148 } |
148 | 149 |
149 // SetProofVerifier sets the ProofVerifier that will be used to verify the | 150 // SetProofVerifier sets the ProofVerifier that will be used to verify the |
150 // server's certificate and takes ownership of |verifier|. | 151 // server's certificate and takes ownership of |verifier|. |
151 void SetProofVerifier(ProofVerifier* verifier) { | 152 void SetProofVerifier(ProofVerifier* verifier) { |
152 // TODO(rtenneti): We should set ProofVerifier in QuicClientSession. | 153 // TODO(rtenneti): We should set ProofVerifier in QuicClientSession. |
153 crypto_config_.SetProofVerifier(verifier); | 154 crypto_config_.SetProofVerifier(verifier); |
154 } | 155 } |
155 | 156 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // when the stream is closed (in OnClose). | 265 // when the stream is closed (in OnClose). |
265 bool print_response_; | 266 bool print_response_; |
266 | 267 |
267 DISALLOW_COPY_AND_ASSIGN(QuicClient); | 268 DISALLOW_COPY_AND_ASSIGN(QuicClient); |
268 }; | 269 }; |
269 | 270 |
270 } // namespace tools | 271 } // namespace tools |
271 } // namespace net | 272 } // namespace net |
272 | 273 |
273 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ | 274 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ |
OLD | NEW |