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 // |
11 // On the client side, the Connection handles the raw reads, as well as the | 11 // On the client side, the Connection handles the raw reads, as well as the |
12 // processing. | 12 // processing. |
13 // | 13 // |
14 // Note: this class is not thread-safe. | 14 // Note: this class is not thread-safe. |
15 | 15 |
16 #ifndef NET_QUIC_QUIC_CONNECTION_H_ | 16 #ifndef NET_QUIC_QUIC_CONNECTION_H_ |
17 #define NET_QUIC_QUIC_CONNECTION_H_ | 17 #define NET_QUIC_QUIC_CONNECTION_H_ |
18 | 18 |
19 #include <deque> | 19 #include <deque> |
20 #include <list> | 20 #include <list> |
21 #include <map> | 21 #include <map> |
22 #include <queue> | 22 #include <queue> |
23 #include <set> | 23 #include <set> |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 #include "base/containers/hash_tables.h" | 26 #include "base/containers/hash_tables.h" |
27 #include "net/base/ip_endpoint.h" | 27 #include "net/base/ip_endpoint.h" |
28 #include "net/base/linked_hash_map.h" | 28 #include "net/base/linked_hash_map.h" |
29 #include "net/quic/congestion_control/quic_congestion_manager.h" | 29 #include "net/quic/congestion_control/quic_congestion_manager.h" |
| 30 #include "net/quic/quic_ack_notifier.h" |
30 #include "net/quic/quic_alarm.h" | 31 #include "net/quic/quic_alarm.h" |
31 #include "net/quic/quic_blocked_writer_interface.h" | 32 #include "net/quic/quic_blocked_writer_interface.h" |
32 #include "net/quic/quic_connection_stats.h" | 33 #include "net/quic/quic_connection_stats.h" |
33 #include "net/quic/quic_framer.h" | 34 #include "net/quic/quic_framer.h" |
34 #include "net/quic/quic_packet_creator.h" | 35 #include "net/quic/quic_packet_creator.h" |
35 #include "net/quic/quic_packet_generator.h" | 36 #include "net/quic/quic_packet_generator.h" |
36 #include "net/quic/quic_protocol.h" | 37 #include "net/quic/quic_protocol.h" |
37 #include "net/quic/quic_received_packet_manager.h" | 38 #include "net/quic/quic_received_packet_manager.h" |
38 #include "net/quic/quic_sent_entropy_manager.h" | 39 #include "net/quic/quic_sent_entropy_manager.h" |
39 | 40 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 207 |
207 // Send the data payload to the peer. | 208 // Send the data payload to the peer. |
208 // Returns a pair with the number of bytes consumed from data, and a boolean | 209 // Returns a pair with the number of bytes consumed from data, and a boolean |
209 // indicating if the fin bit was consumed. This does not indicate the data | 210 // indicating if the fin bit was consumed. This does not indicate the data |
210 // has been sent on the wire: it may have been turned into a packet and queued | 211 // has been sent on the wire: it may have been turned into a packet and queued |
211 // if the socket was unexpectedly blocked. | 212 // if the socket was unexpectedly blocked. |
212 QuicConsumedData SendStreamData(QuicStreamId id, | 213 QuicConsumedData SendStreamData(QuicStreamId id, |
213 base::StringPiece data, | 214 base::StringPiece data, |
214 QuicStreamOffset offset, | 215 QuicStreamOffset offset, |
215 bool fin); | 216 bool fin); |
| 217 // Same as above, except that the provided delegate will be informed once ACKs |
| 218 // have been received for all the packets written. |
| 219 // The |delegate| is not owned by the QuicConnection and must outlive it. |
| 220 QuicConsumedData SendStreamDataAndNotifyWhenAcked( |
| 221 QuicStreamId id, |
| 222 base::StringPiece data, |
| 223 QuicStreamOffset offset, |
| 224 bool fin, |
| 225 QuicAckNotifier::DelegateInterface* delegate); |
| 226 |
216 // Send a stream reset frame to the peer. | 227 // Send a stream reset frame to the peer. |
217 virtual void SendRstStream(QuicStreamId id, | 228 virtual void SendRstStream(QuicStreamId id, |
218 QuicRstStreamErrorCode error); | 229 QuicRstStreamErrorCode error); |
219 | 230 |
220 // Sends the connection close packet without affecting the state of the | 231 // Sends the connection close packet without affecting the state of the |
221 // connection. This should only be called if the session is actively being | 232 // connection. This should only be called if the session is actively being |
222 // destroyed: otherwise call SendConnectionCloseWithDetails instead. | 233 // destroyed: otherwise call SendConnectionCloseWithDetails instead. |
223 virtual void SendConnectionClosePacket(QuicErrorCode error, | 234 virtual void SendConnectionClosePacket(QuicErrorCode error, |
224 const std::string& details); | 235 const std::string& details); |
225 | 236 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 typedef std::list<QueuedPacket> QueuedPacketList; | 508 typedef std::list<QueuedPacket> QueuedPacketList; |
498 typedef linked_hash_map<QuicPacketSequenceNumber, | 509 typedef linked_hash_map<QuicPacketSequenceNumber, |
499 RetransmittableFrames*> UnackedPacketMap; | 510 RetransmittableFrames*> UnackedPacketMap; |
500 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; | 511 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; |
501 typedef base::hash_map<QuicPacketSequenceNumber, | 512 typedef base::hash_map<QuicPacketSequenceNumber, |
502 RetransmissionInfo> RetransmissionMap; | 513 RetransmissionInfo> RetransmissionMap; |
503 typedef std::priority_queue<RetransmissionTime, | 514 typedef std::priority_queue<RetransmissionTime, |
504 std::vector<RetransmissionTime>, | 515 std::vector<RetransmissionTime>, |
505 RetransmissionTimeComparator> | 516 RetransmissionTimeComparator> |
506 RetransmissionTimeouts; | 517 RetransmissionTimeouts; |
| 518 typedef std::list<QuicAckNotifier*> AckNotifierList; |
507 | 519 |
508 // Sends a version negotiation packet to the peer. | 520 // Sends a version negotiation packet to the peer. |
509 void SendVersionNegotiationPacket(); | 521 void SendVersionNegotiationPacket(); |
510 | 522 |
511 void SetupRetransmission(QuicPacketSequenceNumber sequence_number, | 523 void SetupRetransmission(QuicPacketSequenceNumber sequence_number, |
512 EncryptionLevel level); | 524 EncryptionLevel level); |
513 bool IsRetransmission(QuicPacketSequenceNumber sequence_number); | 525 bool IsRetransmission(QuicPacketSequenceNumber sequence_number); |
514 | 526 |
515 void SetupAbandonFecTimer(QuicPacketSequenceNumber sequence_number); | 527 void SetupAbandonFecTimer(QuicPacketSequenceNumber sequence_number); |
516 | 528 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 706 |
695 // True if the last ack received from the peer may have been truncated. False | 707 // True if the last ack received from the peer may have been truncated. False |
696 // otherwise. | 708 // otherwise. |
697 bool received_truncated_ack_; | 709 bool received_truncated_ack_; |
698 bool send_ack_in_response_to_packet_; | 710 bool send_ack_in_response_to_packet_; |
699 | 711 |
700 // Set to true if the udp packet headers have a new self or peer address. | 712 // Set to true if the udp packet headers have a new self or peer address. |
701 // This is checked later on validating a data or version negotiation packet. | 713 // This is checked later on validating a data or version negotiation packet. |
702 bool address_migrating_; | 714 bool address_migrating_; |
703 | 715 |
| 716 // On every ACK frame received by this connection, all the ack_notifiers_ will |
| 717 // be told which sequeunce numbers were ACKed. |
| 718 // Once a given QuicAckNotifier has seen all the sequence numbers it is |
| 719 // interested in, it will be deleted, and removed from this list. |
| 720 AckNotifierList ack_notifiers_; |
| 721 |
704 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 722 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
705 }; | 723 }; |
706 | 724 |
707 } // namespace net | 725 } // namespace net |
708 | 726 |
709 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 727 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |