| 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 void EnableSavingCryptoPackets(); | 512 void EnableSavingCryptoPackets(); |
| 513 | 513 |
| 514 // Returns true if the underlying UDP socket is writable, there is | 514 // Returns true if the underlying UDP socket is writable, there is |
| 515 // no queued data and the connection is not congestion-control | 515 // no queued data and the connection is not congestion-control |
| 516 // blocked. | 516 // blocked. |
| 517 bool CanWriteStreamData(); | 517 bool CanWriteStreamData(); |
| 518 | 518 |
| 519 // Returns true if the connection has queued packets or frames. | 519 // Returns true if the connection has queued packets or frames. |
| 520 bool HasQueuedData() const; | 520 bool HasQueuedData() const; |
| 521 | 521 |
| 522 // Sets the overall and idle state connection timeouts. | 522 // Sets the handshake and idle state connection timeouts. |
| 523 void SetNetworkTimeouts(QuicTime::Delta overall_timeout, | 523 void SetNetworkTimeouts(QuicTime::Delta handshake_timeout, |
| 524 QuicTime::Delta idle_timeout); | 524 QuicTime::Delta idle_timeout); |
| 525 | 525 |
| 526 // If the connection has timed out, this will close the connection. | 526 // If the connection has timed out, this will close the connection. |
| 527 // Otherwise, it will reschedule the timeout alarm. | 527 // Otherwise, it will reschedule the timeout alarm. |
| 528 void CheckForTimeout(); | 528 void CheckForTimeout(); |
| 529 | 529 |
| 530 // Called when the ping alarm fires. Causes a ping frame to be sent only | 530 // Called when the ping alarm fires. Causes a ping frame to be sent only |
| 531 // if the retransmission alarm is not running. | 531 // if the retransmission alarm is not running. |
| 532 void OnPingTimeout(); | 532 void OnPingTimeout(); |
| 533 | 533 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 705 |
| 706 // Writes the given packet to socket, encrypted with packet's | 706 // Writes the given packet to socket, encrypted with packet's |
| 707 // encryption_level. Returns true on successful write, and false if the writer | 707 // encryption_level. Returns true on successful write, and false if the writer |
| 708 // was blocked and the write needs to be tried again. Notifies the | 708 // was blocked and the write needs to be tried again. Notifies the |
| 709 // SentPacketManager when the write is successful and sets | 709 // SentPacketManager when the write is successful and sets |
| 710 // retransmittable frames to nullptr. | 710 // retransmittable frames to nullptr. |
| 711 // Saves the connection close packet for later transmission, even if the | 711 // Saves the connection close packet for later transmission, even if the |
| 712 // writer is write blocked. | 712 // writer is write blocked. |
| 713 bool WritePacket(SerializedPacket* packet); | 713 bool WritePacket(SerializedPacket* packet); |
| 714 | 714 |
| 715 // Does the main work of WritePacket, but does not delete the packet or | |
| 716 // retransmittable frames upon success. | |
| 717 bool WritePacketInner(SerializedPacket* packet); | |
| 718 | |
| 719 // Make sure an ack we got from our peer is sane. | 715 // Make sure an ack we got from our peer is sane. |
| 720 // Returns nullptr for valid acks or an error std::string if it was invalid. | 716 // Returns nullptr for valid acks or an error std::string if it was invalid. |
| 721 const char* ValidateAckFrame(const QuicAckFrame& incoming_ack); | 717 const char* ValidateAckFrame(const QuicAckFrame& incoming_ack); |
| 722 | 718 |
| 723 // Make sure a stop waiting we got from our peer is sane. | 719 // Make sure a stop waiting we got from our peer is sane. |
| 724 // Returns nullptr if the frame is valid or an error std::string if it was | 720 // Returns nullptr if the frame is valid or an error std::string if it was |
| 725 // invalid. | 721 // invalid. |
| 726 const char* ValidateStopWaitingFrame( | 722 const char* ValidateStopWaitingFrame( |
| 727 const QuicStopWaitingFrame& stop_waiting); | 723 const QuicStopWaitingFrame& stop_waiting); |
| 728 | 724 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 std::deque<QuicEncryptedPacket*> undecryptable_packets_; | 871 std::deque<QuicEncryptedPacket*> undecryptable_packets_; |
| 876 | 872 |
| 877 // Maximum number of undecryptable packets the connection will store. | 873 // Maximum number of undecryptable packets the connection will store. |
| 878 size_t max_undecryptable_packets_; | 874 size_t max_undecryptable_packets_; |
| 879 | 875 |
| 880 // When the version negotiation packet could not be sent because the socket | 876 // When the version negotiation packet could not be sent because the socket |
| 881 // was not writable, this is set to true. | 877 // was not writable, this is set to true. |
| 882 bool pending_version_negotiation_packet_; | 878 bool pending_version_negotiation_packet_; |
| 883 | 879 |
| 884 // When packets could not be sent because the socket was not writable, | 880 // When packets could not be sent because the socket was not writable, |
| 885 // they are added to this list. All corresponding frames are in | 881 // they are added to this std::list. All corresponding frames are in |
| 886 // unacked_packets_ if they are to be retransmitted. | 882 // unacked_packets_ if they are to be retransmitted. Packets encrypted_buffer |
| 883 // fields are owned by the QueuedPacketList, in order to ensure they outlast |
| 884 // the original scope of the SerializedPacket. |
| 887 QueuedPacketList queued_packets_; | 885 QueuedPacketList queued_packets_; |
| 888 | 886 |
| 889 // If true, then crypto packets will be saved as termination packets. | 887 // If true, then crypto packets will be saved as termination packets. |
| 890 bool save_crypto_packets_as_termination_packets_; | 888 bool save_crypto_packets_as_termination_packets_; |
| 891 | 889 |
| 892 // Contains the connection close packets if the connection has been closed. | 890 // Contains the connection close packets if the connection has been closed. |
| 893 scoped_ptr<std::vector<QuicEncryptedPacket*>> termination_packets_; | 891 scoped_ptr<std::vector<QuicEncryptedPacket*>> termination_packets_; |
| 894 | 892 |
| 895 // When true, the connection does not send a close packet on timeout. | 893 // When true, the connection does not send a close packet on idle timeout due |
| 894 // to lack of network activity. |
| 895 // This is particularly important on mobile, where connections are short. |
| 896 bool silent_close_enabled_; | 896 bool silent_close_enabled_; |
| 897 | 897 |
| 898 FecGroupMap group_map_; | 898 FecGroupMap group_map_; |
| 899 | 899 |
| 900 QuicReceivedPacketManager received_packet_manager_; | 900 QuicReceivedPacketManager received_packet_manager_; |
| 901 QuicSentEntropyManager sent_entropy_manager_; | 901 QuicSentEntropyManager sent_entropy_manager_; |
| 902 | 902 |
| 903 // Indicates whether an ack should be sent the next time we try to write. | 903 // Indicates whether an ack should be sent the next time we try to write. |
| 904 bool ack_queued_; | 904 bool ack_queued_; |
| 905 // How many retransmittable packets have arrived without sending an ack. | 905 // How many retransmittable packets have arrived without sending an ack. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 940 |
| 941 // Neither visitor is owned by this class. | 941 // Neither visitor is owned by this class. |
| 942 QuicConnectionVisitorInterface* visitor_; | 942 QuicConnectionVisitorInterface* visitor_; |
| 943 QuicConnectionDebugVisitor* debug_visitor_; | 943 QuicConnectionDebugVisitor* debug_visitor_; |
| 944 | 944 |
| 945 QuicPacketGenerator packet_generator_; | 945 QuicPacketGenerator packet_generator_; |
| 946 | 946 |
| 947 // An alarm that fires when an FEC packet should be sent. | 947 // An alarm that fires when an FEC packet should be sent. |
| 948 QuicArenaScopedPtr<QuicAlarm> fec_alarm_; | 948 QuicArenaScopedPtr<QuicAlarm> fec_alarm_; |
| 949 | 949 |
| 950 // Network idle time before we kill of this connection. | 950 // Network idle time before this connection is closed. |
| 951 QuicTime::Delta idle_network_timeout_; | 951 QuicTime::Delta idle_network_timeout_; |
| 952 // Overall connection timeout. | 952 // The connection will wait this long for the handshake to complete. |
| 953 QuicTime::Delta overall_connection_timeout_; | 953 QuicTime::Delta handshake_timeout_; |
| 954 | 954 |
| 955 // Statistics for this session. | 955 // Statistics for this session. |
| 956 QuicConnectionStats stats_; | 956 QuicConnectionStats stats_; |
| 957 | 957 |
| 958 // The time that we got a packet for this connection. | 958 // The time that we got a packet for this connection. |
| 959 // This is used for timeouts, and does not indicate the packet was processed. | 959 // This is used for timeouts, and does not indicate the packet was processed. |
| 960 QuicTime time_of_last_received_packet_; | 960 QuicTime time_of_last_received_packet_; |
| 961 | 961 |
| 962 // The last time this connection began sending a new (non-retransmitted) | 962 // The last time this connection began sending a new (non-retransmitted) |
| 963 // packet. | 963 // packet. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1038 |
| 1039 // If true, multipath is enabled for this connection. | 1039 // If true, multipath is enabled for this connection. |
| 1040 bool multipath_enabled_; | 1040 bool multipath_enabled_; |
| 1041 | 1041 |
| 1042 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1042 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 1043 }; | 1043 }; |
| 1044 | 1044 |
| 1045 } // namespace net | 1045 } // namespace net |
| 1046 | 1046 |
| 1047 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1047 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |