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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Called when a blocked socket becomes writable. | 96 // Called when a blocked socket becomes writable. |
97 virtual void OnCanWrite() = 0; | 97 virtual void OnCanWrite() = 0; |
98 | 98 |
99 // Called to ask if any writes are pending in this visitor. Writes may be | 99 // Called to ask if any writes are pending in this visitor. Writes may be |
100 // pending because they were write-blocked, congestion-throttled or | 100 // pending because they were write-blocked, congestion-throttled or |
101 // yielded to other connections. | 101 // yielded to other connections. |
102 virtual bool HasPendingWrites() const = 0; | 102 virtual bool HasPendingWrites() const = 0; |
103 | 103 |
104 // Called to ask if any handshake messages are pending in this visitor. | 104 // Called to ask if any handshake messages are pending in this visitor. |
105 virtual bool HasPendingHandshake() const = 0; | 105 virtual bool HasPendingHandshake() const = 0; |
| 106 |
| 107 // Called to ask if any streams are open in this visitor, excluding the |
| 108 // reserved crypto and headers stream. |
| 109 virtual bool HasOpenDataStreams() const = 0; |
106 }; | 110 }; |
107 | 111 |
108 // Interface which gets callbacks from the QuicConnection at interesting | 112 // Interface which gets callbacks from the QuicConnection at interesting |
109 // points. Implementations must not mutate the state of the connection | 113 // points. Implementations must not mutate the state of the connection |
110 // as a result of these callbacks. | 114 // as a result of these callbacks. |
111 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitorInterface | 115 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitorInterface |
112 : public QuicPacketGenerator::DebugDelegateInterface { | 116 : public QuicPacketGenerator::DebugDelegateInterface { |
113 public: | 117 public: |
114 virtual ~QuicConnectionDebugVisitorInterface() {} | 118 virtual ~QuicConnectionDebugVisitorInterface() {} |
115 | 119 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 // Sets (or resets) the total time delta the connection can be alive for. | 388 // Sets (or resets) the total time delta the connection can be alive for. |
385 // Also, checks and times out the connection if timer has expired for | 389 // Also, checks and times out the connection if timer has expired for |
386 // |timeout|. Used to limit the time a connection can be alive before crypto | 390 // |timeout|. Used to limit the time a connection can be alive before crypto |
387 // handshake finishes. | 391 // handshake finishes. |
388 void SetOverallConnectionTimeout(QuicTime::Delta timeout); | 392 void SetOverallConnectionTimeout(QuicTime::Delta timeout); |
389 | 393 |
390 // If the connection has timed out, this will close the connection and return | 394 // If the connection has timed out, this will close the connection and return |
391 // true. Otherwise, it will return false and will reset the timeout alarm. | 395 // true. Otherwise, it will return false and will reset the timeout alarm. |
392 bool CheckForTimeout(); | 396 bool CheckForTimeout(); |
393 | 397 |
| 398 // Sends a ping, and resets the ping alarm. |
| 399 void SendPing(); |
| 400 |
394 // Sets up a packet with an QuicAckFrame and sends it out. | 401 // Sets up a packet with an QuicAckFrame and sends it out. |
395 void SendAck(); | 402 void SendAck(); |
396 | 403 |
397 // Called when an RTO fires. Resets the retransmission alarm if there are | 404 // Called when an RTO fires. Resets the retransmission alarm if there are |
398 // remaining unacked packets. | 405 // remaining unacked packets. |
399 void OnRetransmissionTimeout(); | 406 void OnRetransmissionTimeout(); |
400 | 407 |
401 // Retransmits all unacked packets with retransmittable frames if | 408 // Retransmits all unacked packets with retransmittable frames if |
402 // |retransmission_type| is ALL_PACKETS, otherwise retransmits only initially | 409 // |retransmission_type| is ALL_PACKETS, otherwise retransmits only initially |
403 // encrypted packets. Used when the negotiated protocol version is different | 410 // encrypted packets. Used when the negotiated protocol version is different |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // to be sent if there are no outstanding packets. | 590 // to be sent if there are no outstanding packets. |
584 QuicPacketSequenceNumber GetLeastUnacked() const; | 591 QuicPacketSequenceNumber GetLeastUnacked() const; |
585 | 592 |
586 // Get the FEC group associate with the last processed packet or NULL, if the | 593 // Get the FEC group associate with the last processed packet or NULL, if the |
587 // group has already been deleted. | 594 // group has already been deleted. |
588 QuicFecGroup* GetFecGroup(); | 595 QuicFecGroup* GetFecGroup(); |
589 | 596 |
590 // Closes any FEC groups protecting packets before |sequence_number|. | 597 // Closes any FEC groups protecting packets before |sequence_number|. |
591 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); | 598 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); |
592 | 599 |
| 600 // Sets the ping alarm to the appropriate value, if any. |
| 601 void SetPingAlarm(); |
| 602 |
593 QuicFramer framer_; | 603 QuicFramer framer_; |
594 QuicConnectionHelperInterface* helper_; // Not owned. | 604 QuicConnectionHelperInterface* helper_; // Not owned. |
595 QuicPacketWriter* writer_; // Not owned. | 605 QuicPacketWriter* writer_; // Not owned. |
596 EncryptionLevel encryption_level_; | 606 EncryptionLevel encryption_level_; |
597 const QuicClock* clock_; | 607 const QuicClock* clock_; |
598 QuicRandom* random_generator_; | 608 QuicRandom* random_generator_; |
599 | 609 |
600 const QuicConnectionId connection_id_; | 610 const QuicConnectionId connection_id_; |
601 // Address on the last successfully processed packet received from the | 611 // Address on the last successfully processed packet received from the |
602 // client. | 612 // client. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // An alarm that fires when a packet needs to be retransmitted. | 672 // An alarm that fires when a packet needs to be retransmitted. |
663 scoped_ptr<QuicAlarm> retransmission_alarm_; | 673 scoped_ptr<QuicAlarm> retransmission_alarm_; |
664 // An alarm that is scheduled when the sent scheduler requires a | 674 // An alarm that is scheduled when the sent scheduler requires a |
665 // a delay before sending packets and fires when the packet may be sent. | 675 // a delay before sending packets and fires when the packet may be sent. |
666 scoped_ptr<QuicAlarm> send_alarm_; | 676 scoped_ptr<QuicAlarm> send_alarm_; |
667 // An alarm that is scheduled when the connection can still write and there | 677 // An alarm that is scheduled when the connection can still write and there |
668 // may be more data to send. | 678 // may be more data to send. |
669 scoped_ptr<QuicAlarm> resume_writes_alarm_; | 679 scoped_ptr<QuicAlarm> resume_writes_alarm_; |
670 // An alarm that fires when the connection may have timed out. | 680 // An alarm that fires when the connection may have timed out. |
671 scoped_ptr<QuicAlarm> timeout_alarm_; | 681 scoped_ptr<QuicAlarm> timeout_alarm_; |
| 682 // An alarm that fires when a ping should be sent. |
| 683 scoped_ptr<QuicAlarm> ping_alarm_; |
672 | 684 |
673 QuicConnectionVisitorInterface* visitor_; | 685 QuicConnectionVisitorInterface* visitor_; |
674 QuicConnectionDebugVisitorInterface* debug_visitor_; | 686 QuicConnectionDebugVisitorInterface* debug_visitor_; |
675 QuicPacketCreator packet_creator_; | 687 QuicPacketCreator packet_creator_; |
676 QuicPacketGenerator packet_generator_; | 688 QuicPacketGenerator packet_generator_; |
677 | 689 |
678 // Network idle time before we kill of this connection. | 690 // Network idle time before we kill of this connection. |
679 QuicTime::Delta idle_network_timeout_; | 691 QuicTime::Delta idle_network_timeout_; |
680 // Overall connection timeout. | 692 // Overall connection timeout. |
681 QuicTime::Delta overall_connection_timeout_; | 693 QuicTime::Delta overall_connection_timeout_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 | 734 |
723 // Initial flow control receive window size for new streams. | 735 // Initial flow control receive window size for new streams. |
724 uint32 max_flow_control_receive_window_bytes_; | 736 uint32 max_flow_control_receive_window_bytes_; |
725 | 737 |
726 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 738 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
727 }; | 739 }; |
728 | 740 |
729 } // namespace net | 741 } // namespace net |
730 | 742 |
731 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 743 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |