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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Called when a StopWaitingFrame has been parsed. | 153 // Called when a StopWaitingFrame has been parsed. |
154 virtual void OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {} | 154 virtual void OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {} |
155 | 155 |
156 // Called when a Ping has been parsed. | 156 // Called when a Ping has been parsed. |
157 virtual void OnPingFrame(const QuicPingFrame& frame) {} | 157 virtual void OnPingFrame(const QuicPingFrame& frame) {} |
158 | 158 |
159 // Called when a RstStreamFrame has been parsed. | 159 // Called when a RstStreamFrame has been parsed. |
160 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) {} | 160 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) {} |
161 | 161 |
162 // Called when a ConnectionCloseFrame has been parsed. | 162 // Called when a ConnectionCloseFrame has been parsed. |
163 virtual void OnConnectionCloseFrame( | 163 virtual void OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) {} |
164 const QuicConnectionCloseFrame& frame) {} | |
165 | 164 |
166 // Called when a public reset packet has been received. | 165 // Called when a public reset packet has been received. |
167 virtual void OnPublicResetPacket(const QuicPublicResetPacket& packet) {} | 166 virtual void OnPublicResetPacket(const QuicPublicResetPacket& packet) {} |
168 | 167 |
169 // Called when a version negotiation packet has been received. | 168 // Called when a version negotiation packet has been received. |
170 virtual void OnVersionNegotiationPacket( | 169 virtual void OnVersionNegotiationPacket( |
171 const QuicVersionNegotiationPacket& packet) {} | 170 const QuicVersionNegotiationPacket& packet) {} |
172 | 171 |
173 // Called after a packet has been successfully parsed which results | 172 // Called after a packet has been successfully parsed which results |
174 // in the revival of a packet via FEC. | 173 // in the revival of a packet via FEC. |
(...skipping 15 matching lines...) Expand all Loading... |
190 // notify |delegate| when the alarm fires. Caller takes ownership | 189 // notify |delegate| when the alarm fires. Caller takes ownership |
191 // of the new alarm, which will not yet be "set" to fire. | 190 // of the new alarm, which will not yet be "set" to fire. |
192 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) = 0; | 191 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) = 0; |
193 }; | 192 }; |
194 | 193 |
195 class NET_EXPORT_PRIVATE QuicConnection | 194 class NET_EXPORT_PRIVATE QuicConnection |
196 : public QuicFramerVisitorInterface, | 195 : public QuicFramerVisitorInterface, |
197 public QuicBlockedWriterInterface, | 196 public QuicBlockedWriterInterface, |
198 public QuicPacketGenerator::DelegateInterface { | 197 public QuicPacketGenerator::DelegateInterface { |
199 public: | 198 public: |
200 enum PacketType { | 199 enum PacketType { NORMAL, QUEUED, CONNECTION_CLOSE }; |
201 NORMAL, | |
202 QUEUED, | |
203 CONNECTION_CLOSE | |
204 }; | |
205 | 200 |
206 enum AckBundling { | 201 enum AckBundling { |
207 NO_ACK = 0, | 202 NO_ACK = 0, |
208 SEND_ACK = 1, | 203 SEND_ACK = 1, |
209 BUNDLE_PENDING_ACK = 2, | 204 BUNDLE_PENDING_ACK = 2, |
210 }; | 205 }; |
211 | 206 |
212 // Constructs a new QuicConnection for |connection_id| and |address|. | 207 // Constructs a new QuicConnection for |connection_id| and |address|. |
213 // |helper| and |writer| must outlive this connection. | 208 // |helper| and |writer| must outlive this connection. |
214 QuicConnection(QuicConnectionId connection_id, | 209 QuicConnection(QuicConnectionId connection_id, |
(...skipping 24 matching lines...) Expand all Loading... |
239 | 234 |
240 // Send a RST_STREAM frame to the peer. | 235 // Send a RST_STREAM frame to the peer. |
241 virtual void SendRstStream(QuicStreamId id, | 236 virtual void SendRstStream(QuicStreamId id, |
242 QuicRstStreamErrorCode error, | 237 QuicRstStreamErrorCode error, |
243 QuicStreamOffset bytes_written); | 238 QuicStreamOffset bytes_written); |
244 | 239 |
245 // Send a BLOCKED frame to the peer. | 240 // Send a BLOCKED frame to the peer. |
246 virtual void SendBlocked(QuicStreamId id); | 241 virtual void SendBlocked(QuicStreamId id); |
247 | 242 |
248 // Send a WINDOW_UPDATE frame to the peer. | 243 // Send a WINDOW_UPDATE frame to the peer. |
249 virtual void SendWindowUpdate(QuicStreamId id, | 244 virtual void SendWindowUpdate(QuicStreamId id, QuicStreamOffset byte_offset); |
250 QuicStreamOffset byte_offset); | |
251 | 245 |
252 // Sends the connection close packet without affecting the state of the | 246 // Sends the connection close packet without affecting the state of the |
253 // connection. This should only be called if the session is actively being | 247 // connection. This should only be called if the session is actively being |
254 // destroyed: otherwise call SendConnectionCloseWithDetails instead. | 248 // destroyed: otherwise call SendConnectionCloseWithDetails instead. |
255 virtual void SendConnectionClosePacket(QuicErrorCode error, | 249 virtual void SendConnectionClosePacket(QuicErrorCode error, |
256 const std::string& details); | 250 const std::string& details); |
257 | 251 |
258 // Sends a connection close frame to the peer, and closes the connection by | 252 // Sends a connection close frame to the peer, and closes the connection by |
259 // calling CloseConnection(notifying the visitor as it does so). | 253 // calling CloseConnection(notifying the visitor as it does so). |
260 virtual void SendConnectionClose(QuicErrorCode error); | 254 virtual void SendConnectionClose(QuicErrorCode error); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 QuicFecGroup* GetFecGroup(); | 597 QuicFecGroup* GetFecGroup(); |
604 | 598 |
605 // Closes any FEC groups protecting packets before |sequence_number|. | 599 // Closes any FEC groups protecting packets before |sequence_number|. |
606 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); | 600 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); |
607 | 601 |
608 // Sets the ping alarm to the appropriate value, if any. | 602 // Sets the ping alarm to the appropriate value, if any. |
609 void SetPingAlarm(); | 603 void SetPingAlarm(); |
610 | 604 |
611 QuicFramer framer_; | 605 QuicFramer framer_; |
612 QuicConnectionHelperInterface* helper_; // Not owned. | 606 QuicConnectionHelperInterface* helper_; // Not owned. |
613 QuicPacketWriter* writer_; // Not owned. | 607 QuicPacketWriter* writer_; // Not owned. |
614 EncryptionLevel encryption_level_; | 608 EncryptionLevel encryption_level_; |
615 const QuicClock* clock_; | 609 const QuicClock* clock_; |
616 QuicRandom* random_generator_; | 610 QuicRandom* random_generator_; |
617 | 611 |
618 const QuicConnectionId connection_id_; | 612 const QuicConnectionId connection_id_; |
619 // Address on the last successfully processed packet received from the | 613 // Address on the last successfully processed packet received from the |
620 // client. | 614 // client. |
621 IPEndPoint self_address_; | 615 IPEndPoint self_address_; |
622 IPEndPoint peer_address_; | 616 IPEndPoint peer_address_; |
623 | 617 |
624 bool last_packet_revived_; // True if the last packet was revived from FEC. | 618 bool last_packet_revived_; // True if the last packet was revived from FEC. |
625 size_t last_size_; // Size of the last received packet. | 619 size_t last_size_; // Size of the last received packet. |
626 EncryptionLevel last_decrypted_packet_level_; | 620 EncryptionLevel last_decrypted_packet_level_; |
627 QuicPacketHeader last_header_; | 621 QuicPacketHeader last_header_; |
628 std::vector<QuicStreamFrame> last_stream_frames_; | 622 std::vector<QuicStreamFrame> last_stream_frames_; |
629 std::vector<QuicAckFrame> last_ack_frames_; | 623 std::vector<QuicAckFrame> last_ack_frames_; |
630 std::vector<QuicCongestionFeedbackFrame> last_congestion_frames_; | 624 std::vector<QuicCongestionFeedbackFrame> last_congestion_frames_; |
631 std::vector<QuicStopWaitingFrame> last_stop_waiting_frames_; | 625 std::vector<QuicStopWaitingFrame> last_stop_waiting_frames_; |
632 std::vector<QuicRstStreamFrame> last_rst_frames_; | 626 std::vector<QuicRstStreamFrame> last_rst_frames_; |
633 std::vector<QuicGoAwayFrame> last_goaway_frames_; | 627 std::vector<QuicGoAwayFrame> last_goaway_frames_; |
634 std::vector<QuicWindowUpdateFrame> last_window_update_frames_; | 628 std::vector<QuicWindowUpdateFrame> last_window_update_frames_; |
635 std::vector<QuicBlockedFrame> last_blocked_frames_; | 629 std::vector<QuicBlockedFrame> last_blocked_frames_; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 735 |
742 // Initial flow control receive window size for new streams. | 736 // Initial flow control receive window size for new streams. |
743 uint32 max_flow_control_receive_window_bytes_; | 737 uint32 max_flow_control_receive_window_bytes_; |
744 | 738 |
745 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 739 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
746 }; | 740 }; |
747 | 741 |
748 } // namespace net | 742 } // namespace net |
749 | 743 |
750 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 744 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |