| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 proof_verifier), | 70 proof_verifier), |
| 71 server_address_(server_address), | 71 server_address_(server_address), |
| 72 local_port_(0), | 72 local_port_(0), |
| 73 epoll_server_(epoll_server), | 73 epoll_server_(epoll_server), |
| 74 initialized_(false), | 74 initialized_(false), |
| 75 packets_dropped_(0), | 75 packets_dropped_(0), |
| 76 overflow_supported_(false), | 76 overflow_supported_(false), |
| 77 use_recvmmsg_(false), | 77 use_recvmmsg_(false), |
| 78 store_response_(false), | 78 store_response_(false), |
| 79 latest_response_code_(-1), | 79 latest_response_code_(-1), |
| 80 packet_reader_(CreateQuicPacketReader()) {} | 80 packet_reader_(new QuicPacketReader()) {} |
| 81 | 81 |
| 82 QuicClient::~QuicClient() { | 82 QuicClient::~QuicClient() { |
| 83 if (connected()) { | 83 if (connected()) { |
| 84 session()->connection()->SendConnectionCloseWithDetails( | 84 session()->connection()->SendConnectionCloseWithDetails( |
| 85 QUIC_PEER_GOING_AWAY, "Client being torn down"); | 85 QUIC_PEER_GOING_AWAY, "Client being torn down"); |
| 86 } | 86 } |
| 87 | 87 |
| 88 STLDeleteElements(&data_to_resend_on_connect_); | 88 STLDeleteElements(&data_to_resend_on_connect_); |
| 89 STLDeleteElements(&data_sent_before_handshake_); | 89 STLDeleteElements(&data_sent_before_handshake_); |
| 90 | 90 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 const string& QuicClient::latest_response_trailers() const { | 473 const string& QuicClient::latest_response_trailers() const { |
| 474 QUIC_BUG_IF(!store_response_) << "Response not stored!"; | 474 QUIC_BUG_IF(!store_response_) << "Response not stored!"; |
| 475 return latest_response_trailers_; | 475 return latest_response_trailers_; |
| 476 } | 476 } |
| 477 | 477 |
| 478 QuicPacketWriter* QuicClient::CreateQuicPacketWriter() { | 478 QuicPacketWriter* QuicClient::CreateQuicPacketWriter() { |
| 479 return new QuicDefaultPacketWriter(GetLatestFD()); | 479 return new QuicDefaultPacketWriter(GetLatestFD()); |
| 480 } | 480 } |
| 481 | 481 |
| 482 QuicPacketReader* QuicClient::CreateQuicPacketReader() { | |
| 483 return new QuicPacketReader(); | |
| 484 } | |
| 485 | |
| 486 const IPEndPoint QuicClient::GetLatestClientAddress() const { | 482 const IPEndPoint QuicClient::GetLatestClientAddress() const { |
| 487 if (fd_address_map_.empty()) { | 483 if (fd_address_map_.empty()) { |
| 488 return IPEndPoint(); | 484 return IPEndPoint(); |
| 489 } | 485 } |
| 490 | 486 |
| 491 return fd_address_map_.back().second; | 487 return fd_address_map_.back().second; |
| 492 } | 488 } |
| 493 | 489 |
| 494 int QuicClient::GetLatestFD() const { | 490 int QuicClient::GetLatestFD() const { |
| 495 if (fd_address_map_.empty()) { | 491 if (fd_address_map_.empty()) { |
| 496 return -1; | 492 return -1; |
| 497 } | 493 } |
| 498 | 494 |
| 499 return fd_address_map_.back().first; | 495 return fd_address_map_.back().first; |
| 500 } | 496 } |
| 501 | 497 |
| 502 void QuicClient::ProcessPacket(const IPEndPoint& self_address, | 498 void QuicClient::ProcessPacket(const IPEndPoint& self_address, |
| 503 const IPEndPoint& peer_address, | 499 const IPEndPoint& peer_address, |
| 504 const QuicEncryptedPacket& packet) { | 500 const QuicEncryptedPacket& packet) { |
| 505 session()->connection()->ProcessUdpPacket(self_address, peer_address, packet); | 501 session()->connection()->ProcessUdpPacket(self_address, peer_address, packet); |
| 506 } | 502 } |
| 507 | 503 |
| 508 } // namespace net | 504 } // namespace net |
| OLD | NEW |