| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 QUEUED, | 197 QUEUED, |
| 198 CONNECTION_CLOSE | 198 CONNECTION_CLOSE |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 enum AckBundling { | 201 enum AckBundling { |
| 202 NO_ACK = 0, | 202 NO_ACK = 0, |
| 203 SEND_ACK = 1, | 203 SEND_ACK = 1, |
| 204 BUNDLE_PENDING_ACK = 2, | 204 BUNDLE_PENDING_ACK = 2, |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 // Constructs a new QuicConnection for the specified |guid| and |address|. | 207 // Constructs a new QuicConnection for |connection_id| and |address|. |
| 208 // |helper| and |writer| must outlive this connection. | 208 // |helper| and |writer| must outlive this connection. |
| 209 QuicConnection(QuicGuid guid, | 209 QuicConnection(QuicConnectionId connection_id, |
| 210 IPEndPoint address, | 210 IPEndPoint address, |
| 211 QuicConnectionHelperInterface* helper, | 211 QuicConnectionHelperInterface* helper, |
| 212 QuicPacketWriter* writer, | 212 QuicPacketWriter* writer, |
| 213 bool is_server, | 213 bool is_server, |
| 214 const QuicVersionVector& supported_versions); | 214 const QuicVersionVector& supported_versions); |
| 215 virtual ~QuicConnection(); | 215 virtual ~QuicConnection(); |
| 216 | 216 |
| 217 // Sets connection parameters from the supplied |config|. | 217 // Sets connection parameters from the supplied |config|. |
| 218 void SetFromConfig(const QuicConfig& config); | 218 void SetFromConfig(const QuicConfig& config); |
| 219 | 219 |
| 220 // Send the data in |data| to the peer in as few packets as possible. | 220 // Send the data in |data| to the peer in as few packets as possible. |
| 221 // Returns a pair with the number of bytes consumed from data, and a boolean | 221 // Returns a pair with the number of bytes consumed from data, and a boolean |
| 222 // indicating if the fin bit was consumed. This does not indicate the data | 222 // indicating if the fin bit was consumed. This does not indicate the data |
| 223 // has been sent on the wire: it may have been turned into a packet and queued | 223 // has been sent on the wire: it may have been turned into a packet and queued |
| 224 // if the socket was unexpectedly blocked. | 224 // if the socket was unexpectedly blocked. |
| 225 // If |delegate| is provided, then it will be informed once ACKs have been | 225 // If |delegate| is provided, then it will be informed once ACKs have been |
| 226 // received for all the packets written in this call. | 226 // received for all the packets written in this call. |
| 227 // The |delegate| is not owned by the QuicConnection and must outlive it. | 227 // The |delegate| is not owned by the QuicConnection and must outlive it. |
| 228 QuicConsumedData SendStreamData(QuicStreamId id, | 228 QuicConsumedData SendStreamData(QuicStreamId id, |
| 229 const IOVector& data, | 229 const IOVector& data, |
| 230 QuicStreamOffset offset, | 230 QuicStreamOffset offset, |
| 231 bool fin, | 231 bool fin, |
| 232 QuicAckNotifier::DelegateInterface* delegate); | 232 QuicAckNotifier::DelegateInterface* delegate); |
| 233 | 233 |
| 234 // Send a stream reset frame to the peer. | 234 // Send a RST_STREAM frame to the peer. |
| 235 virtual void SendRstStream(QuicStreamId id, | 235 virtual void SendRstStream(QuicStreamId id, |
| 236 QuicRstStreamErrorCode error, | 236 QuicRstStreamErrorCode error, |
| 237 QuicStreamOffset bytes_written); | 237 QuicStreamOffset bytes_written); |
| 238 | 238 |
| 239 // Send a BLOCKED frame to the peer. |
| 240 virtual void SendBlocked(QuicStreamId id); |
| 241 |
| 242 // Send a WINDOW_UPDATE frame to the peer. |
| 243 virtual void SendWindowUpdate(QuicStreamId id, |
| 244 QuicStreamOffset byte_offset); |
| 245 |
| 239 // Sends the connection close packet without affecting the state of the | 246 // Sends the connection close packet without affecting the state of the |
| 240 // connection. This should only be called if the session is actively being | 247 // connection. This should only be called if the session is actively being |
| 241 // destroyed: otherwise call SendConnectionCloseWithDetails instead. | 248 // destroyed: otherwise call SendConnectionCloseWithDetails instead. |
| 242 virtual void SendConnectionClosePacket(QuicErrorCode error, | 249 virtual void SendConnectionClosePacket(QuicErrorCode error, |
| 243 const std::string& details); | 250 const std::string& details); |
| 244 | 251 |
| 245 // Sends a connection close frame to the peer, and closes the connection by | 252 // Sends a connection close frame to the peer, and closes the connection by |
| 246 // calling CloseConnection(notifying the visitor as it does so). | 253 // calling CloseConnection(notifying the visitor as it does so). |
| 247 virtual void SendConnectionClose(QuicErrorCode error); | 254 virtual void SendConnectionClose(QuicErrorCode error); |
| 248 virtual void SendConnectionCloseWithDetails(QuicErrorCode error, | 255 virtual void SendConnectionCloseWithDetails(QuicErrorCode error, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // Accessors | 334 // Accessors |
| 328 void set_visitor(QuicConnectionVisitorInterface* visitor) { | 335 void set_visitor(QuicConnectionVisitorInterface* visitor) { |
| 329 visitor_ = visitor; | 336 visitor_ = visitor; |
| 330 } | 337 } |
| 331 void set_debug_visitor(QuicConnectionDebugVisitorInterface* debug_visitor) { | 338 void set_debug_visitor(QuicConnectionDebugVisitorInterface* debug_visitor) { |
| 332 debug_visitor_ = debug_visitor; | 339 debug_visitor_ = debug_visitor; |
| 333 packet_generator_.set_debug_delegate(debug_visitor); | 340 packet_generator_.set_debug_delegate(debug_visitor); |
| 334 } | 341 } |
| 335 const IPEndPoint& self_address() const { return self_address_; } | 342 const IPEndPoint& self_address() const { return self_address_; } |
| 336 const IPEndPoint& peer_address() const { return peer_address_; } | 343 const IPEndPoint& peer_address() const { return peer_address_; } |
| 337 QuicGuid guid() const { return guid_; } | 344 QuicConnectionId connection_id() const { return connection_id_; } |
| 338 const QuicClock* clock() const { return clock_; } | 345 const QuicClock* clock() const { return clock_; } |
| 339 QuicRandom* random_generator() const { return random_generator_; } | 346 QuicRandom* random_generator() const { return random_generator_; } |
| 340 | 347 |
| 341 QuicPacketCreator::Options* options() { return packet_creator_.options(); } | 348 QuicPacketCreator::Options* options() { return packet_creator_.options(); } |
| 342 | 349 |
| 343 bool connected() const { return connected_; } | 350 bool connected() const { return connected_; } |
| 344 | 351 |
| 345 // Must only be called on client connections. | 352 // Must only be called on client connections. |
| 346 const QuicVersionVector& server_supported_versions() const { | 353 const QuicVersionVector& server_supported_versions() const { |
| 347 DCHECK(!is_server_); | 354 DCHECK(!is_server_); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // Closes any FEC groups protecting packets before |sequence_number|. | 595 // Closes any FEC groups protecting packets before |sequence_number|. |
| 589 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); | 596 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); |
| 590 | 597 |
| 591 QuicFramer framer_; | 598 QuicFramer framer_; |
| 592 QuicConnectionHelperInterface* helper_; // Not owned. | 599 QuicConnectionHelperInterface* helper_; // Not owned. |
| 593 QuicPacketWriter* writer_; // Not owned. | 600 QuicPacketWriter* writer_; // Not owned. |
| 594 EncryptionLevel encryption_level_; | 601 EncryptionLevel encryption_level_; |
| 595 const QuicClock* clock_; | 602 const QuicClock* clock_; |
| 596 QuicRandom* random_generator_; | 603 QuicRandom* random_generator_; |
| 597 | 604 |
| 598 const QuicGuid guid_; | 605 const QuicConnectionId connection_id_; |
| 599 // Address on the last successfully processed packet received from the | 606 // Address on the last successfully processed packet received from the |
| 600 // client. | 607 // client. |
| 601 IPEndPoint self_address_; | 608 IPEndPoint self_address_; |
| 602 IPEndPoint peer_address_; | 609 IPEndPoint peer_address_; |
| 603 | 610 |
| 604 bool last_packet_revived_; // True if the last packet was revived from FEC. | 611 bool last_packet_revived_; // True if the last packet was revived from FEC. |
| 605 size_t last_size_; // Size of the last received packet. | 612 size_t last_size_; // Size of the last received packet. |
| 606 QuicPacketHeader last_header_; | 613 QuicPacketHeader last_header_; |
| 607 std::vector<QuicStreamFrame> last_stream_frames_; | 614 std::vector<QuicStreamFrame> last_stream_frames_; |
| 608 std::vector<QuicAckFrame> last_ack_frames_; | 615 std::vector<QuicAckFrame> last_ack_frames_; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 // If non-empty this contains the set of versions received in a | 724 // If non-empty this contains the set of versions received in a |
| 718 // version negotiation packet. | 725 // version negotiation packet. |
| 719 QuicVersionVector server_supported_versions_; | 726 QuicVersionVector server_supported_versions_; |
| 720 | 727 |
| 721 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 728 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 722 }; | 729 }; |
| 723 | 730 |
| 724 } // namespace net | 731 } // namespace net |
| 725 | 732 |
| 726 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 733 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |