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