| 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 // The entity that handles framing writes for a Quic client or server. | 5 // The entity that handles framing writes for a Quic client or server. |
| 6 // Each QuicSession will have a connection associated with it. | 6 // Each QuicSession will have a connection associated with it. |
| 7 // | 7 // |
| 8 // On the server side, the Dispatcher handles the raw reads, and hands off | 8 // On the server side, the Dispatcher handles the raw reads, and hands off |
| 9 // packets via ProcessUdpPacket for framing and processing. | 9 // packets via ProcessUdpPacket for framing and processing. |
| 10 // | 10 // |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 // If the connection has timed out, this will close the connection and return | 180 // If the connection has timed out, this will close the connection and return |
| 181 // true. Otherwise, it will return false and will reset the timeout alarm. | 181 // true. Otherwise, it will return false and will reset the timeout alarm. |
| 182 bool CheckForTimeout(); | 182 bool CheckForTimeout(); |
| 183 | 183 |
| 184 // Returns true of the next packet to be sent should be "lost" by | 184 // Returns true of the next packet to be sent should be "lost" by |
| 185 // not actually writing it to the wire. | 185 // not actually writing it to the wire. |
| 186 bool ShouldSimulateLostPacket(); | 186 bool ShouldSimulateLostPacket(); |
| 187 | 187 |
| 188 protected: | 188 protected: |
| 189 // Send a packet to the peer. If resend is true, this packet contains data, | 189 // Send a packet to the peer. If should_resend is true, this packet contains |
| 190 // and will be resent if we don't get an ack. If force is true, then the | 190 // data, and contents will be resent with a new sequence number if we don't |
| 191 // packet will be sent immediately and the send scheduler will not be | 191 // get an ack. If force is true, then the packet will be sent immediately and |
| 192 // consulted. | 192 // the send scheduler will not be consulted. If is_retransmit is true, this |
| 193 // packet is being retransmitted with a new sequence number. |
| 193 virtual bool SendPacket(QuicPacketSequenceNumber number, | 194 virtual bool SendPacket(QuicPacketSequenceNumber number, |
| 194 QuicPacket* packet, | 195 QuicPacket* packet, |
| 195 bool resend, | 196 bool should_resend, |
| 196 bool force); | 197 bool force, |
| 198 bool is_retransmit); |
| 197 | 199 |
| 198 // Make sure an ack we got from our peer is sane. | 200 // Make sure an ack we got from our peer is sane. |
| 199 bool ValidateAckFrame(const QuicAckFrame& incoming_ack); | 201 bool ValidateAckFrame(const QuicAckFrame& incoming_ack); |
| 200 | 202 |
| 201 // These two are called by OnAckFrame to update the appropriate internal | 203 // These two are called by OnAckFrame to update the appropriate internal |
| 202 // state. | 204 // state. |
| 203 // | 205 // |
| 204 // Updates internal state based on incoming_ack.received_info | 206 // Updates internal state based on incoming_ack.received_info |
| 205 void UpdatePacketInformationReceivedByPeer( | 207 void UpdatePacketInformationReceivedByPeer( |
| 206 const QuicAckFrame& incoming_ack); | 208 const QuicAckFrame& incoming_ack); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 QuicPacket*> UnackedPacketMap; | 255 QuicPacket*> UnackedPacketMap; |
| 254 // When new packets are created which may be resent, they are added | 256 // When new packets are created which may be resent, they are added |
| 255 // to this map, which contains owning pointers. | 257 // to this map, which contains owning pointers. |
| 256 UnackedPacketMap unacked_packets_; | 258 UnackedPacketMap unacked_packets_; |
| 257 | 259 |
| 258 // Packets which have not been written to the wire. | 260 // Packets which have not been written to the wire. |
| 259 struct QueuedPacket { | 261 struct QueuedPacket { |
| 260 QuicPacketSequenceNumber sequence_number; | 262 QuicPacketSequenceNumber sequence_number; |
| 261 QuicPacket* packet; | 263 QuicPacket* packet; |
| 262 bool resend; | 264 bool resend; |
| 265 bool retransmit; |
| 263 | 266 |
| 264 QueuedPacket(QuicPacketSequenceNumber sequence_number, | 267 QueuedPacket(QuicPacketSequenceNumber sequence_number, |
| 265 QuicPacket* packet, | 268 QuicPacket* packet, |
| 266 bool resend) { | 269 bool resend, |
| 270 bool retransmit) { |
| 267 this->sequence_number = sequence_number; | 271 this->sequence_number = sequence_number; |
| 268 this->packet = packet; | 272 this->packet = packet; |
| 269 this->resend = resend; | 273 this->resend = resend; |
| 274 this->retransmit = retransmit; |
| 270 } | 275 } |
| 271 }; | 276 }; |
| 272 typedef std::list<QueuedPacket> QueuedPacketList; | 277 typedef std::list<QueuedPacket> QueuedPacketList; |
| 273 // When packets could not be sent because the socket was not writable, | 278 // When packets could not be sent because the socket was not writable, |
| 274 // they are added to this list. For packets that are not resendable, this | 279 // they are added to this list. For packets that are not resendable, this |
| 275 // list contains owning pointers, since they are not added to | 280 // list contains owning pointers, since they are not added to |
| 276 // unacked_packets_. | 281 // unacked_packets_. |
| 277 QueuedPacketList queued_packets_; | 282 QueuedPacketList queued_packets_; |
| 278 | 283 |
| 279 // True when the socket becomes unwritable. | 284 // True when the socket becomes unwritable. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 302 scoped_ptr<QuicSendScheduler> scheduler_; | 307 scoped_ptr<QuicSendScheduler> scheduler_; |
| 303 | 308 |
| 304 // True by default. False if we've received or sent an explicit connection | 309 // True by default. False if we've received or sent an explicit connection |
| 305 // close. | 310 // close. |
| 306 bool connected_; | 311 bool connected_; |
| 307 }; | 312 }; |
| 308 | 313 |
| 309 } // namespace net | 314 } // namespace net |
| 310 | 315 |
| 311 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 316 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |