| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 virtual QuicBufferAllocator* GetBufferAllocator() = 0; | 289 virtual QuicBufferAllocator* GetBufferAllocator() = 0; |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 class NET_EXPORT_PRIVATE QuicConnection | 292 class NET_EXPORT_PRIVATE QuicConnection |
| 293 : public QuicFramerVisitorInterface, | 293 : public QuicFramerVisitorInterface, |
| 294 public QuicBlockedWriterInterface, | 294 public QuicBlockedWriterInterface, |
| 295 public QuicPacketGenerator::DelegateInterface, | 295 public QuicPacketGenerator::DelegateInterface, |
| 296 public QuicSentPacketManager::NetworkChangeVisitor { | 296 public QuicSentPacketManager::NetworkChangeVisitor { |
| 297 public: | 297 public: |
| 298 enum AckBundling { | 298 enum AckBundling { |
| 299 NO_ACK = 0, | 299 // Send an ack if it's already queued in the connection. |
| 300 SEND_ACK = 1, | 300 SEND_ACK_IF_QUEUED, |
| 301 BUNDLE_PENDING_ACK = 2, | 301 // Always send an ack. |
| 302 SEND_ACK, |
| 303 // Bundle an ack with outgoing data. |
| 304 SEND_ACK_IF_PENDING, |
| 302 }; | 305 }; |
| 303 | 306 |
| 304 enum AckMode { TCP_ACKING, ACK_DECIMATION, ACK_DECIMATION_WITH_REORDERING }; | 307 enum AckMode { TCP_ACKING, ACK_DECIMATION, ACK_DECIMATION_WITH_REORDERING }; |
| 305 | 308 |
| 306 // Constructs a new QuicConnection for |connection_id| and |address| using | 309 // Constructs a new QuicConnection for |connection_id| and |address| using |
| 307 // |writer| to write packets. |owns_writer| specifies whether the connection | 310 // |writer| to write packets. |owns_writer| specifies whether the connection |
| 308 // takes ownership of |writer|. |helper| must outlive this connection. | 311 // takes ownership of |writer|. |helper| must outlive this connection. |
| 309 QuicConnection(QuicConnectionId connection_id, | 312 QuicConnection(QuicConnectionId connection_id, |
| 310 IPEndPoint address, | 313 IPEndPoint address, |
| 311 QuicConnectionHelperInterface* helper, | 314 QuicConnectionHelperInterface* helper, |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 class NET_EXPORT_PRIVATE ScopedPacketBundler { | 609 class NET_EXPORT_PRIVATE ScopedPacketBundler { |
| 607 public: | 610 public: |
| 608 // In addition to all outgoing frames being bundled when the | 611 // In addition to all outgoing frames being bundled when the |
| 609 // bundler is in scope, setting |include_ack| to true ensures that | 612 // bundler is in scope, setting |include_ack| to true ensures that |
| 610 // an ACK frame is opportunistically bundled with the first | 613 // an ACK frame is opportunistically bundled with the first |
| 611 // outgoing packet. | 614 // outgoing packet. |
| 612 ScopedPacketBundler(QuicConnection* connection, AckBundling send_ack); | 615 ScopedPacketBundler(QuicConnection* connection, AckBundling send_ack); |
| 613 ~ScopedPacketBundler(); | 616 ~ScopedPacketBundler(); |
| 614 | 617 |
| 615 private: | 618 private: |
| 619 bool ShouldSendAck(AckBundling ack_mode) const; |
| 620 |
| 616 QuicConnection* connection_; | 621 QuicConnection* connection_; |
| 617 bool already_in_batch_mode_; | 622 bool already_in_batch_mode_; |
| 618 }; | 623 }; |
| 619 | 624 |
| 620 // Delays setting the retransmission alarm until the scope is exited. | 625 // Delays setting the retransmission alarm until the scope is exited. |
| 621 // When nested, only the outermost scheduler will set the alarm, and inner | 626 // When nested, only the outermost scheduler will set the alarm, and inner |
| 622 // ones have no effect. | 627 // ones have no effect. |
| 623 class NET_EXPORT_PRIVATE ScopedRetransmissionScheduler { | 628 class NET_EXPORT_PRIVATE ScopedRetransmissionScheduler { |
| 624 public: | 629 public: |
| 625 explicit ScopedRetransmissionScheduler(QuicConnection* connection); | 630 explicit ScopedRetransmissionScheduler(QuicConnection* connection); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 650 | 655 |
| 651 // Return the name of the cipher of the primary decrypter of the framer. | 656 // Return the name of the cipher of the primary decrypter of the framer. |
| 652 const char* cipher_name() const { return framer_.decrypter()->cipher_name(); } | 657 const char* cipher_name() const { return framer_.decrypter()->cipher_name(); } |
| 653 // Return the id of the cipher of the primary decrypter of the framer. | 658 // Return the id of the cipher of the primary decrypter of the framer. |
| 654 uint32_t cipher_id() const { return framer_.decrypter()->cipher_id(); } | 659 uint32_t cipher_id() const { return framer_.decrypter()->cipher_id(); } |
| 655 | 660 |
| 656 std::vector<QuicEncryptedPacket*>* termination_packets() { | 661 std::vector<QuicEncryptedPacket*>* termination_packets() { |
| 657 return termination_packets_.get(); | 662 return termination_packets_.get(); |
| 658 } | 663 } |
| 659 | 664 |
| 665 bool ack_queued() const { return ack_queued_; } |
| 666 |
| 660 bool ack_frame_updated() const; | 667 bool ack_frame_updated() const; |
| 661 | 668 |
| 662 QuicConnectionHelperInterface* helper() { return helper_; } | 669 QuicConnectionHelperInterface* helper() { return helper_; } |
| 663 | 670 |
| 664 base::StringPiece GetCurrentPacket(); | 671 base::StringPiece GetCurrentPacket(); |
| 665 | 672 |
| 666 protected: | 673 protected: |
| 667 // Send a packet to the peer, and takes ownership of the packet if the packet | 674 // Send a packet to the peer, and takes ownership of the packet if the packet |
| 668 // cannot be written immediately. | 675 // cannot be written immediately. |
| 669 virtual void SendOrQueuePacket(SerializedPacket* packet); | 676 virtual void SendOrQueuePacket(SerializedPacket* packet); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 IPEndPoint peer_address_; | 847 IPEndPoint peer_address_; |
| 841 | 848 |
| 842 // Used to store latest peer IP address for IP address migration. | 849 // Used to store latest peer IP address for IP address migration. |
| 843 IPAddress migrating_peer_ip_; | 850 IPAddress migrating_peer_ip_; |
| 844 // Used to store latest peer port to possibly migrate to later. | 851 // Used to store latest peer port to possibly migrate to later. |
| 845 uint16_t migrating_peer_port_; | 852 uint16_t migrating_peer_port_; |
| 846 | 853 |
| 847 // True if the last packet has gotten far enough in the framer to be | 854 // True if the last packet has gotten far enough in the framer to be |
| 848 // decrypted. | 855 // decrypted. |
| 849 bool last_packet_decrypted_; | 856 bool last_packet_decrypted_; |
| 850 QuicByteCount last_size_; // Size of the last received packet. | 857 QuicByteCount last_size_; // Size of the last received packet. |
| 851 // TODO(rch): remove this when b/27221014 is fixed. | 858 // TODO(rch): remove this when b/27221014 is fixed. |
| 852 const char* current_packet_data_; // UDP payload of packet currently being | 859 const char* current_packet_data_; // UDP payload of packet currently being |
| 853 // parsed or nullptr. | 860 // parsed or nullptr. |
| 854 EncryptionLevel last_decrypted_packet_level_; | 861 EncryptionLevel last_decrypted_packet_level_; |
| 855 QuicPacketHeader last_header_; | 862 QuicPacketHeader last_header_; |
| 856 QuicStopWaitingFrame last_stop_waiting_frame_; | 863 QuicStopWaitingFrame last_stop_waiting_frame_; |
| 857 bool should_last_packet_instigate_acks_; | 864 bool should_last_packet_instigate_acks_; |
| 858 | 865 |
| 859 // Track some peer state so we can do less bookkeeping | 866 // Track some peer state so we can do less bookkeeping |
| 860 // Largest sequence sent by the peer which had an ack frame (latest ack info). | 867 // Largest sequence sent by the peer which had an ack frame (latest ack info). |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1045 |
| 1039 // If true, multipath is enabled for this connection. | 1046 // If true, multipath is enabled for this connection. |
| 1040 bool multipath_enabled_; | 1047 bool multipath_enabled_; |
| 1041 | 1048 |
| 1042 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1049 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 1043 }; | 1050 }; |
| 1044 | 1051 |
| 1045 } // namespace net | 1052 } // namespace net |
| 1046 | 1053 |
| 1047 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1054 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |