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 #include "net/quic/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/iovector.h" | 8 #include "net/quic/iovector.h" |
9 #include "net/quic/quic_flow_controller.h" | 9 #include "net/quic/quic_flow_controller.h" |
10 #include "net/quic/quic_session.h" | 10 #include "net/quic/quic_session.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 GetReceivedFlowControlWindow(session), | 159 GetReceivedFlowControlWindow(session), |
160 GetInitialStreamFlowControlWindowToSend(session), | 160 GetInitialStreamFlowControlWindowToSend(session), |
161 GetInitialStreamFlowControlWindowToSend(session)), | 161 GetInitialStreamFlowControlWindowToSend(session)), |
162 connection_flow_controller_(session_->flow_controller()), | 162 connection_flow_controller_(session_->flow_controller()), |
163 stream_contributes_to_connection_flow_control_(true) { | 163 stream_contributes_to_connection_flow_control_(true) { |
164 } | 164 } |
165 | 165 |
166 ReliableQuicStream::~ReliableQuicStream() { | 166 ReliableQuicStream::~ReliableQuicStream() { |
167 } | 167 } |
168 | 168 |
169 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) { | 169 void ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) { |
170 if (read_side_closed_) { | 170 if (read_side_closed_) { |
171 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id; | 171 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id; |
172 // We don't want to be reading: blackhole the data. | 172 // We don't want to be reading: blackhole the data. |
173 return true; | 173 return; |
174 } | 174 } |
175 | 175 |
176 if (frame.stream_id != id_) { | 176 if (frame.stream_id != id_) { |
177 LOG(ERROR) << "Error!"; | 177 session_->connection()->SendConnectionClose(QUIC_INTERNAL_ERROR); |
178 return false; | 178 return; |
179 } | 179 } |
180 | 180 |
181 if (frame.fin) { | 181 if (frame.fin) { |
182 fin_received_ = true; | 182 fin_received_ = true; |
183 } | 183 } |
184 | 184 |
185 // This count include duplicate data received. | 185 // This count include duplicate data received. |
186 size_t frame_payload_size = frame.data.TotalBufferSize(); | 186 size_t frame_payload_size = frame.data.TotalBufferSize(); |
187 stream_bytes_read_ += frame_payload_size; | 187 stream_bytes_read_ += frame_payload_size; |
188 | 188 |
189 // Flow control is interested in tracking highest received offset. | 189 // Flow control is interested in tracking highest received offset. |
190 if (MaybeIncreaseHighestReceivedOffset(frame.offset + frame_payload_size)) { | 190 if (MaybeIncreaseHighestReceivedOffset(frame.offset + frame_payload_size)) { |
191 // As the highest received offset has changed, we should check to see if | 191 // As the highest received offset has changed, we should check to see if |
192 // this is a violation of flow control. | 192 // this is a violation of flow control. |
193 if (flow_controller_.FlowControlViolation() || | 193 if (flow_controller_.FlowControlViolation() || |
194 connection_flow_controller_->FlowControlViolation()) { | 194 connection_flow_controller_->FlowControlViolation()) { |
195 session_->connection()->SendConnectionClose( | 195 session_->connection()->SendConnectionClose( |
196 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA); | 196 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA); |
197 return false; | 197 return; |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 return sequencer_.OnStreamFrame(frame); | 201 sequencer_.OnStreamFrame(frame); |
202 } | 202 } |
203 | 203 |
204 int ReliableQuicStream::num_frames_received() const { | 204 int ReliableQuicStream::num_frames_received() const { |
205 return sequencer_.num_frames_received(); | 205 return sequencer_.num_frames_received(); |
206 } | 206 } |
207 | 207 |
208 int ReliableQuicStream::num_duplicate_frames_received() const { | 208 int ReliableQuicStream::num_duplicate_frames_received() const { |
209 return sequencer_.num_duplicate_frames_received(); | 209 return sequencer_.num_duplicate_frames_received(); |
210 } | 210 } |
211 | 211 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 534 |
535 bool ReliableQuicStream::IsFlowControlBlocked() { | 535 bool ReliableQuicStream::IsFlowControlBlocked() { |
536 if (flow_controller_.IsBlocked()) { | 536 if (flow_controller_.IsBlocked()) { |
537 return true; | 537 return true; |
538 } | 538 } |
539 return stream_contributes_to_connection_flow_control_ && | 539 return stream_contributes_to_connection_flow_control_ && |
540 connection_flow_controller_->IsBlocked(); | 540 connection_flow_controller_->IsBlocked(); |
541 } | 541 } |
542 | 542 |
543 } // namespace net | 543 } // namespace net |
OLD | NEW |