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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // writes to happen. | 407 // writes to happen. |
408 void OnCanWrite() override; | 408 void OnCanWrite() override; |
409 | 409 |
410 // Called when an error occurs while attempting to write a packet to the | 410 // Called when an error occurs while attempting to write a packet to the |
411 // network. | 411 // network. |
412 void OnWriteError(int error_code); | 412 void OnWriteError(int error_code); |
413 | 413 |
414 // If the socket is not blocked, writes queued packets. | 414 // If the socket is not blocked, writes queued packets. |
415 void WriteIfNotBlocked(); | 415 void WriteIfNotBlocked(); |
416 | 416 |
| 417 // If the socket is not blocked, writes queued packets and bundles any pending |
| 418 // ACKs. |
| 419 void WriteAndBundleAcksIfNotBlocked(); |
| 420 |
417 // Set the packet writer. | 421 // Set the packet writer. |
418 void SetQuicPacketWriter(QuicPacketWriter* writer, bool owns_writer) { | 422 void SetQuicPacketWriter(QuicPacketWriter* writer, bool owns_writer) { |
419 DCHECK(writer != nullptr); | 423 DCHECK(writer != nullptr); |
420 if (writer_ != nullptr && owns_writer_) { | 424 if (writer_ != nullptr && owns_writer_) { |
421 delete writer_; | 425 delete writer_; |
422 } | 426 } |
423 writer_ = writer; | 427 writer_ = writer; |
424 owns_writer_ = owns_writer; | 428 owns_writer_ = owns_writer; |
425 } | 429 } |
426 | 430 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 710 |
707 // Returns the current per-packet options for the connection. | 711 // Returns the current per-packet options for the connection. |
708 PerPacketOptions* per_packet_options() { return per_packet_options_; } | 712 PerPacketOptions* per_packet_options() { return per_packet_options_; } |
709 // Sets the current per-packet options for the connection. The QuicConnection | 713 // Sets the current per-packet options for the connection. The QuicConnection |
710 // does not take ownership of |options|; |options| must live for as long as | 714 // does not take ownership of |options|; |options| must live for as long as |
711 // the QuicConnection is in use. | 715 // the QuicConnection is in use. |
712 void set_per_packet_options(PerPacketOptions* options) { | 716 void set_per_packet_options(PerPacketOptions* options) { |
713 per_packet_options_ = options; | 717 per_packet_options_ = options; |
714 } | 718 } |
715 | 719 |
| 720 // If |defer| is true, configures the connection to defer sending packets in |
| 721 // response to an ACK to the SendAlarm. If |defer| is false, packets may be |
| 722 // sent immediately after receiving an ACK. |
| 723 void set_defer_send_in_response_to_packets(bool defer) { |
| 724 defer_send_in_response_to_packets_ = defer; |
| 725 } |
| 726 |
716 private: | 727 private: |
717 friend class test::QuicConnectionPeer; | 728 friend class test::QuicConnectionPeer; |
718 friend class test::PacketSavingConnection; | 729 friend class test::PacketSavingConnection; |
719 | 730 |
720 typedef std::list<SerializedPacket> QueuedPacketList; | 731 typedef std::list<SerializedPacket> QueuedPacketList; |
721 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; | 732 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; |
722 | 733 |
723 // Writes the given packet to socket, encrypted with packet's | 734 // Writes the given packet to socket, encrypted with packet's |
724 // encryption_level. Returns true on successful write, and false if the writer | 735 // encryption_level. Returns true on successful write, and false if the writer |
725 // was blocked and the write needs to be tried again. Notifies the | 736 // was blocked and the write needs to be tried again. Notifies the |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 int stop_waiting_count_; | 941 int stop_waiting_count_; |
931 // Indicates the current ack mode, defaults to acking every 2 packets. | 942 // Indicates the current ack mode, defaults to acking every 2 packets. |
932 AckMode ack_mode_; | 943 AckMode ack_mode_; |
933 | 944 |
934 // Indicates the retransmit alarm is going to be set by the | 945 // Indicates the retransmit alarm is going to be set by the |
935 // ScopedRetransmitAlarmDelayer | 946 // ScopedRetransmitAlarmDelayer |
936 bool delay_setting_retransmission_alarm_; | 947 bool delay_setting_retransmission_alarm_; |
937 // Indicates the retransmission alarm needs to be set. | 948 // Indicates the retransmission alarm needs to be set. |
938 bool pending_retransmission_alarm_; | 949 bool pending_retransmission_alarm_; |
939 | 950 |
| 951 // If true, defer sending data in response to received packets to the |
| 952 // SendAlarm. |
| 953 bool defer_send_in_response_to_packets_; |
| 954 |
940 // Arena to store class implementations within the QuicConnection. | 955 // Arena to store class implementations within the QuicConnection. |
941 QuicConnectionArena arena_; | 956 QuicConnectionArena arena_; |
942 | 957 |
943 // An alarm that fires when an ACK should be sent to the peer. | 958 // An alarm that fires when an ACK should be sent to the peer. |
944 QuicArenaScopedPtr<QuicAlarm> ack_alarm_; | 959 QuicArenaScopedPtr<QuicAlarm> ack_alarm_; |
945 // An alarm that fires when a packet needs to be retransmitted. | 960 // An alarm that fires when a packet needs to be retransmitted. |
946 QuicArenaScopedPtr<QuicAlarm> retransmission_alarm_; | 961 QuicArenaScopedPtr<QuicAlarm> retransmission_alarm_; |
947 // An alarm that is scheduled when the SentPacketManager requires a delay | 962 // An alarm that is scheduled when the SentPacketManager requires a delay |
948 // before sending packets and fires when the packet may be sent. | 963 // before sending packets and fires when the packet may be sent. |
949 QuicArenaScopedPtr<QuicAlarm> send_alarm_; | 964 QuicArenaScopedPtr<QuicAlarm> send_alarm_; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1072 |
1058 // If true, multipath is enabled for this connection. | 1073 // If true, multipath is enabled for this connection. |
1059 bool multipath_enabled_; | 1074 bool multipath_enabled_; |
1060 | 1075 |
1061 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1076 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
1062 }; | 1077 }; |
1063 | 1078 |
1064 } // namespace net | 1079 } // namespace net |
1065 | 1080 |
1066 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1081 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |