Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: net/quic/quic_connection.h

Issue 2002083002: Add QuicSentPacketManagerInterface, and QuicSentPacketManager implements it. No functional change e… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_chromium_client_session.cc ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 #include "net/quic/quic_blocked_writer_interface.h" 38 #include "net/quic/quic_blocked_writer_interface.h"
39 #include "net/quic/quic_fec_group.h" 39 #include "net/quic/quic_fec_group.h"
40 #include "net/quic/quic_framer.h" 40 #include "net/quic/quic_framer.h"
41 #include "net/quic/quic_one_block_arena.h" 41 #include "net/quic/quic_one_block_arena.h"
42 #include "net/quic/quic_packet_creator.h" 42 #include "net/quic/quic_packet_creator.h"
43 #include "net/quic/quic_packet_generator.h" 43 #include "net/quic/quic_packet_generator.h"
44 #include "net/quic/quic_packet_writer.h" 44 #include "net/quic/quic_packet_writer.h"
45 #include "net/quic/quic_protocol.h" 45 #include "net/quic/quic_protocol.h"
46 #include "net/quic/quic_received_packet_manager.h" 46 #include "net/quic/quic_received_packet_manager.h"
47 #include "net/quic/quic_sent_entropy_manager.h" 47 #include "net/quic/quic_sent_entropy_manager.h"
48 #include "net/quic/quic_sent_packet_manager.h" 48 #include "net/quic/quic_sent_packet_manager_interface.h"
49 #include "net/quic/quic_time.h" 49 #include "net/quic/quic_time.h"
50 #include "net/quic/quic_types.h" 50 #include "net/quic/quic_types.h"
51 51
52 namespace net { 52 namespace net {
53 53
54 class QuicClock; 54 class QuicClock;
55 class QuicConfig; 55 class QuicConfig;
56 class QuicConnection; 56 class QuicConnection;
57 class QuicEncrypter; 57 class QuicEncrypter;
58 class QuicRandom; 58 class QuicRandom;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 // Called to ask if any streams are open in this visitor, excluding the 156 // Called to ask if any streams are open in this visitor, excluding the
157 // reserved crypto and headers stream. 157 // reserved crypto and headers stream.
158 virtual bool HasOpenDynamicStreams() const = 0; 158 virtual bool HasOpenDynamicStreams() const = 0;
159 }; 159 };
160 160
161 // Interface which gets callbacks from the QuicConnection at interesting 161 // Interface which gets callbacks from the QuicConnection at interesting
162 // points. Implementations must not mutate the state of the connection 162 // points. Implementations must not mutate the state of the connection
163 // as a result of these callbacks. 163 // as a result of these callbacks.
164 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitor 164 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitor
165 : public QuicSentPacketManager::DebugDelegate { 165 : public QuicSentPacketManagerInterface::DebugDelegate {
166 public: 166 public:
167 ~QuicConnectionDebugVisitor() override {} 167 ~QuicConnectionDebugVisitor() override {}
168 168
169 // Called when a packet has been sent. 169 // Called when a packet has been sent.
170 virtual void OnPacketSent(const SerializedPacket& serialized_packet, 170 virtual void OnPacketSent(const SerializedPacket& serialized_packet,
171 QuicPathId original_path_id, 171 QuicPathId original_path_id,
172 QuicPacketNumber original_packet_number, 172 QuicPacketNumber original_packet_number,
173 TransmissionType transmission_type, 173 TransmissionType transmission_type,
174 QuicTime sent_time) {} 174 QuicTime sent_time) {}
175 175
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // case this is when the SHLO has been ACKed. Clients call this on receipt of 468 // case this is when the SHLO has been ACKed. Clients call this on receipt of
469 // the SHLO. 469 // the SHLO.
470 void OnHandshakeComplete(); 470 void OnHandshakeComplete();
471 471
472 // Accessors 472 // Accessors
473 void set_visitor(QuicConnectionVisitorInterface* visitor) { 473 void set_visitor(QuicConnectionVisitorInterface* visitor) {
474 visitor_ = visitor; 474 visitor_ = visitor;
475 } 475 }
476 void set_debug_visitor(QuicConnectionDebugVisitor* debug_visitor) { 476 void set_debug_visitor(QuicConnectionDebugVisitor* debug_visitor) {
477 debug_visitor_ = debug_visitor; 477 debug_visitor_ = debug_visitor;
478 sent_packet_manager_.set_debug_delegate(debug_visitor); 478 sent_packet_manager_->SetDebugDelegate(debug_visitor);
479 } 479 }
480 // Used in Chromium, but not internally. 480 // Used in Chromium, but not internally.
481 void set_creator_debug_delegate(QuicPacketCreator::DebugDelegate* visitor) { 481 void set_creator_debug_delegate(QuicPacketCreator::DebugDelegate* visitor) {
482 packet_generator_.set_debug_delegate(visitor); 482 packet_generator_.set_debug_delegate(visitor);
483 } 483 }
484 const IPEndPoint& self_address() const { return self_address_; } 484 const IPEndPoint& self_address() const { return self_address_; }
485 const IPEndPoint& peer_address() const { return peer_address_; } 485 const IPEndPoint& peer_address() const { return peer_address_; }
486 QuicConnectionId connection_id() const { return connection_id_; } 486 QuicConnectionId connection_id() const { return connection_id_; }
487 const QuicClock* clock() const { return clock_; } 487 const QuicClock* clock() const { return clock_; }
488 QuicRandom* random_generator() const { return random_generator_; } 488 QuicRandom* random_generator() const { return random_generator_; }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 const QuicDecrypter* alternative_decrypter() const; 585 const QuicDecrypter* alternative_decrypter() const;
586 586
587 Perspective perspective() const { return perspective_; } 587 Perspective perspective() const { return perspective_; }
588 588
589 // Allow easy overriding of truncated connection IDs. 589 // Allow easy overriding of truncated connection IDs.
590 void set_can_truncate_connection_ids(bool can) { 590 void set_can_truncate_connection_ids(bool can) {
591 can_truncate_connection_ids_ = can; 591 can_truncate_connection_ids_ = can;
592 } 592 }
593 593
594 // Returns the underlying sent packet manager. 594 // Returns the underlying sent packet manager.
595 const QuicSentPacketManager& sent_packet_manager() const { 595 const QuicSentPacketManagerInterface& sent_packet_manager() const {
596 return sent_packet_manager_; 596 return *sent_packet_manager_;
597 } 597 }
598 598
599 bool CanWrite(HasRetransmittableData retransmittable); 599 bool CanWrite(HasRetransmittableData retransmittable);
600 600
601 // Stores current batch state for connection, puts the connection 601 // Stores current batch state for connection, puts the connection
602 // into batch mode, and destruction restores the stored batch state. 602 // into batch mode, and destruction restores the stored batch state.
603 // While the bundler is in scope, any generated frames are bundled 603 // While the bundler is in scope, any generated frames are bundled
604 // as densely as possible into packets. In addition, this bundler 604 // as densely as possible into packets. In addition, this bundler
605 // can be configured to ensure that an ACK frame is included in the 605 // can be configured to ensure that an ACK frame is included in the
606 // first packet created, if there's new ack information to be sent. 606 // first packet created, if there's new ack information to be sent.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 677
678 const IPEndPoint& last_packet_source_address() const { 678 const IPEndPoint& last_packet_source_address() const {
679 return last_packet_source_address_; 679 return last_packet_source_address_;
680 } 680 }
681 681
682 protected: 682 protected:
683 // Send a packet to the peer, and takes ownership of the packet if the packet 683 // Send a packet to the peer, and takes ownership of the packet if the packet
684 // cannot be written immediately. 684 // cannot be written immediately.
685 virtual void SendOrQueuePacket(SerializedPacket* packet); 685 virtual void SendOrQueuePacket(SerializedPacket* packet);
686 686
687 // Called after a packet is received from a new peer address and is 687 // Called after a packet is received from a new peer address on existing
688 // decrypted. Starts validation of peer's address change. 688 // |path_id| and is decrypted. Starts validation of peer's address change.
689 virtual void StartPeerMigration(PeerAddressChangeType peer_migration_type); 689 virtual void StartPeerMigration(QuicPathId path_id,
690 PeerAddressChangeType peer_migration_type);
690 691
691 // Called when a peer migration is validated. 692 // Called when a peer address migration is validated on |path_id|.
692 virtual void OnPeerMigrationValidated(); 693 virtual void OnPeerMigrationValidated(QuicPathId path_id);
693 694
694 // Selects and updates the version of the protocol being used by selecting a 695 // Selects and updates the version of the protocol being used by selecting a
695 // version from |available_versions| which is also supported. Returns true if 696 // version from |available_versions| which is also supported. Returns true if
696 // such a version exists, false otherwise. 697 // such a version exists, false otherwise.
697 bool SelectMutualVersion(const QuicVersionVector& available_versions); 698 bool SelectMutualVersion(const QuicVersionVector& available_versions);
698 699
699 // Returns the current per-packet options for the connection. 700 // Returns the current per-packet options for the connection.
700 PerPacketOptions* per_packet_options() { return per_packet_options_; } 701 PerPacketOptions* per_packet_options() { return per_packet_options_; }
701 // Sets the current per-packet options for the connection. The QuicConnection 702 // Sets the current per-packet options for the connection. The QuicConnection
702 // does not take ownership of |options|; |options| must live for as long as 703 // does not take ownership of |options|; |options| must live for as long as
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 void ProcessStopWaitingFrame(const QuicStopWaitingFrame& stop_waiting); 787 void ProcessStopWaitingFrame(const QuicStopWaitingFrame& stop_waiting);
787 788
788 // Sends any packets which are a response to the last packet, including both 789 // Sends any packets which are a response to the last packet, including both
789 // acks and pending writes if an ack opened the congestion window. 790 // acks and pending writes if an ack opened the congestion window.
790 void MaybeSendInResponseToPacket(); 791 void MaybeSendInResponseToPacket();
791 792
792 // Queue an ack or set the ack alarm if needed. |was_missing| is true if 793 // Queue an ack or set the ack alarm if needed. |was_missing| is true if
793 // the most recently received packet was formerly missing. 794 // the most recently received packet was formerly missing.
794 void MaybeQueueAck(bool was_missing); 795 void MaybeQueueAck(bool was_missing);
795 796
796 // Gets the least unacked packet number, which is the next packet number 797 // Gets the least unacked packet number of |path_id|, which is the next packet
797 // to be sent if there are no outstanding packets. 798 // number to be sent if there are no outstanding packets.
798 QuicPacketNumber GetLeastUnacked() const; 799 QuicPacketNumber GetLeastUnacked(QuicPathId path_id) const;
799 800
800 // Sets the timeout alarm to the appropriate value, if any. 801 // Sets the timeout alarm to the appropriate value, if any.
801 void SetTimeoutAlarm(); 802 void SetTimeoutAlarm();
802 803
803 // Sets the ping alarm to the appropriate value, if any. 804 // Sets the ping alarm to the appropriate value, if any.
804 void SetPingAlarm(); 805 void SetPingAlarm();
805 806
806 // Sets the retransmission alarm based on SentPacketManager. 807 // Sets the retransmission alarm based on SentPacketManager.
807 void SetRetransmissionAlarm(); 808 void SetRetransmissionAlarm();
808 809
(...skipping 25 matching lines...) Expand all
834 void OnPathClosed(QuicPathId path_id); 835 void OnPathClosed(QuicPathId path_id);
835 836
836 // Do any work which logically would be done in OnPacket but can not be 837 // Do any work which logically would be done in OnPacket but can not be
837 // safely done until the packet is validated. Returns true if packet can be 838 // safely done until the packet is validated. Returns true if packet can be
838 // handled, false otherwise. 839 // handled, false otherwise.
839 bool ProcessValidatedPacket(const QuicPacketHeader& header); 840 bool ProcessValidatedPacket(const QuicPacketHeader& header);
840 841
841 // Consider receiving crypto frame on non crypto stream as memory corruption. 842 // Consider receiving crypto frame on non crypto stream as memory corruption.
842 bool MaybeConsiderAsMemoryCorruption(const QuicStreamFrame& frame); 843 bool MaybeConsiderAsMemoryCorruption(const QuicStreamFrame& frame);
843 844
845 const QuicTime::Delta DelayedAckTime();
846
844 QuicFramer framer_; 847 QuicFramer framer_;
845 QuicConnectionHelperInterface* helper_; // Not owned. 848 QuicConnectionHelperInterface* helper_; // Not owned.
846 QuicAlarmFactory* alarm_factory_; // Not owned. 849 QuicAlarmFactory* alarm_factory_; // Not owned.
847 PerPacketOptions* per_packet_options_; // Not owned. 850 PerPacketOptions* per_packet_options_; // Not owned.
848 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. 851 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|.
849 bool owns_writer_; 852 bool owns_writer_;
850 // Encryption level for new packets. Should only be changed via 853 // Encryption level for new packets. Should only be changed via
851 // SetDefaultEncryptionLevel(). 854 // SetDefaultEncryptionLevel().
852 EncryptionLevel encryption_level_; 855 EncryptionLevel encryption_level_;
853 bool has_forward_secure_encrypter_; 856 bool has_forward_secure_encrypter_;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 // |time_of_last_received_packet_|. 1007 // |time_of_last_received_packet_|.
1005 QuicTime last_send_for_timeout_; 1008 QuicTime last_send_for_timeout_;
1006 1009
1007 // packet number of the last sent packet. Packets are guaranteed to be sent 1010 // packet number of the last sent packet. Packets are guaranteed to be sent
1008 // in packet number order. 1011 // in packet number order.
1009 QuicPacketNumber packet_number_of_last_sent_packet_; 1012 QuicPacketNumber packet_number_of_last_sent_packet_;
1010 1013
1011 // Sent packet manager which tracks the status of packets sent by this 1014 // Sent packet manager which tracks the status of packets sent by this
1012 // connection and contains the send and receive algorithms to determine when 1015 // connection and contains the send and receive algorithms to determine when
1013 // to send packets. 1016 // to send packets.
1014 QuicSentPacketManager sent_packet_manager_; 1017 std::unique_ptr<QuicSentPacketManagerInterface> sent_packet_manager_;
1015 1018
1016 // The state of connection in version negotiation finite state machine. 1019 // The state of connection in version negotiation finite state machine.
1017 QuicVersionNegotiationState version_negotiation_state_; 1020 QuicVersionNegotiationState version_negotiation_state_;
1018 1021
1019 // Tracks if the connection was created by the server or the client. 1022 // Tracks if the connection was created by the server or the client.
1020 Perspective perspective_; 1023 Perspective perspective_;
1021 1024
1022 // True by default. False if we've received or sent an explicit connection 1025 // True by default. False if we've received or sent an explicit connection
1023 // close. 1026 // close.
1024 bool connected_; 1027 bool connected_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1064
1062 // If true, multipath is enabled for this connection. 1065 // If true, multipath is enabled for this connection.
1063 bool multipath_enabled_; 1066 bool multipath_enabled_;
1064 1067
1065 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 1068 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
1066 }; 1069 };
1067 1070
1068 } // namespace net 1071 } // namespace net
1069 1072
1070 #endif // NET_QUIC_QUIC_CONNECTION_H_ 1073 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW
« no previous file with comments | « net/quic/quic_chromium_client_session.cc ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698