| 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_generator.h" | 5 #include "net/quic/quic_packet_generator.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/quic/quic_fec_group.h" | 9 #include "net/quic/quic_fec_group.h" |
| 10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 class QuicAckNotifier; | 29 class QuicAckNotifier; |
| 30 | 30 |
| 31 QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId connection_id, | 31 QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId connection_id, |
| 32 QuicFramer* framer, | 32 QuicFramer* framer, |
| 33 QuicRandom* random_generator, | 33 QuicRandom* random_generator, |
| 34 DelegateInterface* delegate) | 34 DelegateInterface* delegate) |
| 35 : delegate_(delegate), | 35 : delegate_(delegate), |
| 36 debug_delegate_(NULL), | 36 debug_delegate_(nullptr), |
| 37 packet_creator_(connection_id, framer, random_generator), | 37 packet_creator_(connection_id, framer, random_generator), |
| 38 batch_mode_(false), | 38 batch_mode_(false), |
| 39 should_fec_protect_(false), | 39 should_fec_protect_(false), |
| 40 should_send_ack_(false), | 40 should_send_ack_(false), |
| 41 should_send_feedback_(false), | 41 should_send_feedback_(false), |
| 42 should_send_stop_waiting_(false) { | 42 should_send_stop_waiting_(false) {} |
| 43 } | |
| 44 | 43 |
| 45 QuicPacketGenerator::~QuicPacketGenerator() { | 44 QuicPacketGenerator::~QuicPacketGenerator() { |
| 46 for (QuicFrames::iterator it = queued_control_frames_.begin(); | 45 for (QuicFrames::iterator it = queued_control_frames_.begin(); |
| 47 it != queued_control_frames_.end(); ++it) { | 46 it != queued_control_frames_.end(); ++it) { |
| 48 switch (it->type) { | 47 switch (it->type) { |
| 49 case PADDING_FRAME: | 48 case PADDING_FRAME: |
| 50 delete it->padding_frame; | 49 delete it->padding_frame; |
| 51 break; | 50 break; |
| 52 case STREAM_FRAME: | 51 case STREAM_FRAME: |
| 53 delete it->stream_frame; | 52 delete it->stream_frame; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 if (fec_protection == MUST_FEC_PROTECT) { | 133 if (fec_protection == MUST_FEC_PROTECT) { |
| 135 MaybeStartFecProtection(); | 134 MaybeStartFecProtection(); |
| 136 } | 135 } |
| 137 | 136 |
| 138 IOVector data = data_to_write; | 137 IOVector data = data_to_write; |
| 139 size_t data_size = data.TotalBufferSize(); | 138 size_t data_size = data.TotalBufferSize(); |
| 140 while (delegate_->ShouldGeneratePacket(NOT_RETRANSMISSION, | 139 while (delegate_->ShouldGeneratePacket(NOT_RETRANSMISSION, |
| 141 HAS_RETRANSMITTABLE_DATA, handshake)) { | 140 HAS_RETRANSMITTABLE_DATA, handshake)) { |
| 142 QuicFrame frame; | 141 QuicFrame frame; |
| 143 size_t bytes_consumed; | 142 size_t bytes_consumed; |
| 144 if (notifier != NULL) { | 143 if (notifier != nullptr) { |
| 145 // We want to track which packet this stream frame ends up in. | 144 // We want to track which packet this stream frame ends up in. |
| 146 bytes_consumed = packet_creator_.CreateStreamFrameWithNotifier( | 145 bytes_consumed = packet_creator_.CreateStreamFrameWithNotifier( |
| 147 id, data, offset + total_bytes_consumed, fin, notifier, &frame); | 146 id, data, offset + total_bytes_consumed, fin, notifier, &frame); |
| 148 } else { | 147 } else { |
| 149 bytes_consumed = packet_creator_.CreateStreamFrame( | 148 bytes_consumed = packet_creator_.CreateStreamFrame( |
| 150 id, data, offset + total_bytes_consumed, fin, &frame); | 149 id, data, offset + total_bytes_consumed, fin, &frame); |
| 151 } | 150 } |
| 152 if (!AddFrame(frame)) { | 151 if (!AddFrame(frame)) { |
| 153 LOG(DFATAL) << "Failed to add stream frame."; | 152 LOG(DFATAL) << "Failed to add stream frame."; |
| 154 // Inability to add a STREAM frame creates an unrecoverable hole in a | 153 // Inability to add a STREAM frame creates an unrecoverable hole in a |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 QuicByteCount congestion_window) { | 382 QuicByteCount congestion_window) { |
| 384 return packet_creator_.UpdateSequenceNumberLength( | 383 return packet_creator_.UpdateSequenceNumberLength( |
| 385 least_packet_awaited_by_peer, congestion_window); | 384 least_packet_awaited_by_peer, congestion_window); |
| 386 } | 385 } |
| 387 | 386 |
| 388 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { | 387 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { |
| 389 packet_creator_.set_encryption_level(level); | 388 packet_creator_.set_encryption_level(level); |
| 390 } | 389 } |
| 391 | 390 |
| 392 } // namespace net | 391 } // namespace net |
| OLD | NEW |