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 #include "net/tools/quic/quic_client.h" | 5 #include "net/tools/quic/quic_client.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <netinet/in.h> | 8 #include <netinet/in.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/epoll.h> | 10 #include <sys/epoll.h> |
11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "net/base/sockaddr_storage.h" | 16 #include "net/base/sockaddr_storage.h" |
17 #include "net/quic/crypto/quic_random.h" | 17 #include "net/quic/crypto/quic_random.h" |
18 #include "net/quic/quic_bug_tracker.h" | 18 #include "net/quic/quic_bug_tracker.h" |
19 #include "net/quic/quic_connection.h" | 19 #include "net/quic/quic_connection.h" |
20 #include "net/quic/quic_data_reader.h" | 20 #include "net/quic/quic_data_reader.h" |
21 #include "net/quic/quic_flags.h" | 21 #include "net/quic/quic_flags.h" |
22 #include "net/quic/quic_protocol.h" | 22 #include "net/quic/quic_protocol.h" |
23 #include "net/quic/quic_server_id.h" | 23 #include "net/quic/quic_server_id.h" |
| 24 #include "net/tools/quic/quic_epoll_alarm_factory.h" |
24 #include "net/tools/quic/quic_epoll_connection_helper.h" | 25 #include "net/tools/quic/quic_epoll_connection_helper.h" |
25 #include "net/tools/quic/quic_socket_utils.h" | 26 #include "net/tools/quic/quic_socket_utils.h" |
26 #include "net/tools/quic/spdy_balsa_utils.h" | 27 #include "net/tools/quic/spdy_balsa_utils.h" |
27 | 28 |
28 #ifndef SO_RXQ_OVFL | 29 #ifndef SO_RXQ_OVFL |
29 #define SO_RXQ_OVFL 40 | 30 #define SO_RXQ_OVFL 40 |
30 #endif | 31 #endif |
31 | 32 |
32 // TODO(rtenneti): Add support for MMSG_MORE. | 33 // TODO(rtenneti): Add support for MMSG_MORE. |
33 #define MMSG_MORE 0 | 34 #define MMSG_MORE 0 |
(...skipping 27 matching lines...) Expand all Loading... |
61 const QuicServerId& server_id, | 62 const QuicServerId& server_id, |
62 const QuicVersionVector& supported_versions, | 63 const QuicVersionVector& supported_versions, |
63 const QuicConfig& config, | 64 const QuicConfig& config, |
64 EpollServer* epoll_server, | 65 EpollServer* epoll_server, |
65 ProofVerifier* proof_verifier) | 66 ProofVerifier* proof_verifier) |
66 : QuicClientBase( | 67 : QuicClientBase( |
67 server_id, | 68 server_id, |
68 supported_versions, | 69 supported_versions, |
69 config, | 70 config, |
70 new QuicEpollConnectionHelper(epoll_server, QuicAllocator::SIMPLE), | 71 new QuicEpollConnectionHelper(epoll_server, QuicAllocator::SIMPLE), |
| 72 new QuicEpollAlarmFactory(epoll_server), |
71 proof_verifier), | 73 proof_verifier), |
72 server_address_(server_address), | 74 server_address_(server_address), |
73 local_port_(0), | 75 local_port_(0), |
74 epoll_server_(epoll_server), | 76 epoll_server_(epoll_server), |
75 initialized_(false), | 77 initialized_(false), |
76 packets_dropped_(0), | 78 packets_dropped_(0), |
77 overflow_supported_(false), | 79 overflow_supported_(false), |
78 store_response_(false), | 80 store_response_(false), |
79 latest_response_code_(-1), | 81 latest_response_code_(-1), |
80 packet_reader_(new QuicPacketReader()) {} | 82 packet_reader_(new QuicPacketReader()) {} |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // If the last error was due to a stateless reject, queue up the data to | 225 // If the last error was due to a stateless reject, queue up the data to |
224 // be resent on the next successful connection. | 226 // be resent on the next successful connection. |
225 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe | 227 // TODO(jokulik): I'm a little bit concerned about ordering here. Maybe |
226 // we should just maintain one queue? | 228 // we should just maintain one queue? |
227 DCHECK(data_to_resend_on_connect_.empty()); | 229 DCHECK(data_to_resend_on_connect_.empty()); |
228 data_to_resend_on_connect_.swap(data_sent_before_handshake_); | 230 data_to_resend_on_connect_.swap(data_sent_before_handshake_); |
229 } | 231 } |
230 } | 232 } |
231 | 233 |
232 CreateQuicClientSession(new QuicConnection( | 234 CreateQuicClientSession(new QuicConnection( |
233 GetNextConnectionId(), server_address_, helper(), writer, | 235 GetNextConnectionId(), server_address_, helper(), alarm_factory(), writer, |
234 /* owns_writer= */ false, Perspective::IS_CLIENT, supported_versions())); | 236 /* owns_writer= */ false, Perspective::IS_CLIENT, supported_versions())); |
235 | 237 |
236 // Reset |writer_| after |session()| so that the old writer outlives the old | 238 // Reset |writer_| after |session()| so that the old writer outlives the old |
237 // session. | 239 // session. |
238 set_writer(writer); | 240 set_writer(writer); |
239 session()->Initialize(); | 241 session()->Initialize(); |
240 session()->CryptoConnect(); | 242 session()->CryptoConnect(); |
241 set_connected_or_attempting_connect(true); | 243 set_connected_or_attempting_connect(true); |
242 } | 244 } |
243 | 245 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 return fd_address_map_.back().first; | 490 return fd_address_map_.back().first; |
489 } | 491 } |
490 | 492 |
491 void QuicClient::ProcessPacket(const IPEndPoint& self_address, | 493 void QuicClient::ProcessPacket(const IPEndPoint& self_address, |
492 const IPEndPoint& peer_address, | 494 const IPEndPoint& peer_address, |
493 const QuicReceivedPacket& packet) { | 495 const QuicReceivedPacket& packet) { |
494 session()->connection()->ProcessUdpPacket(self_address, peer_address, packet); | 496 session()->connection()->ProcessUdpPacket(self_address, peer_address, packet); |
495 } | 497 } |
496 | 498 |
497 } // namespace net | 499 } // namespace net |
OLD | NEW |