| 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> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace net { | 35 namespace net { |
| 36 namespace tools { | 36 namespace tools { |
| 37 | 37 |
| 38 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; | 38 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; |
| 39 | 39 |
| 40 QuicClient::QuicClient(IPEndPoint server_address, | 40 QuicClient::QuicClient(IPEndPoint server_address, |
| 41 const QuicServerId& server_id, | 41 const QuicServerId& server_id, |
| 42 const QuicVersionVector& supported_versions, | 42 const QuicVersionVector& supported_versions, |
| 43 EpollServer* epoll_server) | 43 EpollServer* epoll_server) |
| 44 : server_address_(server_address), | 44 : QuicClient(server_address, |
| 45 server_id_(server_id), | 45 server_id, |
| 46 local_port_(0), | 46 supported_versions, |
| 47 epoll_server_(epoll_server), | 47 QuicConfig(), |
| 48 fd_(-1), | 48 epoll_server) {} |
| 49 helper_(CreateQuicConnectionHelper()), | |
| 50 initialized_(false), | |
| 51 packets_dropped_(0), | |
| 52 overflow_supported_(false), | |
| 53 supported_versions_(supported_versions), | |
| 54 store_response_(false), | |
| 55 latest_response_code_(-1) { | |
| 56 } | |
| 57 | 49 |
| 58 QuicClient::QuicClient(IPEndPoint server_address, | 50 QuicClient::QuicClient(IPEndPoint server_address, |
| 59 const QuicServerId& server_id, | 51 const QuicServerId& server_id, |
| 60 const QuicVersionVector& supported_versions, | 52 const QuicVersionVector& supported_versions, |
| 61 const QuicConfig& config, | 53 const QuicConfig& config, |
| 62 EpollServer* epoll_server) | 54 EpollServer* epoll_server) |
| 63 : server_address_(server_address), | 55 : server_address_(server_address), |
| 64 server_id_(server_id), | 56 server_id_(server_id), |
| 65 config_(config), | 57 config_(config), |
| 66 local_port_(0), | 58 local_port_(0), |
| 67 epoll_server_(epoll_server), | 59 epoll_server_(epoll_server), |
| 68 fd_(-1), | 60 fd_(-1), |
| 69 helper_(CreateQuicConnectionHelper()), | 61 helper_(CreateQuicConnectionHelper()), |
| 70 initialized_(false), | 62 initialized_(false), |
| 71 packets_dropped_(0), | 63 packets_dropped_(0), |
| 72 overflow_supported_(false), | 64 overflow_supported_(false), |
| 73 supported_versions_(supported_versions), | 65 supported_versions_(supported_versions), |
| 74 store_response_(false), | 66 store_response_(false), |
| 75 latest_response_code_(-1) { | 67 latest_response_code_(-1), |
| 76 } | 68 initial_max_packet_length_(0) {} |
| 77 | 69 |
| 78 QuicClient::~QuicClient() { | 70 QuicClient::~QuicClient() { |
| 79 if (connected()) { | 71 if (connected()) { |
| 80 session()->connection()->SendConnectionClose(QUIC_PEER_GOING_AWAY); | 72 session()->connection()->SendConnectionClose(QUIC_PEER_GOING_AWAY); |
| 81 } | 73 } |
| 82 | 74 |
| 83 CleanUpUDPSocketImpl(); | 75 CleanUpUDPSocketImpl(); |
| 84 } | 76 } |
| 85 | 77 |
| 86 bool QuicClient::Initialize() { | 78 bool QuicClient::Initialize() { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 203 |
| 212 DummyPacketWriterFactory factory(writer); | 204 DummyPacketWriterFactory factory(writer); |
| 213 | 205 |
| 214 session_.reset(CreateQuicClientSession( | 206 session_.reset(CreateQuicClientSession( |
| 215 config_, | 207 config_, |
| 216 new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(), | 208 new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(), |
| 217 factory, | 209 factory, |
| 218 /* owns_writer= */ false, Perspective::IS_CLIENT, | 210 /* owns_writer= */ false, Perspective::IS_CLIENT, |
| 219 server_id_.is_https(), supported_versions_), | 211 server_id_.is_https(), supported_versions_), |
| 220 server_id_, &crypto_config_)); | 212 server_id_, &crypto_config_)); |
| 213 if (initial_max_packet_length_ != 0) { |
| 214 session_->connection()->set_max_packet_length(initial_max_packet_length_); |
| 215 } |
| 221 | 216 |
| 222 // Reset |writer_| after |session_| so that the old writer outlives the old | 217 // Reset |writer_| after |session_| so that the old writer outlives the old |
| 223 // session. | 218 // session. |
| 224 if (writer_.get() != writer) { | 219 if (writer_.get() != writer) { |
| 225 writer_.reset(writer); | 220 writer_.reset(writer); |
| 226 } | 221 } |
| 227 session_->Initialize(); | 222 session_->Initialize(); |
| 228 session_->CryptoConnect(); | 223 session_->CryptoConnect(); |
| 229 } | 224 } |
| 230 | 225 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 QuicEncryptedPacket packet(buf, bytes_read, false); | 415 QuicEncryptedPacket packet(buf, bytes_read, false); |
| 421 | 416 |
| 422 IPEndPoint client_address(client_ip, client_address_.port()); | 417 IPEndPoint client_address(client_ip, client_address_.port()); |
| 423 session_->connection()->ProcessUdpPacket( | 418 session_->connection()->ProcessUdpPacket( |
| 424 client_address, server_address, packet); | 419 client_address, server_address, packet); |
| 425 return true; | 420 return true; |
| 426 } | 421 } |
| 427 | 422 |
| 428 } // namespace tools | 423 } // namespace tools |
| 429 } // namespace net | 424 } // namespace net |
| OLD | NEW |