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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/crypto/proof_verifier.h" | 8 #include "net/quic/crypto/proof_verifier.h" |
9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 void QuicSession::OnWindowUpdateFrames( | 250 void QuicSession::OnWindowUpdateFrames( |
251 const vector<QuicWindowUpdateFrame>& frames) { | 251 const vector<QuicWindowUpdateFrame>& frames) { |
252 bool connection_window_updated = false; | 252 bool connection_window_updated = false; |
253 for (size_t i = 0; i < frames.size(); ++i) { | 253 for (size_t i = 0; i < frames.size(); ++i) { |
254 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't | 254 // Stream may be closed by the time we receive a WINDOW_UPDATE, so we can't |
255 // assume that it still exists. | 255 // assume that it still exists. |
256 QuicStreamId stream_id = frames[i].stream_id; | 256 QuicStreamId stream_id = frames[i].stream_id; |
257 if (stream_id == 0) { | 257 if (stream_id == kConnectionLevelId) { |
258 // This is a window update that applies to the connection, rather than an | 258 // This is a window update that applies to the connection, rather than an |
259 // individual stream. | 259 // individual stream. |
260 DVLOG(1) << ENDPOINT | 260 DVLOG(1) << ENDPOINT |
261 << "Received connection level flow control window update with " | 261 << "Received connection level flow control window update with " |
262 "byte offset: " << frames[i].byte_offset; | 262 "byte offset: " << frames[i].byte_offset; |
263 if (FLAGS_enable_quic_connection_flow_control_2 && | 263 if (FLAGS_enable_quic_connection_flow_control_2 && |
264 flow_controller_->UpdateSendWindowOffset(frames[i].byte_offset)) { | 264 flow_controller_->UpdateSendWindowOffset(frames[i].byte_offset)) { |
265 connection_window_updated = true; | 265 connection_window_updated = true; |
266 } | 266 } |
267 continue; | 267 continue; |
268 } | 268 } |
269 | 269 |
270 QuicDataStream* stream = GetDataStream(stream_id); | 270 if (connection_->version() <= QUIC_VERSION_20 && |
| 271 (stream_id == kCryptoStreamId || stream_id == kHeadersStreamId)) { |
| 272 DLOG(DFATAL) << "WindowUpdate for stream " << stream_id << " in version " |
| 273 << QuicVersionToString(connection_->version()); |
| 274 return; |
| 275 } |
| 276 |
| 277 ReliableQuicStream* stream = GetStream(stream_id); |
271 if (stream) { | 278 if (stream) { |
272 stream->OnWindowUpdateFrame(frames[i]); | 279 stream->OnWindowUpdateFrame(frames[i]); |
273 } | 280 } |
274 } | 281 } |
275 | 282 |
276 // Connection level flow control window has increased, so blocked streams can | 283 // Connection level flow control window has increased, so blocked streams can |
277 // write again. | 284 // write again. |
278 if (connection_window_updated) { | 285 if (connection_window_updated) { |
279 OnCanWrite(); | 286 OnCanWrite(); |
280 } | 287 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 if (new_window < kDefaultFlowControlSendWindow) { | 512 if (new_window < kDefaultFlowControlSendWindow) { |
506 LOG(ERROR) | 513 LOG(ERROR) |
507 << "Peer sent us an invalid stream flow control send window: " | 514 << "Peer sent us an invalid stream flow control send window: " |
508 << new_window << ", below default: " << kDefaultFlowControlSendWindow; | 515 << new_window << ", below default: " << kDefaultFlowControlSendWindow; |
509 if (connection_->connected()) { | 516 if (connection_->connected()) { |
510 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); | 517 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
511 } | 518 } |
512 return; | 519 return; |
513 } | 520 } |
514 | 521 |
| 522 // Inform all existing streams about the new window. |
| 523 if (connection_->version() > QUIC_VERSION_20) { |
| 524 GetCryptoStream()->flow_controller()->UpdateSendWindowOffset(new_window); |
| 525 headers_stream_->flow_controller()->UpdateSendWindowOffset(new_window); |
| 526 } |
515 for (DataStreamMap::iterator it = stream_map_.begin(); | 527 for (DataStreamMap::iterator it = stream_map_.begin(); |
516 it != stream_map_.end(); ++it) { | 528 it != stream_map_.end(); ++it) { |
517 it->second->flow_controller()->UpdateSendWindowOffset(new_window); | 529 it->second->flow_controller()->UpdateSendWindowOffset(new_window); |
518 } | 530 } |
519 } | 531 } |
520 | 532 |
521 void QuicSession::OnNewSessionFlowControlWindow(uint32 new_window) { | 533 void QuicSession::OnNewSessionFlowControlWindow(uint32 new_window) { |
522 if (new_window < kDefaultFlowControlSendWindow) { | 534 if (new_window < kDefaultFlowControlSendWindow) { |
523 LOG(ERROR) | 535 LOG(ERROR) |
524 << "Peer sent us an invalid session flow control send window: " | 536 << "Peer sent us an invalid session flow control send window: " |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 void QuicSession::PostProcessAfterData() { | 744 void QuicSession::PostProcessAfterData() { |
733 STLDeleteElements(&closed_streams_); | 745 STLDeleteElements(&closed_streams_); |
734 closed_streams_.clear(); | 746 closed_streams_.clear(); |
735 } | 747 } |
736 | 748 |
737 void QuicSession::OnSuccessfulVersionNegotiation(const QuicVersion& version) { | 749 void QuicSession::OnSuccessfulVersionNegotiation(const QuicVersion& version) { |
738 if (version < QUIC_VERSION_19) { | 750 if (version < QUIC_VERSION_19) { |
739 flow_controller_->Disable(); | 751 flow_controller_->Disable(); |
740 } | 752 } |
741 | 753 |
742 // Inform all streams about the negotiated version. They may have been created | 754 // Disable stream level flow control based on negotiated version. Streams may |
743 // with a different version. | 755 // have been created with a different version. |
| 756 if (version <= QUIC_VERSION_20) { |
| 757 GetCryptoStream()->flow_controller()->Disable(); |
| 758 headers_stream_->flow_controller()->Disable(); |
| 759 } |
744 for (DataStreamMap::iterator it = stream_map_.begin(); | 760 for (DataStreamMap::iterator it = stream_map_.begin(); |
745 it != stream_map_.end(); ++it) { | 761 it != stream_map_.end(); ++it) { |
746 if (version <= QUIC_VERSION_16) { | 762 if (version <= QUIC_VERSION_16) { |
747 it->second->flow_controller()->Disable(); | 763 it->second->flow_controller()->Disable(); |
748 } | 764 } |
749 } | 765 } |
750 } | 766 } |
751 | 767 |
752 } // namespace net | 768 } // namespace net |
OLD | NEW |