| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 // Called when packets are acked by the peer. | 67 // Called when packets are acked by the peer. |
| 68 virtual void OnAck(AckedPackets acked_packets) = 0; | 68 virtual void OnAck(AckedPackets acked_packets) = 0; |
| 69 | 69 |
| 70 // Called when a blocked socket becomes writable. If all pending bytes for | 70 // Called when a blocked socket becomes writable. If all pending bytes for |
| 71 // this visitor are consumed by the connection successfully this should | 71 // this visitor are consumed by the connection successfully this should |
| 72 // return true, otherwise it should return false. | 72 // return true, otherwise it should return false. |
| 73 virtual bool OnCanWrite() = 0; | 73 virtual bool OnCanWrite() = 0; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // Interface which gets callbacks from the QuicConnection at interesting |
| 77 // points. Implementations must not mutate the state of the connection |
| 78 // as a result of these callbacks. |
| 79 class QuicConnectionDebugVisitorInterface { |
| 80 public: |
| 81 virtual ~QuicConnectionDebugVisitorInterface() {} |
| 82 |
| 83 // Called when a packet has been received, but before it is |
| 84 // validated or parsed. |
| 85 virtual void OnPacketReceived(const IPEndPoint& self_address, |
| 86 const IPEndPoint& peer_address, |
| 87 const QuicEncryptedPacket& packet) = 0; |
| 88 |
| 89 // Called when the header of a packet has been parsed. |
| 90 virtual void OnPacketHeader(const QuicPacketHeader& header) = 0; |
| 91 |
| 92 // Called when a StreamFrame has been parsed. |
| 93 virtual void OnStreamFrame(const QuicStreamFrame& frame) = 0; |
| 94 |
| 95 // Called when a AckFrame has been parsed. |
| 96 virtual void OnAckFrame(const QuicAckFrame& frame) = 0; |
| 97 |
| 98 // Called when a CongestionFeedbackFrame has been parsed. |
| 99 virtual void OnCongestionFeedbackFrame( |
| 100 const QuicCongestionFeedbackFrame& frame) = 0; |
| 101 |
| 102 // Called when a RstStreamFrame has been parsed. |
| 103 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) = 0; |
| 104 |
| 105 // Called when a ConnectionCloseFrame has been parsed. |
| 106 virtual void OnConnectionCloseFrame( |
| 107 const QuicConnectionCloseFrame& frame) = 0; |
| 108 |
| 109 // Called when a public reset packet has been received. |
| 110 virtual void OnPublicResetPacket(const QuicPublicResetPacket& packet) = 0; |
| 111 |
| 112 // Called after a packet has been successfully parsed which results |
| 113 // in the revival of a packet via FEC. |
| 114 virtual void OnRevivedPacket(const QuicPacketHeader& revived_header, |
| 115 base::StringPiece payload) = 0; |
| 116 }; |
| 117 |
| 76 class NET_EXPORT_PRIVATE QuicConnectionHelperInterface { | 118 class NET_EXPORT_PRIVATE QuicConnectionHelperInterface { |
| 77 public: | 119 public: |
| 78 virtual ~QuicConnectionHelperInterface() {} | 120 virtual ~QuicConnectionHelperInterface() {} |
| 79 | 121 |
| 80 // Sets the QuicConnection to be used by this helper. This method | 122 // Sets the QuicConnection to be used by this helper. This method |
| 81 // must only be called once. | 123 // must only be called once. |
| 82 virtual void SetConnection(QuicConnection* connection) = 0; | 124 virtual void SetConnection(QuicConnection* connection) = 0; |
| 83 | 125 |
| 84 // Returns a QuicClock to be used for all time related functions. | 126 // Returns a QuicClock to be used for all time related functions. |
| 85 virtual const QuicClock* GetClock() const = 0; | 127 virtual const QuicClock* GetClock() const = 0; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE; | 230 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE; |
| 189 virtual void OnConnectionCloseFrame( | 231 virtual void OnConnectionCloseFrame( |
| 190 const QuicConnectionCloseFrame& frame) OVERRIDE; | 232 const QuicConnectionCloseFrame& frame) OVERRIDE; |
| 191 virtual void OnFecData(const QuicFecData& fec) OVERRIDE; | 233 virtual void OnFecData(const QuicFecData& fec) OVERRIDE; |
| 192 virtual void OnPacketComplete() OVERRIDE; | 234 virtual void OnPacketComplete() OVERRIDE; |
| 193 | 235 |
| 194 // Accessors | 236 // Accessors |
| 195 void set_visitor(QuicConnectionVisitorInterface* visitor) { | 237 void set_visitor(QuicConnectionVisitorInterface* visitor) { |
| 196 visitor_ = visitor; | 238 visitor_ = visitor; |
| 197 } | 239 } |
| 240 void set_debug_visitor(QuicConnectionDebugVisitorInterface* debug_visitor) { |
| 241 debug_visitor_ = debug_visitor; |
| 242 } |
| 198 const IPEndPoint& self_address() const { return self_address_; } | 243 const IPEndPoint& self_address() const { return self_address_; } |
| 199 const IPEndPoint& peer_address() const { return peer_address_; } | 244 const IPEndPoint& peer_address() const { return peer_address_; } |
| 200 QuicGuid guid() const { return guid_; } | 245 QuicGuid guid() const { return guid_; } |
| 201 const QuicClock* clock() const { return clock_; } | 246 const QuicClock* clock() const { return clock_; } |
| 202 QuicRandom* random_generator() const { return random_generator_; } | 247 QuicRandom* random_generator() const { return random_generator_; } |
| 203 | 248 |
| 204 // Updates the internal state concerning which packets have been acked. | 249 // Updates the internal state concerning which packets have been acked. |
| 205 void RecordPacketReceived(const QuicPacketHeader& header); | 250 void RecordPacketReceived(const QuicPacketHeader& header); |
| 206 | 251 |
| 207 // Called by a RetransmissionAlarm when the timer goes off. If the peer | 252 // Called by a RetransmissionAlarm when the timer goes off. If the peer |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 478 |
| 434 // Pending control frames, besides the ack and congestion control frames. | 479 // Pending control frames, besides the ack and congestion control frames. |
| 435 QuicFrames queued_control_frames_; | 480 QuicFrames queued_control_frames_; |
| 436 | 481 |
| 437 // True when the socket becomes unwritable. | 482 // True when the socket becomes unwritable. |
| 438 bool write_blocked_; | 483 bool write_blocked_; |
| 439 | 484 |
| 440 FecGroupMap group_map_; | 485 FecGroupMap group_map_; |
| 441 | 486 |
| 442 QuicConnectionVisitorInterface* visitor_; | 487 QuicConnectionVisitorInterface* visitor_; |
| 488 QuicConnectionDebugVisitorInterface* debug_visitor_; |
| 443 QuicPacketCreator packet_creator_; | 489 QuicPacketCreator packet_creator_; |
| 444 | 490 |
| 445 // Network idle time before we kill of this connection. | 491 // Network idle time before we kill of this connection. |
| 446 const QuicTime::Delta timeout_; | 492 const QuicTime::Delta timeout_; |
| 447 // The time that we got or tried to send a packet for this connection. | 493 // The time that we got or tried to send a packet for this connection. |
| 448 QuicTime time_of_last_packet_; | 494 QuicTime time_of_last_packet_; |
| 449 | 495 |
| 450 // Congestion manager which controls the rate the connection sends packets | 496 // Congestion manager which controls the rate the connection sends packets |
| 451 // as well as collecting and generating congestion feedback. | 497 // as well as collecting and generating congestion feedback. |
| 452 QuicCongestionManager congestion_manager_; | 498 QuicCongestionManager congestion_manager_; |
| 453 | 499 |
| 454 // True by default. False if we've received or sent an explicit connection | 500 // True by default. False if we've received or sent an explicit connection |
| 455 // close. | 501 // close. |
| 456 bool connected_; | 502 bool connected_; |
| 457 | 503 |
| 458 // True if the last ack received from the peer may have been truncated. False | 504 // True if the last ack received from the peer may have been truncated. False |
| 459 // otherwise. | 505 // otherwise. |
| 460 bool received_truncated_ack_; | 506 bool received_truncated_ack_; |
| 461 | 507 |
| 462 bool send_ack_in_response_to_packet_; | 508 bool send_ack_in_response_to_packet_; |
| 463 | 509 |
| 464 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 510 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 465 }; | 511 }; |
| 466 | 512 |
| 467 } // namespace net | 513 } // namespace net |
| 468 | 514 |
| 469 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 515 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |