| 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 // Responsible for generating packets on behalf of a QuicConnection. | 5 // Responsible for generating packets on behalf of a QuicConnection. |
| 6 // Packets are serialized just-in-time. Control frames are queued. | 6 // Packets are serialized just-in-time. Control frames are queued. |
| 7 // Ack and Feedback frames will be requested from the Connection | 7 // Ack and Feedback frames will be requested from the Connection |
| 8 // just-in-time. When a packet needs to be sent, the Generator | 8 // just-in-time. When a packet needs to be sent, the Generator |
| 9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket() | 9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket() |
| 10 // | 10 // |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 bool HasQueuedFrames() const; | 102 bool HasQueuedFrames() const; |
| 103 | 103 |
| 104 void set_debug_delegate(DebugDelegateInterface* debug_delegate) { | 104 void set_debug_delegate(DebugDelegateInterface* debug_delegate) { |
| 105 debug_delegate_ = debug_delegate; | 105 debug_delegate_ = debug_delegate; |
| 106 } | 106 } |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 void SendQueuedFrames(); | 109 void SendQueuedFrames(); |
| 110 | 110 |
| 111 // Test to see if we have pending ack, feedback, or control frames. |
| 111 bool HasPendingFrames() const; | 112 bool HasPendingFrames() const; |
| 113 // Test to see if the addition of a pending frame (which might be |
| 114 // retransmittable) would still allow the resulting packet to be sent now. |
| 115 bool CanSendWithNextPendingFrameAddition() const; |
| 116 // Add exactly one pending frame, preferring ack over feedback over control |
| 117 // frames. |
| 112 bool AddNextPendingFrame(); | 118 bool AddNextPendingFrame(); |
| 113 | 119 |
| 114 bool AddFrame(const QuicFrame& frame); | 120 bool AddFrame(const QuicFrame& frame); |
| 115 void SerializeAndSendPacket(); | 121 void SerializeAndSendPacket(); |
| 116 | 122 |
| 117 DelegateInterface* delegate_; | 123 DelegateInterface* delegate_; |
| 118 DebugDelegateInterface* debug_delegate_; | 124 DebugDelegateInterface* debug_delegate_; |
| 119 | 125 |
| 120 QuicPacketCreator* packet_creator_; | 126 QuicPacketCreator* packet_creator_; |
| 121 QuicFrames queued_control_frames_; | 127 QuicFrames queued_control_frames_; |
| 122 bool should_flush_; | 128 bool should_flush_; |
| 129 // Flags to indicate the need for just-in-time construction of a frame. |
| 123 bool should_send_ack_; | 130 bool should_send_ack_; |
| 131 bool should_send_feedback_; |
| 132 // If we put a non-retransmittable frame (namley ack or feedback frame) in |
| 133 // this packet, then we have to hold a reference to it until we flush (and |
| 134 // serialize it). Retransmittable frames are referenced elsewhere so that they |
| 135 // can later be (optionally) retransmitted. |
| 124 scoped_ptr<QuicAckFrame> pending_ack_frame_; | 136 scoped_ptr<QuicAckFrame> pending_ack_frame_; |
| 125 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; | 137 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; |
| 126 bool should_send_feedback_; | |
| 127 | 138 |
| 128 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); | 139 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); |
| 129 }; | 140 }; |
| 130 | 141 |
| 131 } // namespace net | 142 } // namespace net |
| 132 | 143 |
| 133 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ | 144 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ |
| OLD | NEW |