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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 #include "net/quic/quic_sent_packet_manager.h" | 42 #include "net/quic/quic_sent_packet_manager.h" |
43 | 43 |
44 namespace net { | 44 namespace net { |
45 | 45 |
46 class QuicClock; | 46 class QuicClock; |
47 class QuicConfig; | 47 class QuicConfig; |
48 class QuicConnection; | 48 class QuicConnection; |
49 class QuicDecrypter; | 49 class QuicDecrypter; |
50 class QuicEncrypter; | 50 class QuicEncrypter; |
51 class QuicFecGroup; | 51 class QuicFecGroup; |
52 class QuicFlowController; | |
53 class QuicRandom; | 52 class QuicRandom; |
54 | 53 |
55 namespace test { | 54 namespace test { |
56 class QuicConnectionPeer; | 55 class QuicConnectionPeer; |
57 } // namespace test | 56 } // namespace test |
58 | 57 |
59 // Class that receives callbacks from the connection when frames are received | 58 // Class that receives callbacks from the connection when frames are received |
60 // and when other interesting events happen. | 59 // and when other interesting events happen. |
61 class NET_EXPORT_PRIVATE QuicConnectionVisitorInterface { | 60 class NET_EXPORT_PRIVATE QuicConnectionVisitorInterface { |
62 public: | 61 public: |
(...skipping 24 matching lines...) Expand all Loading... | |
87 | 86 |
88 // Called when the connection failed to write because the socket was blocked. | 87 // Called when the connection failed to write because the socket was blocked. |
89 virtual void OnWriteBlocked() = 0; | 88 virtual void OnWriteBlocked() = 0; |
90 | 89 |
91 // Called once a specific QUIC version is agreed by both endpoints. | 90 // Called once a specific QUIC version is agreed by both endpoints. |
92 virtual void OnSuccessfulVersionNegotiation(const QuicVersion& version) = 0; | 91 virtual void OnSuccessfulVersionNegotiation(const QuicVersion& version) = 0; |
93 | 92 |
94 // Called when a blocked socket becomes writable. | 93 // Called when a blocked socket becomes writable. |
95 virtual void OnCanWrite() = 0; | 94 virtual void OnCanWrite() = 0; |
96 | 95 |
97 // Called to ask if any writes are pending in this visitor. Writes may be | 96 // Called to ask if the visitor wants to schedule write resumption as it has |
98 // pending because they were write-blocked, congestion-throttled or | 97 // both has pending data to write, and is able to write (e.g. based on flow |
wtc
2014/05/19 18:58:40
Nit: has both has => both has
ramant (doing other things)
2014/05/20 03:22:32
Done.
| |
99 // yielded to other connections. | 98 // control limits). |
100 virtual bool HasPendingWrites() const = 0; | 99 // Writes may be pending because they were write-blocked, congestion-throttled |
100 // or yielded to other connections. | |
101 virtual bool WillingAndAbleToWrite() const = 0; | |
101 | 102 |
102 // Called to ask if any handshake messages are pending in this visitor. | 103 // Called to ask if any handshake messages are pending in this visitor. |
103 virtual bool HasPendingHandshake() const = 0; | 104 virtual bool HasPendingHandshake() const = 0; |
104 | 105 |
105 // 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 |
106 // reserved crypto and headers stream. | 107 // reserved crypto and headers stream. |
107 virtual bool HasOpenDataStreams() const = 0; | 108 virtual bool HasOpenDataStreams() const = 0; |
108 }; | 109 }; |
109 | 110 |
110 // Interface which gets callbacks from the QuicConnection at interesting | 111 // Interface which gets callbacks from the QuicConnection at interesting |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 BUNDLE_PENDING_ACK = 2, | 211 BUNDLE_PENDING_ACK = 2, |
211 }; | 212 }; |
212 | 213 |
213 // Constructs a new QuicConnection for |connection_id| and |address|. | 214 // Constructs a new QuicConnection for |connection_id| and |address|. |
214 // |helper| and |writer| must outlive this connection. | 215 // |helper| and |writer| must outlive this connection. |
215 QuicConnection(QuicConnectionId connection_id, | 216 QuicConnection(QuicConnectionId connection_id, |
216 IPEndPoint address, | 217 IPEndPoint address, |
217 QuicConnectionHelperInterface* helper, | 218 QuicConnectionHelperInterface* helper, |
218 QuicPacketWriter* writer, | 219 QuicPacketWriter* writer, |
219 bool is_server, | 220 bool is_server, |
220 const QuicVersionVector& supported_versions, | 221 const QuicVersionVector& supported_versions); |
221 uint32 max_flow_control_receive_window_bytes); | |
222 virtual ~QuicConnection(); | 222 virtual ~QuicConnection(); |
223 | 223 |
224 // Sets connection parameters from the supplied |config|. | 224 // Sets connection parameters from the supplied |config|. |
225 void SetFromConfig(const QuicConfig& config); | 225 void SetFromConfig(const QuicConfig& config); |
226 | 226 |
227 // Send the data in |data| to the peer in as few packets as possible. | 227 // Send the data in |data| to the peer in as few packets as possible. |
228 // Returns a pair with the number of bytes consumed from data, and a boolean | 228 // Returns a pair with the number of bytes consumed from data, and a boolean |
229 // indicating if the fin bit was consumed. This does not indicate the data | 229 // indicating if the fin bit was consumed. This does not indicate the data |
230 // has been sent on the wire: it may have been turned into a packet and queued | 230 // has been sent on the wire: it may have been turned into a packet and queued |
231 // if the socket was unexpectedly blocked. | 231 // if the socket was unexpectedly blocked. |
(...skipping 28 matching lines...) Expand all Loading... | |
260 // calling CloseConnection(notifying the visitor as it does so). | 260 // calling CloseConnection(notifying the visitor as it does so). |
261 virtual void SendConnectionClose(QuicErrorCode error); | 261 virtual void SendConnectionClose(QuicErrorCode error); |
262 virtual void SendConnectionCloseWithDetails(QuicErrorCode error, | 262 virtual void SendConnectionCloseWithDetails(QuicErrorCode error, |
263 const std::string& details); | 263 const std::string& details); |
264 // Notifies the visitor of the close and marks the connection as disconnected. | 264 // Notifies the visitor of the close and marks the connection as disconnected. |
265 virtual void CloseConnection(QuicErrorCode error, bool from_peer) OVERRIDE; | 265 virtual void CloseConnection(QuicErrorCode error, bool from_peer) OVERRIDE; |
266 virtual void SendGoAway(QuicErrorCode error, | 266 virtual void SendGoAway(QuicErrorCode error, |
267 QuicStreamId last_good_stream_id, | 267 QuicStreamId last_good_stream_id, |
268 const std::string& reason); | 268 const std::string& reason); |
269 | 269 |
270 QuicFlowController* flow_controller() { return flow_controller_.get(); } | |
271 | |
272 // Returns statistics tracked for this connection. | 270 // Returns statistics tracked for this connection. |
273 const QuicConnectionStats& GetStats(); | 271 const QuicConnectionStats& GetStats(); |
274 | 272 |
275 // Processes an incoming UDP packet (consisting of a QuicEncryptedPacket) from | 273 // Processes an incoming UDP packet (consisting of a QuicEncryptedPacket) from |
276 // the peer. If processing this packet permits a packet to be revived from | 274 // the peer. If processing this packet permits a packet to be revived from |
277 // its FEC group that packet will be revived and processed. | 275 // its FEC group that packet will be revived and processed. |
278 virtual void ProcessUdpPacket(const IPEndPoint& self_address, | 276 virtual void ProcessUdpPacket(const IPEndPoint& self_address, |
279 const IPEndPoint& peer_address, | 277 const IPEndPoint& peer_address, |
280 const QuicEncryptedPacket& packet); | 278 const QuicEncryptedPacket& packet); |
281 | 279 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 bool is_server() const { return is_server_; } | 451 bool is_server() const { return is_server_; } |
454 | 452 |
455 // Returns the underlying sent packet manager. | 453 // Returns the underlying sent packet manager. |
456 const QuicSentPacketManager& sent_packet_manager() const { | 454 const QuicSentPacketManager& sent_packet_manager() const { |
457 return sent_packet_manager_; | 455 return sent_packet_manager_; |
458 } | 456 } |
459 | 457 |
460 bool CanWrite(TransmissionType transmission_type, | 458 bool CanWrite(TransmissionType transmission_type, |
461 HasRetransmittableData retransmittable); | 459 HasRetransmittableData retransmittable); |
462 | 460 |
463 uint32 max_flow_control_receive_window_bytes() const { | |
464 return max_flow_control_receive_window_bytes_; | |
465 } | |
466 | |
467 // Stores current batch state for connection, puts the connection | 461 // Stores current batch state for connection, puts the connection |
468 // into batch mode, and destruction restores the stored batch state. | 462 // into batch mode, and destruction restores the stored batch state. |
469 // While the bundler is in scope, any generated frames are bundled | 463 // While the bundler is in scope, any generated frames are bundled |
470 // as densely as possible into packets. In addition, this bundler | 464 // as densely as possible into packets. In addition, this bundler |
471 // can be configured to ensure that an ACK frame is included in the | 465 // can be configured to ensure that an ACK frame is included in the |
472 // first packet created, if there's new ack information to be sent. | 466 // first packet created, if there's new ack information to be sent. |
473 class ScopedPacketBundler { | 467 class ScopedPacketBundler { |
474 public: | 468 public: |
475 // In addition to all outgoing frames being bundled when the | 469 // In addition to all outgoing frames being bundled when the |
476 // bundler is in scope, setting |include_ack| to true ensures that | 470 // bundler is in scope, setting |include_ack| to true ensures that |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 bool self_ip_changed_; | 747 bool self_ip_changed_; |
754 | 748 |
755 // Set to true if the UDP packet headers are addressed to a different port. | 749 // Set to true if the UDP packet headers are addressed to a different port. |
756 // We do not support connection migration when the self port changed. | 750 // We do not support connection migration when the self port changed. |
757 bool self_port_changed_; | 751 bool self_port_changed_; |
758 | 752 |
759 // If non-empty this contains the set of versions received in a | 753 // If non-empty this contains the set of versions received in a |
760 // version negotiation packet. | 754 // version negotiation packet. |
761 QuicVersionVector server_supported_versions_; | 755 QuicVersionVector server_supported_versions_; |
762 | 756 |
763 // Initial flow control receive window size for new streams. | |
764 uint32 max_flow_control_receive_window_bytes_; | |
765 | |
766 // Used for connection level flow control. | |
767 scoped_ptr<QuicFlowController> flow_controller_; | |
768 | |
769 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 757 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
770 }; | 758 }; |
771 | 759 |
772 } // namespace net | 760 } // namespace net |
773 | 761 |
774 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 762 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |