| 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_packet_creator.h" | 5 #include "net/quic/quic_packet_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 if (fec_protection == MUST_FEC_PROTECT) { | 264 if (fec_protection == MUST_FEC_PROTECT) { |
| 265 should_fec_protect_next_packet_ = true; | 265 should_fec_protect_next_packet_ = true; |
| 266 MaybeStartFecProtection(); | 266 MaybeStartFecProtection(); |
| 267 } | 267 } |
| 268 CreateStreamFrame(id, iov, iov_offset, offset, fin, frame); | 268 CreateStreamFrame(id, iov, iov_offset, offset, fin, frame); |
| 269 bool success = AddFrame(*frame, /*save_retransmittable_frames=*/true); | 269 bool success = AddFrame(*frame, /*save_retransmittable_frames=*/true); |
| 270 if (needs_padding) { | 270 if (needs_padding) { |
| 271 needs_padding_ = true; | 271 needs_padding_ = true; |
| 272 } | 272 } |
| 273 DCHECK(success); | 273 DCHECK(success); |
| 274 if (fec_protection == MUST_FEC_PROTECT && |
| 275 iov_offset + frame->stream_frame->frame_length == iov.total_length) { |
| 276 // Turn off FEC protection when we're done writing protected data. |
| 277 DVLOG(1) << "Turning FEC protection OFF"; |
| 278 should_fec_protect_next_packet_ = false; |
| 279 } |
| 274 return true; | 280 return true; |
| 275 } | 281 } |
| 276 | 282 |
| 277 bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id, | 283 bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id, |
| 278 QuicStreamOffset offset) const { | 284 QuicStreamOffset offset) const { |
| 279 // TODO(jri): This is a simple safe decision for now, but make | 285 // TODO(jri): This is a simple safe decision for now, but make |
| 280 // is_in_fec_group a parameter. Same as with all public methods in | 286 // is_in_fec_group a parameter. Same as with all public methods in |
| 281 // QuicPacketCreator. | 287 // QuicPacketCreator. |
| 282 return BytesFree() > | 288 return BytesFree() > |
| 283 QuicFramer::GetMinStreamFrameSize( | 289 QuicFramer::GetMinStreamFrameSize( |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // value from CACHELINE_SIZE). | 458 // value from CACHELINE_SIZE). |
| 453 ALIGNAS(64) char seralized_packet_buffer[kMaxPacketSize]; | 459 ALIGNAS(64) char seralized_packet_buffer[kMaxPacketSize]; |
| 454 SerializedPacket serialized_packet = | 460 SerializedPacket serialized_packet = |
| 455 SerializePacket(seralized_packet_buffer, kMaxPacketSize); | 461 SerializePacket(seralized_packet_buffer, kMaxPacketSize); |
| 456 OnSerializedPacket(&serialized_packet); | 462 OnSerializedPacket(&serialized_packet); |
| 457 } | 463 } |
| 458 | 464 |
| 459 void QuicPacketCreator::OnSerializedPacket(SerializedPacket* packet) { | 465 void QuicPacketCreator::OnSerializedPacket(SerializedPacket* packet) { |
| 460 if (packet->packet == nullptr) { | 466 if (packet->packet == nullptr) { |
| 461 LOG(DFATAL) << "Failed to SerializePacket. fec_policy:" << fec_send_policy() | 467 LOG(DFATAL) << "Failed to SerializePacket. fec_policy:" << fec_send_policy() |
| 462 << " should_fec_protect_:" << should_fec_protect_next_packet(); | 468 << " should_fec_protect_:" << should_fec_protect_next_packet_; |
| 463 delegate_->CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false); | 469 delegate_->CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false); |
| 464 return; | 470 return; |
| 465 } | 471 } |
| 466 // There may be AckListeners interested in this packet. | 472 // There may be AckListeners interested in this packet. |
| 467 packet->listeners.swap(ack_listeners_); | 473 packet->listeners.swap(ack_listeners_); |
| 468 DCHECK(ack_listeners_.empty()); | 474 DCHECK(ack_listeners_.empty()); |
| 469 delegate_->OnSerializedPacket(packet); | 475 delegate_->OnSerializedPacket(packet); |
| 470 has_ack_ = false; | 476 has_ack_ = false; |
| 471 has_stop_waiting_ = false; | 477 has_stop_waiting_ = false; |
| 472 MaybeSendFecPacketAndCloseGroup(/*force_send_fec=*/false, | 478 MaybeSendFecPacketAndCloseGroup(/*force_send_fec=*/false, |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 hash_map<QuicPathId, QuicPacketNumber>::iterator it = | 834 hash_map<QuicPathId, QuicPacketNumber>::iterator it = |
| 829 multipath_packet_number_.find(path_id); | 835 multipath_packet_number_.find(path_id); |
| 830 // If path_id is not in the map, it's a new path. Set packet_number to 0. | 836 // If path_id is not in the map, it's a new path. Set packet_number to 0. |
| 831 packet_number_ = it == multipath_packet_number_.end() ? 0 : it->second; | 837 packet_number_ = it == multipath_packet_number_.end() ? 0 : it->second; |
| 832 current_path_ = path_id; | 838 current_path_ = path_id; |
| 833 // Switching path needs to update packet number length. | 839 // Switching path needs to update packet number length. |
| 834 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); | 840 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); |
| 835 } | 841 } |
| 836 | 842 |
| 837 } // namespace net | 843 } // namespace net |
| OLD | NEW |