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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 virtual bool HasPendingHandshake() const = 0; | 104 virtual bool HasPendingHandshake() const = 0; |
105 | 105 |
106 // Called to ask if any streams are open in this visitor, excluding the | 106 // Called to ask if any streams are open in this visitor, excluding the |
107 // reserved crypto and headers stream. | 107 // reserved crypto and headers stream. |
108 virtual bool HasOpenDataStreams() const = 0; | 108 virtual bool HasOpenDataStreams() const = 0; |
109 }; | 109 }; |
110 | 110 |
111 // Interface which gets callbacks from the QuicConnection at interesting | 111 // Interface which gets callbacks from the QuicConnection at interesting |
112 // points. Implementations must not mutate the state of the connection | 112 // points. Implementations must not mutate the state of the connection |
113 // as a result of these callbacks. | 113 // as a result of these callbacks. |
114 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitorInterface | 114 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitor |
115 : public QuicPacketGenerator::DebugDelegateInterface { | 115 : public QuicPacketGenerator::DebugDelegate { |
116 public: | 116 public: |
117 virtual ~QuicConnectionDebugVisitorInterface() {} | 117 virtual ~QuicConnectionDebugVisitor() {} |
118 | 118 |
119 // Called when a packet has been sent. | 119 // Called when a packet has been sent. |
120 virtual void OnPacketSent(QuicPacketSequenceNumber sequence_number, | 120 virtual void OnPacketSent(QuicPacketSequenceNumber sequence_number, |
121 EncryptionLevel level, | 121 EncryptionLevel level, |
122 TransmissionType transmission_type, | 122 TransmissionType transmission_type, |
123 const QuicEncryptedPacket& packet, | 123 const QuicEncryptedPacket& packet, |
124 WriteResult result) {} | 124 WriteResult result) {} |
125 | 125 |
126 // Called when the contents of a packet have been retransmitted as | 126 // Called when the contents of a packet have been retransmitted as |
127 // a new packet. | 127 // a new packet. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 IsHandshake handshake) OVERRIDE; | 337 IsHandshake handshake) OVERRIDE; |
338 virtual QuicAckFrame* CreateAckFrame() OVERRIDE; | 338 virtual QuicAckFrame* CreateAckFrame() OVERRIDE; |
339 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() OVERRIDE; | 339 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() OVERRIDE; |
340 virtual QuicStopWaitingFrame* CreateStopWaitingFrame() OVERRIDE; | 340 virtual QuicStopWaitingFrame* CreateStopWaitingFrame() OVERRIDE; |
341 virtual bool OnSerializedPacket(const SerializedPacket& packet) OVERRIDE; | 341 virtual bool OnSerializedPacket(const SerializedPacket& packet) OVERRIDE; |
342 | 342 |
343 // Accessors | 343 // Accessors |
344 void set_visitor(QuicConnectionVisitorInterface* visitor) { | 344 void set_visitor(QuicConnectionVisitorInterface* visitor) { |
345 visitor_ = visitor; | 345 visitor_ = visitor; |
346 } | 346 } |
347 void set_debug_visitor(QuicConnectionDebugVisitorInterface* debug_visitor) { | 347 void set_debug_visitor(QuicConnectionDebugVisitor* debug_visitor) { |
348 debug_visitor_ = debug_visitor; | 348 debug_visitor_ = debug_visitor; |
349 packet_generator_.set_debug_delegate(debug_visitor); | 349 packet_generator_.set_debug_delegate(debug_visitor); |
350 } | 350 } |
351 const IPEndPoint& self_address() const { return self_address_; } | 351 const IPEndPoint& self_address() const { return self_address_; } |
352 const IPEndPoint& peer_address() const { return peer_address_; } | 352 const IPEndPoint& peer_address() const { return peer_address_; } |
353 QuicConnectionId connection_id() const { return connection_id_; } | 353 QuicConnectionId connection_id() const { return connection_id_; } |
354 const QuicClock* clock() const { return clock_; } | 354 const QuicClock* clock() const { return clock_; } |
355 QuicRandom* random_generator() const { return random_generator_; } | 355 QuicRandom* random_generator() const { return random_generator_; } |
356 | 356 size_t max_packet_length() const { |
357 QuicPacketCreator::Options* options() { return packet_creator_.options(); } | 357 return packet_creator_.max_packet_length(); |
| 358 } |
| 359 void set_max_packet_length(size_t length) { |
| 360 return packet_creator_.set_max_packet_length(length); |
| 361 } |
358 | 362 |
359 bool connected() const { return connected_; } | 363 bool connected() const { return connected_; } |
360 | 364 |
361 // Must only be called on client connections. | 365 // Must only be called on client connections. |
362 const QuicVersionVector& server_supported_versions() const { | 366 const QuicVersionVector& server_supported_versions() const { |
363 DCHECK(!is_server_); | 367 DCHECK(!is_server_); |
364 return server_supported_versions_; | 368 return server_supported_versions_; |
365 } | 369 } |
366 | 370 |
367 size_t NumFecGroups() const { return group_map_.size(); } | 371 size_t NumFecGroups() const { return group_map_.size(); } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 const QuicDecrypter* decrypter() const; | 452 const QuicDecrypter* decrypter() const; |
449 const QuicDecrypter* alternative_decrypter() const; | 453 const QuicDecrypter* alternative_decrypter() const; |
450 | 454 |
451 bool is_server() const { return is_server_; } | 455 bool is_server() const { return is_server_; } |
452 | 456 |
453 // Returns the underlying sent packet manager. | 457 // Returns the underlying sent packet manager. |
454 const QuicSentPacketManager& sent_packet_manager() const { | 458 const QuicSentPacketManager& sent_packet_manager() const { |
455 return sent_packet_manager_; | 459 return sent_packet_manager_; |
456 } | 460 } |
457 | 461 |
458 bool CanWrite(TransmissionType transmission_type, | 462 bool CanWrite(HasRetransmittableData retransmittable); |
459 HasRetransmittableData retransmittable); | |
460 | 463 |
461 // Stores current batch state for connection, puts the connection | 464 // Stores current batch state for connection, puts the connection |
462 // into batch mode, and destruction restores the stored batch state. | 465 // into batch mode, and destruction restores the stored batch state. |
463 // While the bundler is in scope, any generated frames are bundled | 466 // While the bundler is in scope, any generated frames are bundled |
464 // as densely as possible into packets. In addition, this bundler | 467 // as densely as possible into packets. In addition, this bundler |
465 // can be configured to ensure that an ACK frame is included in the | 468 // can be configured to ensure that an ACK frame is included in the |
466 // first packet created, if there's new ack information to be sent. | 469 // first packet created, if there's new ack information to be sent. |
467 class ScopedPacketBundler { | 470 class ScopedPacketBundler { |
468 public: | 471 public: |
469 // In addition to all outgoing frames being bundled when the | 472 // In addition to all outgoing frames being bundled when the |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 scoped_ptr<QuicAlarm> send_alarm_; | 691 scoped_ptr<QuicAlarm> send_alarm_; |
689 // An alarm that is scheduled when the connection can still write and there | 692 // An alarm that is scheduled when the connection can still write and there |
690 // may be more data to send. | 693 // may be more data to send. |
691 scoped_ptr<QuicAlarm> resume_writes_alarm_; | 694 scoped_ptr<QuicAlarm> resume_writes_alarm_; |
692 // An alarm that fires when the connection may have timed out. | 695 // An alarm that fires when the connection may have timed out. |
693 scoped_ptr<QuicAlarm> timeout_alarm_; | 696 scoped_ptr<QuicAlarm> timeout_alarm_; |
694 // An alarm that fires when a ping should be sent. | 697 // An alarm that fires when a ping should be sent. |
695 scoped_ptr<QuicAlarm> ping_alarm_; | 698 scoped_ptr<QuicAlarm> ping_alarm_; |
696 | 699 |
697 QuicConnectionVisitorInterface* visitor_; | 700 QuicConnectionVisitorInterface* visitor_; |
698 QuicConnectionDebugVisitorInterface* debug_visitor_; | 701 QuicConnectionDebugVisitor* debug_visitor_; |
699 QuicPacketCreator packet_creator_; | 702 QuicPacketCreator packet_creator_; |
700 QuicPacketGenerator packet_generator_; | 703 QuicPacketGenerator packet_generator_; |
701 | 704 |
702 // Network idle time before we kill of this connection. | 705 // Network idle time before we kill of this connection. |
703 QuicTime::Delta idle_network_timeout_; | 706 QuicTime::Delta idle_network_timeout_; |
704 // Overall connection timeout. | 707 // Overall connection timeout. |
705 QuicTime::Delta overall_connection_timeout_; | 708 QuicTime::Delta overall_connection_timeout_; |
706 | 709 |
707 // Statistics for this session. | 710 // Statistics for this session. |
708 QuicConnectionStats stats_; | 711 QuicConnectionStats stats_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 // If non-empty this contains the set of versions received in a | 756 // If non-empty this contains the set of versions received in a |
754 // version negotiation packet. | 757 // version negotiation packet. |
755 QuicVersionVector server_supported_versions_; | 758 QuicVersionVector server_supported_versions_; |
756 | 759 |
757 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 760 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
758 }; | 761 }; |
759 | 762 |
760 } // namespace net | 763 } // namespace net |
761 | 764 |
762 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 765 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |