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/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 IPEndPoint address, | 239 IPEndPoint address, |
240 QuicConnectionHelperInterface* helper, | 240 QuicConnectionHelperInterface* helper, |
241 QuicPacketWriter* writer, | 241 QuicPacketWriter* writer, |
242 bool owns_writer, | 242 bool owns_writer, |
243 Perspective perspective, | 243 Perspective perspective, |
244 const QuicVersionVector& supported_versions) | 244 const QuicVersionVector& supported_versions) |
245 : framer_(supported_versions, | 245 : framer_(supported_versions, |
246 helper->GetClock()->ApproximateNow(), | 246 helper->GetClock()->ApproximateNow(), |
247 perspective), | 247 perspective), |
248 helper_(helper), | 248 helper_(helper), |
| 249 per_packet_options_(nullptr), |
249 writer_(writer), | 250 writer_(writer), |
250 owns_writer_(owns_writer), | 251 owns_writer_(owns_writer), |
251 encryption_level_(ENCRYPTION_NONE), | 252 encryption_level_(ENCRYPTION_NONE), |
252 has_forward_secure_encrypter_(false), | 253 has_forward_secure_encrypter_(false), |
253 first_required_forward_secure_packet_(0), | 254 first_required_forward_secure_packet_(0), |
254 clock_(helper->GetClock()), | 255 clock_(helper->GetClock()), |
255 random_generator_(helper->GetRandomGenerator()), | 256 random_generator_(helper->GetRandomGenerator()), |
256 connection_id_(connection_id), | 257 connection_id_(connection_id), |
257 peer_address_(address), | 258 peer_address_(address), |
258 migrating_peer_port_(0), | 259 migrating_peer_port_(0), |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 pending_version_negotiation_packet_ = true; | 1126 pending_version_negotiation_packet_ = true; |
1126 if (writer_->IsWriteBlocked()) { | 1127 if (writer_->IsWriteBlocked()) { |
1127 visitor_->OnWriteBlocked(); | 1128 visitor_->OnWriteBlocked(); |
1128 return; | 1129 return; |
1129 } | 1130 } |
1130 DVLOG(1) << ENDPOINT << "Sending version negotiation packet: {" | 1131 DVLOG(1) << ENDPOINT << "Sending version negotiation packet: {" |
1131 << QuicVersionVectorToString(framer_.supported_versions()) << "}"; | 1132 << QuicVersionVectorToString(framer_.supported_versions()) << "}"; |
1132 scoped_ptr<QuicEncryptedPacket> version_packet( | 1133 scoped_ptr<QuicEncryptedPacket> version_packet( |
1133 packet_generator_.SerializeVersionNegotiationPacket( | 1134 packet_generator_.SerializeVersionNegotiationPacket( |
1134 framer_.supported_versions())); | 1135 framer_.supported_versions())); |
1135 WriteResult result = | 1136 WriteResult result = writer_->WritePacket( |
1136 writer_->WritePacket(version_packet->data(), version_packet->length(), | 1137 version_packet->data(), version_packet->length(), |
1137 self_address().address().bytes(), peer_address()); | 1138 self_address().address().bytes(), peer_address(), per_packet_options_); |
1138 | 1139 |
1139 if (result.status == WRITE_STATUS_ERROR) { | 1140 if (result.status == WRITE_STATUS_ERROR) { |
1140 OnWriteError(result.error_code); | 1141 OnWriteError(result.error_code); |
1141 return; | 1142 return; |
1142 } | 1143 } |
1143 if (result.status == WRITE_STATUS_BLOCKED) { | 1144 if (result.status == WRITE_STATUS_BLOCKED) { |
1144 visitor_->OnWriteBlocked(); | 1145 visitor_->OnWriteBlocked(); |
1145 if (writer_->IsWriteBlockedDataBuffered()) { | 1146 if (writer_->IsWriteBlockedDataBuffered()) { |
1146 pending_version_negotiation_packet_ = false; | 1147 pending_version_negotiation_packet_ = false; |
1147 } | 1148 } |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 << ", encryption level: " | 1650 << ", encryption level: " |
1650 << QuicUtils::EncryptionLevelToString(packet->encryption_level) | 1651 << QuicUtils::EncryptionLevelToString(packet->encryption_level) |
1651 << ", encrypted length:" << encrypted->length(); | 1652 << ", encrypted length:" << encrypted->length(); |
1652 DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl | 1653 DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl |
1653 << QuicUtils::StringToHexASCIIDump(encrypted->AsStringPiece()); | 1654 << QuicUtils::StringToHexASCIIDump(encrypted->AsStringPiece()); |
1654 | 1655 |
1655 // Measure the RTT from before the write begins to avoid underestimating the | 1656 // Measure the RTT from before the write begins to avoid underestimating the |
1656 // min_rtt_, especially in cases where the thread blocks or gets swapped out | 1657 // min_rtt_, especially in cases where the thread blocks or gets swapped out |
1657 // during the WritePacket below. | 1658 // during the WritePacket below. |
1658 QuicTime packet_send_time = clock_->Now(); | 1659 QuicTime packet_send_time = clock_->Now(); |
1659 WriteResult result = | 1660 WriteResult result = writer_->WritePacket( |
1660 writer_->WritePacket(encrypted->data(), encrypted->length(), | 1661 encrypted->data(), encrypted->length(), self_address().address().bytes(), |
1661 self_address().address().bytes(), peer_address()); | 1662 peer_address(), per_packet_options_); |
1662 if (result.error_code == ERR_IO_PENDING) { | 1663 if (result.error_code == ERR_IO_PENDING) { |
1663 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); | 1664 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); |
1664 } | 1665 } |
1665 | 1666 |
1666 if (result.status == WRITE_STATUS_BLOCKED) { | 1667 if (result.status == WRITE_STATUS_BLOCKED) { |
1667 visitor_->OnWriteBlocked(); | 1668 visitor_->OnWriteBlocked(); |
1668 // If the socket buffers the the data, then the packet should not | 1669 // If the socket buffers the the data, then the packet should not |
1669 // be queued and sent again, which would result in an unnecessary | 1670 // be queued and sent again, which would result in an unnecessary |
1670 // duplicate packet being sent. The helper must call OnCanWrite | 1671 // duplicate packet being sent. The helper must call OnCanWrite |
1671 // when the write completes, and OnWriteError if an error occurs. | 1672 // when the write completes, and OnWriteError if an error occurs. |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 void QuicConnection::OnPathClosed(QuicPathId path_id) { | 2462 void QuicConnection::OnPathClosed(QuicPathId path_id) { |
2462 // Stop receiving packets on this path. | 2463 // Stop receiving packets on this path. |
2463 framer_.OnPathClosed(path_id); | 2464 framer_.OnPathClosed(path_id); |
2464 } | 2465 } |
2465 | 2466 |
2466 bool QuicConnection::ack_frame_updated() const { | 2467 bool QuicConnection::ack_frame_updated() const { |
2467 return received_packet_manager_.ack_frame_updated(); | 2468 return received_packet_manager_.ack_frame_updated(); |
2468 } | 2469 } |
2469 | 2470 |
2470 } // namespace net | 2471 } // namespace net |
OLD | NEW |