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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 // Constructs a new QuicConnection for |connection_id| and |address|. Invokes | 241 // Constructs a new QuicConnection for |connection_id| and |address|. Invokes |
242 // writer_factory->Create() to get a writer; |owns_writer| specifies whether | 242 // writer_factory->Create() to get a writer; |owns_writer| specifies whether |
243 // the connection takes ownership of the returned writer. |helper| must | 243 // the connection takes ownership of the returned writer. |helper| must |
244 // outlive this connection. | 244 // outlive this connection. |
245 QuicConnection(QuicConnectionId connection_id, | 245 QuicConnection(QuicConnectionId connection_id, |
246 IPEndPoint address, | 246 IPEndPoint address, |
247 QuicConnectionHelperInterface* helper, | 247 QuicConnectionHelperInterface* helper, |
248 const PacketWriterFactory& writer_factory, | 248 const PacketWriterFactory& writer_factory, |
249 bool owns_writer, | 249 bool owns_writer, |
250 bool is_server, | 250 Perspective perspective, |
251 bool is_secure, | 251 bool is_secure, |
252 const QuicVersionVector& supported_versions); | 252 const QuicVersionVector& supported_versions); |
253 ~QuicConnection() override; | 253 ~QuicConnection() override; |
254 | 254 |
255 // Sets connection parameters from the supplied |config|. | 255 // Sets connection parameters from the supplied |config|. |
256 void SetFromConfig(const QuicConfig& config); | 256 void SetFromConfig(const QuicConfig& config); |
257 | 257 |
258 // Called by the Session when the client has provided CachedNetworkParameters. | 258 // Called by the Session when the client has provided CachedNetworkParameters. |
259 // Returns true if this changes the initial connection state. | 259 // Returns true if this changes the initial connection state. |
260 virtual bool ResumeConnectionState( | 260 virtual bool ResumeConnectionState( |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 QuicConnectionId connection_id() const { return connection_id_; } | 397 QuicConnectionId connection_id() const { return connection_id_; } |
398 const QuicClock* clock() const { return clock_; } | 398 const QuicClock* clock() const { return clock_; } |
399 QuicRandom* random_generator() const { return random_generator_; } | 399 QuicRandom* random_generator() const { return random_generator_; } |
400 QuicByteCount max_packet_length() const; | 400 QuicByteCount max_packet_length() const; |
401 void set_max_packet_length(QuicByteCount length); | 401 void set_max_packet_length(QuicByteCount length); |
402 | 402 |
403 bool connected() const { return connected_; } | 403 bool connected() const { return connected_; } |
404 | 404 |
405 // Must only be called on client connections. | 405 // Must only be called on client connections. |
406 const QuicVersionVector& server_supported_versions() const { | 406 const QuicVersionVector& server_supported_versions() const { |
407 DCHECK(!is_server_); | 407 DCHECK_EQ(Perspective::IS_CLIENT, perspective_); |
408 return server_supported_versions_; | 408 return server_supported_versions_; |
409 } | 409 } |
410 | 410 |
411 size_t NumFecGroups() const { return group_map_.size(); } | 411 size_t NumFecGroups() const { return group_map_.size(); } |
412 | 412 |
413 // Testing only. | 413 // Testing only. |
414 size_t NumQueuedPackets() const { return queued_packets_.size(); } | 414 size_t NumQueuedPackets() const { return queued_packets_.size(); } |
415 | 415 |
416 QuicEncryptedPacket* ReleaseConnectionClosePacket() { | 416 QuicEncryptedPacket* ReleaseConnectionClosePacket() { |
417 return connection_close_packet_.release(); | 417 return connection_close_packet_.release(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 // that the decrypter is successful it will replace the primary decrypter. | 480 // that the decrypter is successful it will replace the primary decrypter. |
481 // Otherwise both decrypters will remain active and the primary decrypter | 481 // Otherwise both decrypters will remain active and the primary decrypter |
482 // will be the one last used. | 482 // will be the one last used. |
483 void SetAlternativeDecrypter(QuicDecrypter* decrypter, | 483 void SetAlternativeDecrypter(QuicDecrypter* decrypter, |
484 EncryptionLevel level, | 484 EncryptionLevel level, |
485 bool latch_once_used); | 485 bool latch_once_used); |
486 | 486 |
487 const QuicDecrypter* decrypter() const; | 487 const QuicDecrypter* decrypter() const; |
488 const QuicDecrypter* alternative_decrypter() const; | 488 const QuicDecrypter* alternative_decrypter() const; |
489 | 489 |
490 bool is_server() const { return is_server_; } | 490 Perspective perspective() const { return perspective_; } |
491 | 491 |
492 // Allow easy overriding of truncated connection IDs. | 492 // Allow easy overriding of truncated connection IDs. |
493 void set_can_truncate_connection_ids(bool can) { | 493 void set_can_truncate_connection_ids(bool can) { |
494 can_truncate_connection_ids_ = can; | 494 can_truncate_connection_ids_ = can; |
495 } | 495 } |
496 | 496 |
497 // Returns the underlying sent packet manager. | 497 // Returns the underlying sent packet manager. |
498 const QuicSentPacketManager& sent_packet_manager() const { | 498 const QuicSentPacketManager& sent_packet_manager() const { |
499 return sent_packet_manager_; | 499 return sent_packet_manager_; |
500 } | 500 } |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 QuicPacketSequenceNumber sequence_number_of_last_sent_packet_; | 797 QuicPacketSequenceNumber sequence_number_of_last_sent_packet_; |
798 | 798 |
799 // Sent packet manager which tracks the status of packets sent by this | 799 // Sent packet manager which tracks the status of packets sent by this |
800 // connection and contains the send and receive algorithms to determine when | 800 // connection and contains the send and receive algorithms to determine when |
801 // to send packets. | 801 // to send packets. |
802 QuicSentPacketManager sent_packet_manager_; | 802 QuicSentPacketManager sent_packet_manager_; |
803 | 803 |
804 // The state of connection in version negotiation finite state machine. | 804 // The state of connection in version negotiation finite state machine. |
805 QuicVersionNegotiationState version_negotiation_state_; | 805 QuicVersionNegotiationState version_negotiation_state_; |
806 | 806 |
807 // Tracks if the connection was created by the server. | 807 // Tracks if the connection was created by the server or the client. |
808 bool is_server_; | 808 Perspective perspective_; |
809 | 809 |
810 // True by default. False if we've received or sent an explicit connection | 810 // True by default. False if we've received or sent an explicit connection |
811 // close. | 811 // close. |
812 bool connected_; | 812 bool connected_; |
813 | 813 |
814 // Set to true if the UDP packet headers have a new IP address for the peer. | 814 // Set to true if the UDP packet headers have a new IP address for the peer. |
815 // If true, do not perform connection migration. | 815 // If true, do not perform connection migration. |
816 bool peer_ip_changed_; | 816 bool peer_ip_changed_; |
817 | 817 |
818 // Set to true if the UDP packet headers have a new port for the peer. | 818 // Set to true if the UDP packet headers have a new port for the peer. |
(...skipping 18 matching lines...) Expand all Loading... |
837 | 837 |
838 // True if this is a secure QUIC connection. | 838 // True if this is a secure QUIC connection. |
839 bool is_secure_; | 839 bool is_secure_; |
840 | 840 |
841 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 841 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
842 }; | 842 }; |
843 | 843 |
844 } // namespace net | 844 } // namespace net |
845 | 845 |
846 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 846 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |