| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // packet creator to be serialized into packets. If not in batch | 115 // packet creator to be serialized into packets. If not in batch |
| 116 // mode, these packets will also be sent during this call. Also | 116 // mode, these packets will also be sent during this call. Also |
| 117 // attaches a QuicAckNotifier to any created stream frames, which | 117 // attaches a QuicAckNotifier to any created stream frames, which |
| 118 // will be called once the frame is ACKed by the peer. The | 118 // will be called once the frame is ACKed by the peer. The |
| 119 // QuicAckNotifier is owned by the QuicConnection. |notifier| may | 119 // QuicAckNotifier is owned by the QuicConnection. |notifier| may |
| 120 // be NULL. | 120 // be NULL. |
| 121 QuicConsumedData ConsumeData(QuicStreamId id, | 121 QuicConsumedData ConsumeData(QuicStreamId id, |
| 122 const IOVector& data, | 122 const IOVector& data, |
| 123 QuicStreamOffset offset, | 123 QuicStreamOffset offset, |
| 124 bool fin, | 124 bool fin, |
| 125 FecProtection fec_protection, |
| 125 QuicAckNotifier* notifier); | 126 QuicAckNotifier* notifier); |
| 126 | 127 |
| 127 // Indicates whether batch mode is currently enabled. | 128 // Indicates whether batch mode is currently enabled. |
| 128 bool InBatchMode(); | 129 bool InBatchMode(); |
| 129 // Disables flushing. | 130 // Disables flushing. |
| 130 void StartBatchOperations(); | 131 void StartBatchOperations(); |
| 131 // Enables flushing and flushes queued data which can be sent. | 132 // Enables flushing and flushes queued data which can be sent. |
| 132 void FinishBatchOperations(); | 133 void FinishBatchOperations(); |
| 133 | 134 |
| 134 // Flushes all queued frames, even frames which are not sendable. | 135 // Flushes all queued frames, even frames which are not sendable. |
| 135 void FlushAllQueuedFrames(); | 136 void FlushAllQueuedFrames(); |
| 136 | 137 |
| 137 bool HasQueuedFrames() const; | 138 bool HasQueuedFrames() const; |
| 138 | 139 |
| 139 void set_debug_delegate(DebugDelegate* debug_delegate) { | 140 void set_debug_delegate(DebugDelegate* debug_delegate) { |
| 140 debug_delegate_ = debug_delegate; | 141 debug_delegate_ = debug_delegate; |
| 141 } | 142 } |
| 142 | 143 |
| 143 private: | 144 private: |
| 144 friend class test::QuicPacketGeneratorPeer; | 145 friend class test::QuicPacketGeneratorPeer; |
| 145 | 146 |
| 146 // Turn on FEC protection for subsequent packets in the generator. | 147 // Turn on FEC protection for subsequent packets in the generator. |
| 147 // If no FEC group is currently open in the creator, this method flushes any | 148 // If no FEC group is currently open in the creator, this method flushes any |
| 148 // queued frames in the generator and in the creator, and it then turns FEC on | 149 // queued frames in the generator and in the creator, and it then turns FEC on |
| 149 // in the creator. This method may be called with an open FEC group in the | 150 // in the creator. This method may be called with an open FEC group in the |
| 150 // creator, in which case, only the generator's state is altered. | 151 // creator, in which case, only the generator's state is altered. |
| 151 void MaybeStartFecProtection(); | 152 void MaybeStartFecProtection(); |
| 152 | 153 |
| 153 // Turn off FEC protection for subsequent packets. If |force| is true, | |
| 154 // force-closes any open FEC group, sends out an FEC packet if one was under | |
| 155 // construction, and turns off protection in the generator and creator. If | |
| 156 // |force| is false, does the same as above if the creator is ready to send | |
| 157 // and FEC packet. Note that when |force| is false, the creator may still have | |
| 158 // an open FEC group after this method runs. | |
| 159 void MaybeStopFecProtection(bool force); | |
| 160 | |
| 161 // Serializes and calls the delegate on an FEC packet if one was under | 154 // Serializes and calls the delegate on an FEC packet if one was under |
| 162 // construction in the creator. When |force| is false, it relies on the | 155 // construction in the creator. When |force| is false, it relies on the |
| 163 // creator being ready to send an FEC packet, otherwise FEC packet is sent | 156 // creator being ready to send an FEC packet, otherwise FEC packet is sent |
| 164 // as long as one is under construction in the creator. Also tries to turns | 157 // as long as one is under construction in the creator. Also tries to turns |
| 165 // off FEC protection in the creator if it's off in the generator. | 158 // off FEC protection in the creator if it's off in the generator. |
| 166 void MaybeSendFecPacketAndCloseGroup(bool force); | 159 void MaybeSendFecPacketAndCloseGroup(bool force); |
| 167 | 160 |
| 168 void SendQueuedFrames(bool flush); | 161 void SendQueuedFrames(bool flush); |
| 169 | 162 |
| 170 // Test to see if we have pending ack, feedback, or control frames. | 163 // Test to see if we have pending ack, feedback, or control frames. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 182 | 175 |
| 183 DelegateInterface* delegate_; | 176 DelegateInterface* delegate_; |
| 184 DebugDelegate* debug_delegate_; | 177 DebugDelegate* debug_delegate_; |
| 185 | 178 |
| 186 QuicPacketCreator* packet_creator_; | 179 QuicPacketCreator* packet_creator_; |
| 187 QuicFrames queued_control_frames_; | 180 QuicFrames queued_control_frames_; |
| 188 | 181 |
| 189 // True if batch mode is currently enabled. | 182 // True if batch mode is currently enabled. |
| 190 bool batch_mode_; | 183 bool batch_mode_; |
| 191 | 184 |
| 192 // True if FEC protection is on. | 185 // True if FEC protection is on. The creator may have an open FEC group even |
| 186 // if this variable is false. |
| 193 bool should_fec_protect_; | 187 bool should_fec_protect_; |
| 194 | 188 |
| 195 // Flags to indicate the need for just-in-time construction of a frame. | 189 // Flags to indicate the need for just-in-time construction of a frame. |
| 196 bool should_send_ack_; | 190 bool should_send_ack_; |
| 197 bool should_send_feedback_; | 191 bool should_send_feedback_; |
| 198 bool should_send_stop_waiting_; | 192 bool should_send_stop_waiting_; |
| 199 // If we put a non-retransmittable frame (namley ack or feedback frame) in | 193 // If we put a non-retransmittable frame (namley ack or feedback frame) in |
| 200 // this packet, then we have to hold a reference to it until we flush (and | 194 // this packet, then we have to hold a reference to it until we flush (and |
| 201 // serialize it). Retransmittable frames are referenced elsewhere so that they | 195 // serialize it). Retransmittable frames are referenced elsewhere so that they |
| 202 // can later be (optionally) retransmitted. | 196 // can later be (optionally) retransmitted. |
| 203 scoped_ptr<QuicAckFrame> pending_ack_frame_; | 197 scoped_ptr<QuicAckFrame> pending_ack_frame_; |
| 204 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; | 198 scoped_ptr<QuicCongestionFeedbackFrame> pending_feedback_frame_; |
| 205 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; | 199 scoped_ptr<QuicStopWaitingFrame> pending_stop_waiting_frame_; |
| 206 | 200 |
| 207 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); | 201 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); |
| 208 }; | 202 }; |
| 209 | 203 |
| 210 } // namespace net | 204 } // namespace net |
| 211 | 205 |
| 212 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ | 206 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ |
| OLD | NEW |