Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: net/tools/quic/quic_client.h

Issue 1761263002: Landing recent QUIC changes until 7:19 PM, Feb 26, 2016 UTC-5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ActivateStream() call to QuicChromiumClientSession to fix server push failure Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/quic/end_to_end_test.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 11 #include <stddef.h>
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "net/base/ip_address.h" 19 #include "net/base/ip_address.h"
20 #include "net/base/ip_endpoint.h" 20 #include "net/base/ip_endpoint.h"
21 #include "net/quic/quic_client_push_promise_index.h" 21 #include "net/quic/quic_client_push_promise_index.h"
22 #include "net/quic/quic_config.h" 22 #include "net/quic/quic_config.h"
23 #include "net/quic/quic_spdy_stream.h" 23 #include "net/quic/quic_spdy_stream.h"
24 #include "net/tools/balsa/balsa_headers.h" 24 #include "net/tools/balsa/balsa_headers.h"
25 #include "net/tools/epoll_server/epoll_server.h" 25 #include "net/tools/epoll_server/epoll_server.h"
26 #include "net/tools/quic/quic_client_base.h" 26 #include "net/tools/quic/quic_client_base.h"
27 #include "net/tools/quic/quic_client_session.h" 27 #include "net/tools/quic/quic_client_session.h"
28 #include "net/tools/quic/quic_packet_reader.h"
28 #include "net/tools/quic/quic_process_packet_interface.h" 29 #include "net/tools/quic/quic_process_packet_interface.h"
29 30
30 namespace net { 31 namespace net {
31 32
32 class QuicServerId; 33 class QuicServerId;
33 34
34 class QuicEpollConnectionHelper; 35 class QuicEpollConnectionHelper;
35 class QuicPacketReader;
36 36
37 namespace test { 37 namespace test {
38 class QuicClientPeer; 38 class QuicClientPeer;
39 } // namespace test 39 } // namespace test
40 40
41 class QuicClient : public QuicClientBase, 41 class QuicClient : public QuicClientBase,
42 public EpollCallbackInterface, 42 public EpollCallbackInterface,
43 public QuicSpdyStream::Visitor, 43 public QuicSpdyStream::Visitor,
44 public ProcessPacketInterface, 44 public ProcessPacketInterface,
45 public QuicClientPushPromiseIndex::Delegate { 45 public QuicClientPushPromiseIndex::Delegate {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Implements ProcessPacketInterface. This will be called for each received 186 // Implements ProcessPacketInterface. This will be called for each received
187 // packet. 187 // packet.
188 void ProcessPacket(const IPEndPoint& self_address, 188 void ProcessPacket(const IPEndPoint& self_address,
189 const IPEndPoint& peer_address, 189 const IPEndPoint& peer_address,
190 const QuicEncryptedPacket& packet) override; 190 const QuicEncryptedPacket& packet) override;
191 191
192 QuicClientPushPromiseIndex* push_promise_index() { 192 QuicClientPushPromiseIndex* push_promise_index() {
193 return &push_promise_index_; 193 return &push_promise_index_;
194 } 194 }
195 195
196 protected:
197 virtual QuicPacketWriter* CreateQuicPacketWriter(); 196 virtual QuicPacketWriter* CreateQuicPacketWriter();
198 virtual QuicPacketReader* CreateQuicPacketReader();
199
200 virtual int ReadPacket(char* buffer,
201 int buffer_len,
202 IPEndPoint* server_address,
203 IPAddress* client_ip);
204 197
205 // If |fd| is an open UDP socket, unregister and close it. Otherwise, do 198 // If |fd| is an open UDP socket, unregister and close it. Otherwise, do
206 // nothing. 199 // nothing.
207 virtual void CleanUpUDPSocket(int fd); 200 virtual void CleanUpUDPSocket(int fd);
208 201
209 // Unregister and close all open UDP sockets. 202 // Unregister and close all open UDP sockets.
210 virtual void CleanUpAllUDPSockets(); 203 virtual void CleanUpAllUDPSockets();
211 204
212 EpollServer* epoll_server() { return epoll_server_; } 205 EpollServer* epoll_server() { return epoll_server_; }
213 206
(...skipping 22 matching lines...) Expand all
236 void Resend() override; 229 void Resend() override;
237 230
238 private: 231 private:
239 QuicClient* client_; 232 QuicClient* client_;
240 233
241 DISALLOW_COPY_AND_ASSIGN(ClientQuicDataToResend); 234 DISALLOW_COPY_AND_ASSIGN(ClientQuicDataToResend);
242 }; 235 };
243 236
244 // Used during initialization: creates the UDP socket FD, sets socket options, 237 // Used during initialization: creates the UDP socket FD, sets socket options,
245 // and binds the socket to our address. 238 // and binds the socket to our address.
246 bool CreateUDPSocket(); 239 bool CreateUDPSocketAndBind();
247 240
248 // Actually clean up |fd|. 241 // Actually clean up |fd|.
249 void CleanUpUDPSocketImpl(int fd); 242 void CleanUpUDPSocketImpl(int fd);
250 243
251 // Read a UDP packet and hand it to the framer.
252 bool ReadAndProcessPacket();
253
254 // Read available UDP packets up to kNumPacketsPerReadCall
255 // and hand them to the connection.
256 // TODO(rtenneti): Add support for ReadAndProcessPackets().
257 // bool ReadAndProcessPackets();
258
259 // If the request URL matches a push promise, bypass sending the 244 // If the request URL matches a push promise, bypass sending the
260 // request. 245 // request.
261 bool MaybeHandlePromised(const BalsaHeaders& headers, 246 bool MaybeHandlePromised(const BalsaHeaders& headers,
262 const SpdyHeaderBlock& spdy_headers, 247 const SpdyHeaderBlock& spdy_headers,
263 base::StringPiece body, 248 base::StringPiece body,
264 bool fin); 249 bool fin);
265 250
266 // Address of the server. 251 // Address of the server.
267 const IPEndPoint server_address_; 252 const IPEndPoint server_address_;
268 253
(...skipping 20 matching lines...) Expand all
289 bool initialized_; 274 bool initialized_;
290 275
291 // If overflow_supported_ is true, this will be the number of packets dropped 276 // If overflow_supported_ is true, this will be the number of packets dropped
292 // during the lifetime of the server. 277 // during the lifetime of the server.
293 QuicPacketCount packets_dropped_; 278 QuicPacketCount packets_dropped_;
294 279
295 // True if the kernel supports SO_RXQ_OVFL, the number of packets dropped 280 // True if the kernel supports SO_RXQ_OVFL, the number of packets dropped
296 // because the socket would otherwise overflow. 281 // because the socket would otherwise overflow.
297 bool overflow_supported_; 282 bool overflow_supported_;
298 283
284 // If true, use recvmmsg for reading.
285 bool use_recvmmsg_;
286
299 // If true, store the latest response code, headers, and body. 287 // If true, store the latest response code, headers, and body.
300 bool store_response_; 288 bool store_response_;
301 // HTTP response code from most recent response. 289 // HTTP response code from most recent response.
302 size_t latest_response_code_; 290 size_t latest_response_code_;
303 // HTTP/2 headers from most recent response. 291 // HTTP/2 headers from most recent response.
304 std::string latest_response_headers_; 292 std::string latest_response_headers_;
305 // Body of most recent response. 293 // Body of most recent response.
306 std::string latest_response_body_; 294 std::string latest_response_body_;
307 // HTTP/2 trailers from most recent response. 295 // HTTP/2 trailers from most recent response.
308 std::string latest_response_trailers_; 296 std::string latest_response_trailers_;
309 297
310 // Keeps track of any data sent before the handshake. 298 // Keeps track of any data sent before the handshake.
311 std::vector<QuicDataToResend*> data_sent_before_handshake_; 299 std::vector<QuicDataToResend*> data_sent_before_handshake_;
312 300
313 // Once the client receives a stateless reject, keeps track of any data that 301 // Once the client receives a stateless reject, keeps track of any data that
314 // must be resent upon a subsequent successful connection. 302 // must be resent upon a subsequent successful connection.
315 std::vector<QuicDataToResend*> data_to_resend_on_connect_; 303 std::vector<QuicDataToResend*> data_to_resend_on_connect_;
316 304
317 // Point to a QuicPacketReader object on the heap. The reader allocates more 305 // Point to a QuicPacketReader object on the heap. The reader allocates more
318 // space than allowed on the stack. 306 // space than allowed on the stack.
319 // 307 //
320 // TODO(rtenneti): Chromium code doesn't use |packet_reader_|. Add support for 308 // TODO(rtenneti): Chromium code doesn't use |packet_reader_|. Add support for
321 // QuicPacketReader 309 // QuicPacketReader
322 QuicPacketReader* packet_reader_; 310 scoped_ptr<QuicPacketReader> packet_reader_;
323 311
324 std::unique_ptr<ClientQuicDataToResend> push_promise_data_to_resend_; 312 std::unique_ptr<ClientQuicDataToResend> push_promise_data_to_resend_;
325 313
326 DISALLOW_COPY_AND_ASSIGN(QuicClient); 314 DISALLOW_COPY_AND_ASSIGN(QuicClient);
327 }; 315 };
328 316
329 } // namespace net 317 } // namespace net
330 318
331 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_ 319 #endif // NET_TOOLS_QUIC_QUIC_CLIENT_H_
OLDNEW
« no previous file with comments | « net/tools/quic/end_to_end_test.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698