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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 // Called when a blocked socket becomes writable. | 126 // Called when a blocked socket becomes writable. |
127 virtual void OnCanWrite() = 0; | 127 virtual void OnCanWrite() = 0; |
128 | 128 |
129 // Called when the connection experiences a change in congestion window. | 129 // Called when the connection experiences a change in congestion window. |
130 virtual void OnCongestionWindowChange(QuicTime now) = 0; | 130 virtual void OnCongestionWindowChange(QuicTime now) = 0; |
131 | 131 |
132 // Called when the connection receives a packet from a migrated client. | 132 // Called when the connection receives a packet from a migrated client. |
133 virtual void OnConnectionMigration() = 0; | 133 virtual void OnConnectionMigration() = 0; |
134 | 134 |
| 135 // Called after OnStreamFrame, OnRstStream, OnGoAway, OnWindowUpdateFrame, |
| 136 // OnBlockedFrame, and OnCanWrite to allow post-processing once the work has |
| 137 // been done. |
| 138 virtual void PostProcessAfterData() = 0; |
| 139 |
135 // Called to ask if the visitor wants to schedule write resumption as it both | 140 // Called to ask if the visitor wants to schedule write resumption as it both |
136 // has pending data to write, and is able to write (e.g. based on flow control | 141 // has pending data to write, and is able to write (e.g. based on flow control |
137 // limits). | 142 // limits). |
138 // Writes may be pending because they were write-blocked, congestion-throttled | 143 // Writes may be pending because they were write-blocked, congestion-throttled |
139 // or yielded to other connections. | 144 // or yielded to other connections. |
140 virtual bool WillingAndAbleToWrite() const = 0; | 145 virtual bool WillingAndAbleToWrite() const = 0; |
141 | 146 |
142 // Called to ask if any handshake messages are pending in this visitor. | 147 // Called to ask if any handshake messages are pending in this visitor. |
143 virtual bool HasPendingHandshake() const = 0; | 148 virtual bool HasPendingHandshake() const = 0; |
144 | 149 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 bool SelectMutualVersion(const QuicVersionVector& available_versions); | 682 bool SelectMutualVersion(const QuicVersionVector& available_versions); |
678 | 683 |
679 bool peer_ip_changed() const { return peer_ip_changed_; } | 684 bool peer_ip_changed() const { return peer_ip_changed_; } |
680 | 685 |
681 bool peer_port_changed() const { return peer_port_changed_; } | 686 bool peer_port_changed() const { return peer_port_changed_; } |
682 | 687 |
683 const IPAddressNumber& migrating_peer_ip() const { | 688 const IPAddressNumber& migrating_peer_ip() const { |
684 return migrating_peer_ip_; | 689 return migrating_peer_ip_; |
685 } | 690 } |
686 | 691 |
| 692 // Returns the current per-packet options for the connection. |
| 693 PerPacketOptions* per_packet_options() { return per_packet_options_; } |
| 694 // Sets the current per-packet options for the connection. The QuicConnection |
| 695 // does not take ownership of |options|; |options| must live for as long as |
| 696 // the QuicConnection is in use. |
| 697 void set_per_packet_options(PerPacketOptions* options) { |
| 698 per_packet_options_ = options; |
| 699 } |
| 700 |
687 private: | 701 private: |
688 friend class test::QuicConnectionPeer; | 702 friend class test::QuicConnectionPeer; |
689 friend class test::PacketSavingConnection; | 703 friend class test::PacketSavingConnection; |
690 | 704 |
691 typedef std::list<SerializedPacket> QueuedPacketList; | 705 typedef std::list<SerializedPacket> QueuedPacketList; |
692 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; | 706 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; |
693 | 707 |
694 // Writes the given packet to socket, encrypted with packet's | 708 // Writes the given packet to socket, encrypted with packet's |
695 // encryption_level. Returns true on successful write, and false if the writer | 709 // encryption_level. Returns true on successful write, and false if the writer |
696 // was blocked and the write needs to be tried again. Notifies the | 710 // was blocked and the write needs to be tried again. Notifies the |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 // frame is sent or received. Stops receiving packets on closed path. Drops | 816 // frame is sent or received. Stops receiving packets on closed path. Drops |
803 // receive side of a closed path, and packets with retransmittable frames on a | 817 // receive side of a closed path, and packets with retransmittable frames on a |
804 // closed path are marked as retransmissions which will be transmitted on | 818 // closed path are marked as retransmissions which will be transmitted on |
805 // other paths. | 819 // other paths. |
806 // TODO(fayang): complete OnPathClosed once QuicMultipathSentPacketManager and | 820 // TODO(fayang): complete OnPathClosed once QuicMultipathSentPacketManager and |
807 // QuicMultipathReceivedPacketManager are landed in QuicConnection. | 821 // QuicMultipathReceivedPacketManager are landed in QuicConnection. |
808 void OnPathClosed(QuicPathId path_id); | 822 void OnPathClosed(QuicPathId path_id); |
809 | 823 |
810 QuicFramer framer_; | 824 QuicFramer framer_; |
811 QuicConnectionHelperInterface* helper_; // Not owned. | 825 QuicConnectionHelperInterface* helper_; // Not owned. |
| 826 PerPacketOptions* per_packet_options_; // Not owned. |
812 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. | 827 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. |
813 bool owns_writer_; | 828 bool owns_writer_; |
814 // Encryption level for new packets. Should only be changed via | 829 // Encryption level for new packets. Should only be changed via |
815 // SetDefaultEncryptionLevel(). | 830 // SetDefaultEncryptionLevel(). |
816 EncryptionLevel encryption_level_; | 831 EncryptionLevel encryption_level_; |
817 bool has_forward_secure_encrypter_; | 832 bool has_forward_secure_encrypter_; |
818 // The packet number of the first packet which will be encrypted with the | 833 // The packet number of the first packet which will be encrypted with the |
819 // foward-secure encrypter, even if the peer has not started sending | 834 // foward-secure encrypter, even if the peer has not started sending |
820 // forward-secure packets. | 835 // forward-secure packets. |
821 QuicPacketNumber first_required_forward_secure_packet_; | 836 QuicPacketNumber first_required_forward_secure_packet_; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 | 1029 |
1015 // If true, multipath is enabled for this connection. | 1030 // If true, multipath is enabled for this connection. |
1016 bool multipath_enabled_; | 1031 bool multipath_enabled_; |
1017 | 1032 |
1018 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1033 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
1019 }; | 1034 }; |
1020 | 1035 |
1021 } // namespace net | 1036 } // namespace net |
1022 | 1037 |
1023 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1038 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |