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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Since the packet creator will not change packet number length mid FEC | 230 // Since the packet creator will not change packet number length mid FEC |
231 // group, include the size of an FEC group to be safe. | 231 // group, include the size of an FEC group to be safe. |
232 const QuicPacketNumber current_delta = max_packets_per_fec_group_ + | 232 const QuicPacketNumber current_delta = max_packets_per_fec_group_ + |
233 packet_number_ + 1 - | 233 packet_number_ + 1 - |
234 least_packet_awaited_by_peer; | 234 least_packet_awaited_by_peer; |
235 const uint64 delta = max(current_delta, max_packets_in_flight); | 235 const uint64 delta = max(current_delta, max_packets_in_flight); |
236 next_packet_number_length_ = | 236 next_packet_number_length_ = |
237 QuicFramer::GetMinSequenceNumberLength(delta * 4); | 237 QuicFramer::GetMinSequenceNumberLength(delta * 4); |
238 } | 238 } |
239 | 239 |
| 240 bool QuicPacketCreator::ConsumeData(QuicStreamId id, |
| 241 QuicIOVector iov, |
| 242 size_t iov_offset, |
| 243 QuicStreamOffset offset, |
| 244 bool fin, |
| 245 bool needs_padding, |
| 246 QuicFrame* frame) { |
| 247 UniqueStreamBuffer buffer; |
| 248 CreateStreamFrame(id, iov, iov_offset, offset, fin, frame, &buffer); |
| 249 |
| 250 return AddFrame(*frame, |
| 251 /*save_retransmittable_frames=*/true, |
| 252 needs_padding, |
| 253 std::move(buffer)); |
| 254 } |
| 255 |
240 bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id, | 256 bool QuicPacketCreator::HasRoomForStreamFrame(QuicStreamId id, |
241 QuicStreamOffset offset) const { | 257 QuicStreamOffset offset) const { |
242 // TODO(jri): This is a simple safe decision for now, but make | 258 // TODO(jri): This is a simple safe decision for now, but make |
243 // is_in_fec_group a parameter. Same as with all public methods in | 259 // is_in_fec_group a parameter. Same as with all public methods in |
244 // QuicPacketCreator. | 260 // QuicPacketCreator. |
245 return BytesFree() > | 261 return BytesFree() > |
246 QuicFramer::GetMinStreamFrameSize(id, offset, true, | 262 QuicFramer::GetMinStreamFrameSize(id, offset, true, |
247 should_fec_protect_ ? IN_FEC_GROUP : | 263 should_fec_protect_ ? IN_FEC_GROUP : |
248 NOT_IN_FEC_GROUP); | 264 NOT_IN_FEC_GROUP); |
249 } | 265 } |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 if (BytesFree() == 0) { | 696 if (BytesFree() == 0) { |
681 // Don't pad full packets. | 697 // Don't pad full packets. |
682 return; | 698 return; |
683 } | 699 } |
684 | 700 |
685 bool success = AddFrame(QuicFrame(QuicPaddingFrame()), false, false, nullptr); | 701 bool success = AddFrame(QuicFrame(QuicPaddingFrame()), false, false, nullptr); |
686 DCHECK(success); | 702 DCHECK(success); |
687 } | 703 } |
688 | 704 |
689 } // namespace net | 705 } // namespace net |
OLD | NEW |