| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 : connection_(connection), | 104 : connection_(connection), |
| 105 visitor_shim_(new VisitorShim(this)), | 105 visitor_shim_(new VisitorShim(this)), |
| 106 config_(config), | 106 config_(config), |
| 107 max_open_streams_(config_.MaxStreamsPerConnection()), | 107 max_open_streams_(config_.MaxStreamsPerConnection()), |
| 108 next_stream_id_(is_server() ? 2 : 5), | 108 next_stream_id_(is_server() ? 2 : 5), |
| 109 largest_peer_created_stream_id_(0), | 109 largest_peer_created_stream_id_(0), |
| 110 error_(QUIC_NO_ERROR), | 110 error_(QUIC_NO_ERROR), |
| 111 goaway_received_(false), | 111 goaway_received_(false), |
| 112 goaway_sent_(false), | 112 goaway_sent_(false), |
| 113 has_pending_handshake_(false) { | 113 has_pending_handshake_(false) { |
| 114 if (connection_->version() <= QUIC_VERSION_19) { | 114 if (connection_->version() == QUIC_VERSION_19) { |
| 115 flow_controller_.reset(new QuicFlowController( | 115 flow_controller_.reset(new QuicFlowController( |
| 116 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, | 116 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
| 117 config_.GetInitialFlowControlWindowToSend(), | 117 config_.GetInitialFlowControlWindowToSend(), |
| 118 config_.GetInitialFlowControlWindowToSend())); | 118 config_.GetInitialFlowControlWindowToSend())); |
| 119 } else { | 119 } else { |
| 120 flow_controller_.reset(new QuicFlowController( | 120 flow_controller_.reset(new QuicFlowController( |
| 121 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, | 121 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
| 122 config_.GetInitialSessionFlowControlWindowToSend(), | 122 config_.GetInitialSessionFlowControlWindowToSend(), |
| 123 config_.GetInitialSessionFlowControlWindowToSend())); | 123 config_.GetInitialSessionFlowControlWindowToSend())); |
| 124 } | 124 } |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 // when FIN/RSTs for old streams are lost or arrive out of order. | 480 // when FIN/RSTs for old streams are lost or arrive out of order. |
| 481 // Use a minimum number of additional streams, or a percentage increase, | 481 // Use a minimum number of additional streams, or a percentage increase, |
| 482 // whichever is larger. | 482 // whichever is larger. |
| 483 max_streams = | 483 max_streams = |
| 484 max(max_streams + kMaxStreamsMinimumIncrement, | 484 max(max_streams + kMaxStreamsMinimumIncrement, |
| 485 static_cast<uint32>(max_streams * kMaxStreamsMultiplier)); | 485 static_cast<uint32>(max_streams * kMaxStreamsMultiplier)); |
| 486 } | 486 } |
| 487 set_max_open_streams(max_streams); | 487 set_max_open_streams(max_streams); |
| 488 } | 488 } |
| 489 | 489 |
| 490 if (version <= QUIC_VERSION_19) { | 490 if (version == QUIC_VERSION_19) { |
| 491 // QUIC_VERSION_17,18,19 don't support independent stream/session flow | 491 // QUIC_VERSION_19 doesn't support independent stream/session flow |
| 492 // control windows. | 492 // control windows. |
| 493 if (config_.HasReceivedInitialFlowControlWindowBytes()) { | 493 if (config_.HasReceivedInitialFlowControlWindowBytes()) { |
| 494 // Streams which were created before the SHLO was received (0-RTT | 494 // Streams which were created before the SHLO was received (0-RTT |
| 495 // requests) are now informed of the peer's initial flow control window. | 495 // requests) are now informed of the peer's initial flow control window. |
| 496 uint32 new_window = config_.ReceivedInitialFlowControlWindowBytes(); | 496 uint32 new_window = config_.ReceivedInitialFlowControlWindowBytes(); |
| 497 OnNewStreamFlowControlWindow(new_window); | 497 OnNewStreamFlowControlWindow(new_window); |
| 498 OnNewSessionFlowControlWindow(new_window); | 498 OnNewSessionFlowControlWindow(new_window); |
| 499 } | 499 } |
| 500 | 500 |
| 501 return; | 501 return; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 763 |
| 764 if (FLAGS_close_quic_connection_unfinished_streams_2 && | 764 if (FLAGS_close_quic_connection_unfinished_streams_2 && |
| 765 connection()->connected() && | 765 connection()->connected() && |
| 766 locally_closed_streams_highest_offset_.size() > max_open_streams_) { | 766 locally_closed_streams_highest_offset_.size() > max_open_streams_) { |
| 767 // A buggy client may fail to send FIN/RSTs. Don't tolerate this. | 767 // A buggy client may fail to send FIN/RSTs. Don't tolerate this. |
| 768 connection_->SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS); | 768 connection_->SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS); |
| 769 } | 769 } |
| 770 } | 770 } |
| 771 | 771 |
| 772 void QuicSession::OnSuccessfulVersionNegotiation(const QuicVersion& version) { | 772 void QuicSession::OnSuccessfulVersionNegotiation(const QuicVersion& version) { |
| 773 if (version < QUIC_VERSION_19) { | |
| 774 flow_controller_->Disable(); | |
| 775 } | |
| 776 | |
| 777 // Disable stream level flow control based on negotiated version. Streams may | 773 // Disable stream level flow control based on negotiated version. Streams may |
| 778 // have been created with a different version. | 774 // have been created with a different version. |
| 779 if (version < QUIC_VERSION_21) { | 775 if (version < QUIC_VERSION_21) { |
| 780 GetCryptoStream()->flow_controller()->Disable(); | 776 GetCryptoStream()->flow_controller()->Disable(); |
| 781 headers_stream_->flow_controller()->Disable(); | 777 headers_stream_->flow_controller()->Disable(); |
| 782 } | 778 } |
| 783 } | 779 } |
| 784 | 780 |
| 785 bool QuicSession::IsConnectionFlowControlBlocked() const { | 781 bool QuicSession::IsConnectionFlowControlBlocked() const { |
| 786 return flow_controller_->IsBlocked(); | 782 return flow_controller_->IsBlocked(); |
| 787 } | 783 } |
| 788 | 784 |
| 789 bool QuicSession::IsStreamFlowControlBlocked() { | 785 bool QuicSession::IsStreamFlowControlBlocked() { |
| 790 if (headers_stream_->flow_controller()->IsBlocked() || | 786 if (headers_stream_->flow_controller()->IsBlocked() || |
| 791 GetCryptoStream()->flow_controller()->IsBlocked()) { | 787 GetCryptoStream()->flow_controller()->IsBlocked()) { |
| 792 return true; | 788 return true; |
| 793 } | 789 } |
| 794 for (DataStreamMap::iterator it = stream_map_.begin(); | 790 for (DataStreamMap::iterator it = stream_map_.begin(); |
| 795 it != stream_map_.end(); ++it) { | 791 it != stream_map_.end(); ++it) { |
| 796 if (it->second->flow_controller()->IsBlocked()) { | 792 if (it->second->flow_controller()->IsBlocked()) { |
| 797 return true; | 793 return true; |
| 798 } | 794 } |
| 799 } | 795 } |
| 800 return false; | 796 return false; |
| 801 } | 797 } |
| 802 | 798 |
| 803 } // namespace net | 799 } // namespace net |
| OLD | NEW |