| 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 16 matching lines...) Expand all Loading... |
| 27 #include <string> | 27 #include <string> |
| 28 #include <vector> | 28 #include <vector> |
| 29 | 29 |
| 30 #include "base/logging.h" | 30 #include "base/logging.h" |
| 31 #include "base/macros.h" | 31 #include "base/macros.h" |
| 32 #include "base/strings/string_piece.h" | 32 #include "base/strings/string_piece.h" |
| 33 #include "net/base/ip_address.h" | 33 #include "net/base/ip_address.h" |
| 34 #include "net/base/ip_endpoint.h" | 34 #include "net/base/ip_endpoint.h" |
| 35 #include "net/quic/crypto/quic_decrypter.h" | 35 #include "net/quic/crypto/quic_decrypter.h" |
| 36 #include "net/quic/quic_alarm.h" | 36 #include "net/quic/quic_alarm.h" |
| 37 #include "net/quic/quic_alarm_factory.h" |
| 37 #include "net/quic/quic_blocked_writer_interface.h" | 38 #include "net/quic/quic_blocked_writer_interface.h" |
| 38 #include "net/quic/quic_fec_group.h" | 39 #include "net/quic/quic_fec_group.h" |
| 39 #include "net/quic/quic_framer.h" | 40 #include "net/quic/quic_framer.h" |
| 40 #include "net/quic/quic_one_block_arena.h" | 41 #include "net/quic/quic_one_block_arena.h" |
| 41 #include "net/quic/quic_packet_creator.h" | 42 #include "net/quic/quic_packet_creator.h" |
| 42 #include "net/quic/quic_packet_generator.h" | 43 #include "net/quic/quic_packet_generator.h" |
| 43 #include "net/quic/quic_packet_writer.h" | 44 #include "net/quic/quic_packet_writer.h" |
| 44 #include "net/quic/quic_protocol.h" | 45 #include "net/quic/quic_protocol.h" |
| 45 #include "net/quic/quic_received_packet_manager.h" | 46 #include "net/quic/quic_received_packet_manager.h" |
| 46 #include "net/quic/quic_sent_entropy_manager.h" | 47 #include "net/quic/quic_sent_entropy_manager.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 class NET_EXPORT_PRIVATE QuicConnectionHelperInterface { | 267 class NET_EXPORT_PRIVATE QuicConnectionHelperInterface { |
| 267 public: | 268 public: |
| 268 virtual ~QuicConnectionHelperInterface() {} | 269 virtual ~QuicConnectionHelperInterface() {} |
| 269 | 270 |
| 270 // Returns a QuicClock to be used for all time related functions. | 271 // Returns a QuicClock to be used for all time related functions. |
| 271 virtual const QuicClock* GetClock() const = 0; | 272 virtual const QuicClock* GetClock() const = 0; |
| 272 | 273 |
| 273 // Returns a QuicRandom to be used for all random number related functions. | 274 // Returns a QuicRandom to be used for all random number related functions. |
| 274 virtual QuicRandom* GetRandomGenerator() = 0; | 275 virtual QuicRandom* GetRandomGenerator() = 0; |
| 275 | 276 |
| 276 // Creates a new platform-specific alarm which will be configured to notify | |
| 277 // |delegate| when the alarm fires. Returns an alarm allocated on the heap. | |
| 278 // Caller takes ownership of the new alarm, which will not yet be "set" to | |
| 279 // fire. | |
| 280 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) = 0; | |
| 281 | |
| 282 // Creates a new platform-specific alarm which will be configured to notify | |
| 283 // |delegate| when the alarm fires. Caller takes ownership of the new alarm, | |
| 284 // which will not yet be "set" to fire. If |arena| is null, then the alarm | |
| 285 // will be created on the heap. Otherwise, it will be created in |arena|. | |
| 286 virtual QuicArenaScopedPtr<QuicAlarm> CreateAlarm( | |
| 287 QuicArenaScopedPtr<QuicAlarm::Delegate> delegate, | |
| 288 QuicConnectionArena* arena) = 0; | |
| 289 | |
| 290 // Returns a QuicBufferAllocator to be used for all stream frame buffers. | 277 // Returns a QuicBufferAllocator to be used for all stream frame buffers. |
| 291 virtual QuicBufferAllocator* GetBufferAllocator() = 0; | 278 virtual QuicBufferAllocator* GetBufferAllocator() = 0; |
| 292 }; | 279 }; |
| 293 | 280 |
| 294 class NET_EXPORT_PRIVATE QuicConnection | 281 class NET_EXPORT_PRIVATE QuicConnection |
| 295 : public QuicFramerVisitorInterface, | 282 : public QuicFramerVisitorInterface, |
| 296 public QuicBlockedWriterInterface, | 283 public QuicBlockedWriterInterface, |
| 297 public QuicPacketGenerator::DelegateInterface, | 284 public QuicPacketGenerator::DelegateInterface, |
| 298 public QuicSentPacketManager::NetworkChangeVisitor { | 285 public QuicSentPacketManager::NetworkChangeVisitor { |
| 299 public: | 286 public: |
| 300 enum AckBundling { | 287 enum AckBundling { |
| 301 // Send an ack if it's already queued in the connection. | 288 // Send an ack if it's already queued in the connection. |
| 302 SEND_ACK_IF_QUEUED, | 289 SEND_ACK_IF_QUEUED, |
| 303 // Always send an ack. | 290 // Always send an ack. |
| 304 SEND_ACK, | 291 SEND_ACK, |
| 305 // Bundle an ack with outgoing data. | 292 // Bundle an ack with outgoing data. |
| 306 SEND_ACK_IF_PENDING, | 293 SEND_ACK_IF_PENDING, |
| 307 }; | 294 }; |
| 308 | 295 |
| 309 enum AckMode { TCP_ACKING, ACK_DECIMATION, ACK_DECIMATION_WITH_REORDERING }; | 296 enum AckMode { TCP_ACKING, ACK_DECIMATION, ACK_DECIMATION_WITH_REORDERING }; |
| 310 | 297 |
| 311 // Constructs a new QuicConnection for |connection_id| and |address| using | 298 // Constructs a new QuicConnection for |connection_id| and |address| using |
| 312 // |writer| to write packets. |owns_writer| specifies whether the connection | 299 // |writer| to write packets. |owns_writer| specifies whether the connection |
| 313 // takes ownership of |writer|. |helper| must outlive this connection. | 300 // takes ownership of |writer|. |helper| must outlive this connection. |
| 314 QuicConnection(QuicConnectionId connection_id, | 301 QuicConnection(QuicConnectionId connection_id, |
| 315 IPEndPoint address, | 302 IPEndPoint address, |
| 316 QuicConnectionHelperInterface* helper, | 303 QuicConnectionHelperInterface* helper, |
| 304 QuicAlarmFactory* alarm_factory, |
| 317 QuicPacketWriter* writer, | 305 QuicPacketWriter* writer, |
| 318 bool owns_writer, | 306 bool owns_writer, |
| 319 Perspective perspective, | 307 Perspective perspective, |
| 320 const QuicVersionVector& supported_versions); | 308 const QuicVersionVector& supported_versions); |
| 321 ~QuicConnection() override; | 309 ~QuicConnection() override; |
| 322 | 310 |
| 323 // Sets connection parameters from the supplied |config|. | 311 // Sets connection parameters from the supplied |config|. |
| 324 void SetFromConfig(const QuicConfig& config); | 312 void SetFromConfig(const QuicConfig& config); |
| 325 | 313 |
| 326 // Called by the session when sending connection state to the client. | 314 // Called by the session when sending connection state to the client. |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 646 |
| 659 std::vector<QuicEncryptedPacket*>* termination_packets() { | 647 std::vector<QuicEncryptedPacket*>* termination_packets() { |
| 660 return termination_packets_.get(); | 648 return termination_packets_.get(); |
| 661 } | 649 } |
| 662 | 650 |
| 663 bool ack_queued() const { return ack_queued_; } | 651 bool ack_queued() const { return ack_queued_; } |
| 664 | 652 |
| 665 bool ack_frame_updated() const; | 653 bool ack_frame_updated() const; |
| 666 | 654 |
| 667 QuicConnectionHelperInterface* helper() { return helper_; } | 655 QuicConnectionHelperInterface* helper() { return helper_; } |
| 656 QuicAlarmFactory* alarm_factory() { return alarm_factory_; } |
| 668 | 657 |
| 669 base::StringPiece GetCurrentPacket(); | 658 base::StringPiece GetCurrentPacket(); |
| 670 | 659 |
| 671 const QuicPacketGenerator& packet_generator() const { | 660 const QuicPacketGenerator& packet_generator() const { |
| 672 return packet_generator_; | 661 return packet_generator_; |
| 673 } | 662 } |
| 674 | 663 |
| 675 EncryptionLevel encryption_level() const { return encryption_level_; } | 664 EncryptionLevel encryption_level() const { return encryption_level_; } |
| 676 | 665 |
| 677 protected: | 666 protected: |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 // QuicMultipathReceivedPacketManager are landed in QuicConnection. | 821 // QuicMultipathReceivedPacketManager are landed in QuicConnection. |
| 833 void OnPathClosed(QuicPathId path_id); | 822 void OnPathClosed(QuicPathId path_id); |
| 834 | 823 |
| 835 // Do any work which logically would be done in OnPacket but can not be | 824 // Do any work which logically would be done in OnPacket but can not be |
| 836 // safely done until the packet is validated. Returns true if packet can be | 825 // safely done until the packet is validated. Returns true if packet can be |
| 837 // handled, false otherwise. | 826 // handled, false otherwise. |
| 838 bool ProcessValidatedPacket(const QuicPacketHeader& header); | 827 bool ProcessValidatedPacket(const QuicPacketHeader& header); |
| 839 | 828 |
| 840 QuicFramer framer_; | 829 QuicFramer framer_; |
| 841 QuicConnectionHelperInterface* helper_; // Not owned. | 830 QuicConnectionHelperInterface* helper_; // Not owned. |
| 831 QuicAlarmFactory* alarm_factory_; // Not owned. |
| 842 PerPacketOptions* per_packet_options_; // Not owned. | 832 PerPacketOptions* per_packet_options_; // Not owned. |
| 843 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. | 833 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. |
| 844 bool owns_writer_; | 834 bool owns_writer_; |
| 845 // Encryption level for new packets. Should only be changed via | 835 // Encryption level for new packets. Should only be changed via |
| 846 // SetDefaultEncryptionLevel(). | 836 // SetDefaultEncryptionLevel(). |
| 847 EncryptionLevel encryption_level_; | 837 EncryptionLevel encryption_level_; |
| 848 bool has_forward_secure_encrypter_; | 838 bool has_forward_secure_encrypter_; |
| 849 // The packet number of the first packet which will be encrypted with the | 839 // The packet number of the first packet which will be encrypted with the |
| 850 // foward-secure encrypter, even if the peer has not started sending | 840 // foward-secure encrypter, even if the peer has not started sending |
| 851 // forward-secure packets. | 841 // forward-secure packets. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 | 1041 |
| 1052 // If true, multipath is enabled for this connection. | 1042 // If true, multipath is enabled for this connection. |
| 1053 bool multipath_enabled_; | 1043 bool multipath_enabled_; |
| 1054 | 1044 |
| 1055 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1045 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 1056 }; | 1046 }; |
| 1057 | 1047 |
| 1058 } // namespace net | 1048 } // namespace net |
| 1059 | 1049 |
| 1060 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1050 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |