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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 // Called when a blocked socket becomes writable. If all pending bytes for | 76 // Called when a blocked socket becomes writable. If all pending bytes for |
77 // this visitor are consumed by the connection successfully this should | 77 // this visitor are consumed by the connection successfully this should |
78 // return true, otherwise it should return false. | 78 // return true, otherwise it should return false. |
79 virtual bool OnCanWrite() = 0; | 79 virtual bool OnCanWrite() = 0; |
80 }; | 80 }; |
81 | 81 |
82 // Interface which gets callbacks from the QuicConnection at interesting | 82 // Interface which gets callbacks from the QuicConnection at interesting |
83 // points. Implementations must not mutate the state of the connection | 83 // points. Implementations must not mutate the state of the connection |
84 // as a result of these callbacks. | 84 // as a result of these callbacks. |
85 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitorInterface { | 85 class NET_EXPORT_PRIVATE QuicConnectionDebugVisitorInterface |
| 86 : public QuicPacketGenerator::DebugDelegateInterface { |
86 public: | 87 public: |
87 virtual ~QuicConnectionDebugVisitorInterface() {} | 88 virtual ~QuicConnectionDebugVisitorInterface() {} |
88 | 89 |
| 90 // Called when a packet has been sent. |
| 91 virtual void OnPacketSent(QuicPacketSequenceNumber sequence_number, |
| 92 EncryptionLevel level, |
| 93 const QuicEncryptedPacket& packet, |
| 94 int rv) = 0; |
| 95 |
89 // Called when a packet has been received, but before it is | 96 // Called when a packet has been received, but before it is |
90 // validated or parsed. | 97 // validated or parsed. |
91 virtual void OnPacketReceived(const IPEndPoint& self_address, | 98 virtual void OnPacketReceived(const IPEndPoint& self_address, |
92 const IPEndPoint& peer_address, | 99 const IPEndPoint& peer_address, |
93 const QuicEncryptedPacket& packet) = 0; | 100 const QuicEncryptedPacket& packet) = 0; |
94 | 101 |
95 // Called when the protocol version on the received packet doensn't match | 102 // Called when the protocol version on the received packet doensn't match |
96 // current protocol version of the connection. | 103 // current protocol version of the connection. |
97 virtual void OnProtocolVersionMismatch(QuicTag version) = 0; | 104 virtual void OnProtocolVersionMismatch(QuicTag version) = 0; |
98 | 105 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 virtual QuicAckFrame* CreateAckFrame() OVERRIDE; | 306 virtual QuicAckFrame* CreateAckFrame() OVERRIDE; |
300 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() OVERRIDE; | 307 virtual QuicCongestionFeedbackFrame* CreateFeedbackFrame() OVERRIDE; |
301 virtual bool OnSerializedPacket(const SerializedPacket& packet) OVERRIDE; | 308 virtual bool OnSerializedPacket(const SerializedPacket& packet) OVERRIDE; |
302 | 309 |
303 // Accessors | 310 // Accessors |
304 void set_visitor(QuicConnectionVisitorInterface* visitor) { | 311 void set_visitor(QuicConnectionVisitorInterface* visitor) { |
305 visitor_ = visitor; | 312 visitor_ = visitor; |
306 } | 313 } |
307 void set_debug_visitor(QuicConnectionDebugVisitorInterface* debug_visitor) { | 314 void set_debug_visitor(QuicConnectionDebugVisitorInterface* debug_visitor) { |
308 debug_visitor_ = debug_visitor; | 315 debug_visitor_ = debug_visitor; |
| 316 packet_generator_.set_debug_delegate(debug_visitor); |
309 } | 317 } |
310 const IPEndPoint& self_address() const { return self_address_; } | 318 const IPEndPoint& self_address() const { return self_address_; } |
311 const IPEndPoint& peer_address() const { return peer_address_; } | 319 const IPEndPoint& peer_address() const { return peer_address_; } |
312 QuicGuid guid() const { return guid_; } | 320 QuicGuid guid() const { return guid_; } |
313 const QuicClock* clock() const { return clock_; } | 321 const QuicClock* clock() const { return clock_; } |
314 QuicRandom* random_generator() const { return random_generator_; } | 322 QuicRandom* random_generator() const { return random_generator_; } |
315 | 323 |
316 // Updates the internal state concerning which packets have been acked. | 324 // Updates the internal state concerning which packets have been acked. |
317 void RecordPacketReceived(const QuicPacketHeader& header); | 325 void RecordPacketReceived(const QuicPacketHeader& header); |
318 | 326 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 // deleted and should not be accessed. If |sequence_number| is present in | 430 // deleted and should not be accessed. If |sequence_number| is present in |
423 // |retransmission_map_| it also sets up retransmission of the given packet | 431 // |retransmission_map_| it also sets up retransmission of the given packet |
424 // in case of successful write. If |force| is FORCE, then the packet will be | 432 // in case of successful write. If |force| is FORCE, then the packet will be |
425 // sent immediately and the send scheduler will not be consulted. | 433 // sent immediately and the send scheduler will not be consulted. |
426 bool WritePacket(EncryptionLevel level, | 434 bool WritePacket(EncryptionLevel level, |
427 QuicPacketSequenceNumber sequence_number, | 435 QuicPacketSequenceNumber sequence_number, |
428 QuicPacket* packet, | 436 QuicPacket* packet, |
429 HasRetransmittableData retransmittable, | 437 HasRetransmittableData retransmittable, |
430 Force force); | 438 Force force); |
431 | 439 |
| 440 int WritePacketToWire(QuicPacketSequenceNumber sequence_number, |
| 441 EncryptionLevel level, |
| 442 const QuicEncryptedPacket& packet, |
| 443 int* error); |
| 444 |
432 // Make sure an ack we got from our peer is sane. | 445 // Make sure an ack we got from our peer is sane. |
433 bool ValidateAckFrame(const QuicAckFrame& incoming_ack); | 446 bool ValidateAckFrame(const QuicAckFrame& incoming_ack); |
434 | 447 |
435 QuicConnectionHelperInterface* helper() { return helper_.get(); } | 448 QuicConnectionHelperInterface* helper() { return helper_.get(); } |
436 | 449 |
437 protected: | 450 protected: |
438 QuicFramer framer_; | 451 QuicFramer framer_; |
439 | 452 |
440 private: | 453 private: |
441 friend class test::QuicConnectionPeer; | 454 friend class test::QuicConnectionPeer; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 // Set to true if the udp packet headers have a new self or peer address. | 704 // Set to true if the udp packet headers have a new self or peer address. |
692 // This is checked later on validating a data or version negotiation packet. | 705 // This is checked later on validating a data or version negotiation packet. |
693 bool address_migrating_; | 706 bool address_migrating_; |
694 | 707 |
695 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 708 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
696 }; | 709 }; |
697 | 710 |
698 } // namespace net | 711 } // namespace net |
699 | 712 |
700 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 713 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |