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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/quic_utils.h" | 8 #include "net/quic/quic_utils.h" |
9 | 9 |
10 using base::StringPiece; | 10 using base::StringPiece; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 bool QuicPacketCreator::HasPendingFrames() { | 87 bool QuicPacketCreator::HasPendingFrames() { |
88 return !queued_frames_.empty(); | 88 return !queued_frames_.empty(); |
89 } | 89 } |
90 | 90 |
91 size_t QuicPacketCreator::BytesFree() { | 91 size_t QuicPacketCreator::BytesFree() { |
92 const size_t max_plaintext_size = | 92 const size_t max_plaintext_size = |
93 framer_->GetMaxPlaintextSize(options_.max_packet_length); | 93 framer_->GetMaxPlaintextSize(options_.max_packet_length); |
94 if (packet_size_ > max_plaintext_size) { | 94 if (packet_size_ > max_plaintext_size) { |
95 return 0; | 95 return 0; |
96 } else { | |
97 return max_plaintext_size - packet_size_; | |
98 } | 96 } |
| 97 return max_plaintext_size - packet_size_; |
99 } | 98 } |
100 | 99 |
101 bool QuicPacketCreator::AddFrame(const QuicFrame& frame) { | 100 bool QuicPacketCreator::AddFrame(const QuicFrame& frame) { |
102 size_t frame_len = framer_->GetSerializedFrameLength( | 101 size_t frame_len = framer_->GetSerializedFrameLength( |
103 frame, BytesFree(), queued_frames_.empty()); | 102 frame, BytesFree(), queued_frames_.empty()); |
104 if (frame_len == 0) { | 103 if (frame_len == 0) { |
105 return false; | 104 return false; |
106 } | 105 } |
107 packet_size_ += frame_len; | 106 packet_size_ += frame_len; |
108 queued_frames_.push_back(frame); | 107 queued_frames_.push_back(frame); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 header->packet_sequence_number = ++sequence_number_; | 159 header->packet_sequence_number = ++sequence_number_; |
161 header->fec_group = fec_group; | 160 header->fec_group = fec_group; |
162 } | 161 } |
163 | 162 |
164 bool QuicPacketCreator::ShouldRetransmit(const QuicFrame& frame) { | 163 bool QuicPacketCreator::ShouldRetransmit(const QuicFrame& frame) { |
165 return frame.type != ACK_FRAME && frame.type != CONGESTION_FEEDBACK_FRAME && | 164 return frame.type != ACK_FRAME && frame.type != CONGESTION_FEEDBACK_FRAME && |
166 frame.type != PADDING_FRAME; | 165 frame.type != PADDING_FRAME; |
167 } | 166 } |
168 | 167 |
169 } // namespace net | 168 } // namespace net |
OLD | NEW |