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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 // will be the one last used. | 487 // will be the one last used. |
488 void SetAlternativeDecrypter(QuicDecrypter* decrypter, | 488 void SetAlternativeDecrypter(QuicDecrypter* decrypter, |
489 EncryptionLevel level, | 489 EncryptionLevel level, |
490 bool latch_once_used); | 490 bool latch_once_used); |
491 | 491 |
492 const QuicDecrypter* decrypter() const; | 492 const QuicDecrypter* decrypter() const; |
493 const QuicDecrypter* alternative_decrypter() const; | 493 const QuicDecrypter* alternative_decrypter() const; |
494 | 494 |
495 bool is_server() const { return is_server_; } | 495 bool is_server() const { return is_server_; } |
496 | 496 |
| 497 // Allow easy overriding of truncated connection IDs. |
| 498 void set_can_truncate_connection_ids(bool can) { |
| 499 can_truncate_connection_ids_ = can; |
| 500 } |
| 501 |
497 // Returns the underlying sent packet manager. | 502 // Returns the underlying sent packet manager. |
498 const QuicSentPacketManager& sent_packet_manager() const { | 503 const QuicSentPacketManager& sent_packet_manager() const { |
499 return sent_packet_manager_; | 504 return sent_packet_manager_; |
500 } | 505 } |
501 | 506 |
502 bool CanWrite(HasRetransmittableData retransmittable); | 507 bool CanWrite(HasRetransmittableData retransmittable); |
503 | 508 |
504 // Stores current batch state for connection, puts the connection | 509 // Stores current batch state for connection, puts the connection |
505 // into batch mode, and destruction restores the stored batch state. | 510 // into batch mode, and destruction restores the stored batch state. |
506 // While the bundler is in scope, any generated frames are bundled | 511 // While the bundler is in scope, any generated frames are bundled |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 virtual void SendOrQueuePacket(QueuedPacket packet); | 555 virtual void SendOrQueuePacket(QueuedPacket packet); |
551 | 556 |
552 QuicConnectionHelperInterface* helper() { return helper_; } | 557 QuicConnectionHelperInterface* helper() { return helper_; } |
553 | 558 |
554 // Selects and updates the version of the protocol being used by selecting a | 559 // Selects and updates the version of the protocol being used by selecting a |
555 // version from |available_versions| which is also supported. Returns true if | 560 // version from |available_versions| which is also supported. Returns true if |
556 // such a version exists, false otherwise. | 561 // such a version exists, false otherwise. |
557 bool SelectMutualVersion(const QuicVersionVector& available_versions); | 562 bool SelectMutualVersion(const QuicVersionVector& available_versions); |
558 | 563 |
559 QuicPacketWriter* writer() { return writer_; } | 564 QuicPacketWriter* writer() { return writer_; } |
| 565 const QuicPacketWriter* writer() const { return writer_; } |
560 | 566 |
561 bool peer_port_changed() const { return peer_port_changed_; } | 567 bool peer_port_changed() const { return peer_port_changed_; } |
562 | 568 |
563 QuicPacketSequenceNumber sequence_number_of_last_sent_packet() const { | 569 QuicPacketSequenceNumber sequence_number_of_last_sent_packet() const { |
564 return sequence_number_of_last_sent_packet_; | 570 return sequence_number_of_last_sent_packet_; |
565 } | 571 } |
566 | 572 |
567 private: | 573 private: |
568 friend class test::QuicConnectionPeer; | 574 friend class test::QuicConnectionPeer; |
569 friend class test::PacketSavingConnection; | 575 friend class test::PacketSavingConnection; |
(...skipping 19 matching lines...) Expand all Loading... |
589 | 595 |
590 // Make sure a stop waiting we got from our peer is sane. | 596 // Make sure a stop waiting we got from our peer is sane. |
591 bool ValidateStopWaitingFrame(const QuicStopWaitingFrame& stop_waiting); | 597 bool ValidateStopWaitingFrame(const QuicStopWaitingFrame& stop_waiting); |
592 | 598 |
593 // Sends a version negotiation packet to the peer. | 599 // Sends a version negotiation packet to the peer. |
594 void SendVersionNegotiationPacket(); | 600 void SendVersionNegotiationPacket(); |
595 | 601 |
596 // Clears any accumulated frames from the last received packet. | 602 // Clears any accumulated frames from the last received packet. |
597 void ClearLastFrames(); | 603 void ClearLastFrames(); |
598 | 604 |
| 605 // Closes the connection if the sent or received packet manager are tracking |
| 606 // too many outstanding packets. |
| 607 void MaybeCloseIfTooManyOutstandingPackets(); |
| 608 |
599 // Writes as many queued packets as possible. The connection must not be | 609 // Writes as many queued packets as possible. The connection must not be |
600 // blocked when this is called. | 610 // blocked when this is called. |
601 void WriteQueuedPackets(); | 611 void WriteQueuedPackets(); |
602 | 612 |
603 // Writes as many pending retransmissions as possible. | 613 // Writes as many pending retransmissions as possible. |
604 void WritePendingRetransmissions(); | 614 void WritePendingRetransmissions(); |
605 | 615 |
606 // Returns true if the packet should be discarded and not sent. | 616 // Returns true if the packet should be discarded and not sent. |
607 bool ShouldDiscardPacket(const QueuedPacket& packet); | 617 bool ShouldDiscardPacket(const QueuedPacket& packet); |
608 | 618 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 bool peer_port_changed_; | 814 bool peer_port_changed_; |
805 | 815 |
806 // Set to true if the UDP packet headers are addressed to a different IP. | 816 // Set to true if the UDP packet headers are addressed to a different IP. |
807 // We do not support connection migration when the self IP changed. | 817 // We do not support connection migration when the self IP changed. |
808 bool self_ip_changed_; | 818 bool self_ip_changed_; |
809 | 819 |
810 // Set to true if the UDP packet headers are addressed to a different port. | 820 // Set to true if the UDP packet headers are addressed to a different port. |
811 // We do not support connection migration when the self port changed. | 821 // We do not support connection migration when the self port changed. |
812 bool self_port_changed_; | 822 bool self_port_changed_; |
813 | 823 |
| 824 // Set to false if the connection should not send truncated connection IDs to |
| 825 // the peer, even if the peer supports it. |
| 826 bool can_truncate_connection_ids_; |
| 827 |
814 // If non-empty this contains the set of versions received in a | 828 // If non-empty this contains the set of versions received in a |
815 // version negotiation packet. | 829 // version negotiation packet. |
816 QuicVersionVector server_supported_versions_; | 830 QuicVersionVector server_supported_versions_; |
817 | 831 |
818 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 832 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
819 }; | 833 }; |
820 | 834 |
821 } // namespace net | 835 } // namespace net |
822 | 836 |
823 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 837 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |