| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 : connection_(connection), | 99 : connection_(connection), |
| 100 visitor_shim_(new VisitorShim(this)), | 100 visitor_shim_(new VisitorShim(this)), |
| 101 config_(config), | 101 config_(config), |
| 102 max_open_streams_(config_.max_streams_per_connection()), | 102 max_open_streams_(config_.max_streams_per_connection()), |
| 103 next_stream_id_(is_server() ? 2 : 3), | 103 next_stream_id_(is_server() ? 2 : 3), |
| 104 largest_peer_created_stream_id_(0), | 104 largest_peer_created_stream_id_(0), |
| 105 error_(QUIC_NO_ERROR), | 105 error_(QUIC_NO_ERROR), |
| 106 goaway_received_(false), | 106 goaway_received_(false), |
| 107 goaway_sent_(false), | 107 goaway_sent_(false), |
| 108 has_pending_handshake_(false) { | 108 has_pending_handshake_(false) { |
| 109 flow_controller_.reset(new QuicFlowController( | 109 if (connection_->version() <= QUIC_VERSION_19) { |
| 110 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, | 110 flow_controller_.reset(new QuicFlowController( |
| 111 config_.GetInitialFlowControlWindowToSend(), | 111 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
| 112 config_.GetInitialFlowControlWindowToSend())); | 112 config_.GetInitialFlowControlWindowToSend(), |
| 113 config_.GetInitialFlowControlWindowToSend())); |
| 114 } else { |
| 115 flow_controller_.reset(new QuicFlowController( |
| 116 connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow, |
| 117 config_.GetInitialSessionFlowControlWindowToSend(), |
| 118 config_.GetInitialSessionFlowControlWindowToSend())); |
| 119 } |
| 113 | 120 |
| 114 connection_->set_visitor(visitor_shim_.get()); | 121 connection_->set_visitor(visitor_shim_.get()); |
| 115 connection_->SetFromConfig(config_); | 122 connection_->SetFromConfig(config_); |
| 116 if (connection_->connected()) { | 123 if (connection_->connected()) { |
| 117 connection_->SetOverallConnectionTimeout( | 124 connection_->SetOverallConnectionTimeout( |
| 118 config_.max_time_before_crypto_handshake()); | 125 config_.max_time_before_crypto_handshake()); |
| 119 } | 126 } |
| 120 headers_stream_.reset(new QuicHeadersStream(this)); | 127 headers_stream_.reset(new QuicHeadersStream(this)); |
| 121 if (!is_server()) { | 128 if (!is_server()) { |
| 122 // For version above QUIC v12, the headers stream is stream 3, so the | 129 // For version above QUIC v12, the headers stream is stream 3, so the |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 bool QuicSession::IsEncryptionEstablished() { | 461 bool QuicSession::IsEncryptionEstablished() { |
| 455 return GetCryptoStream()->encryption_established(); | 462 return GetCryptoStream()->encryption_established(); |
| 456 } | 463 } |
| 457 | 464 |
| 458 bool QuicSession::IsCryptoHandshakeConfirmed() { | 465 bool QuicSession::IsCryptoHandshakeConfirmed() { |
| 459 return GetCryptoStream()->handshake_confirmed(); | 466 return GetCryptoStream()->handshake_confirmed(); |
| 460 } | 467 } |
| 461 | 468 |
| 462 void QuicSession::OnConfigNegotiated() { | 469 void QuicSession::OnConfigNegotiated() { |
| 463 connection_->SetFromConfig(config_); | 470 connection_->SetFromConfig(config_); |
| 464 // Tell all streams about the newly received peer receive window. | 471 QuicVersion version = connection()->version(); |
| 465 if (connection()->version() >= QUIC_VERSION_17 && | 472 if (version < QUIC_VERSION_17) { |
| 466 config_.HasReceivedInitialFlowControlWindowBytes()) { | 473 return; |
| 467 // Streams which were created before the SHLO was received (0RTT requests) | 474 } |
| 468 // are now informed of the peer's initial flow control window. | 475 |
| 469 uint32 new_window = config_.ReceivedInitialFlowControlWindowBytes(); | 476 if (version <= QUIC_VERSION_19) { |
| 470 OnNewStreamFlowControlWindow(new_window); | 477 // QUIC_VERSION_17,18,19 don't support independent stream/session flow |
| 471 OnNewSessionFlowControlWindow(new_window); | 478 // control windows. |
| 479 if (config_.HasReceivedInitialFlowControlWindowBytes()) { |
| 480 // Streams which were created before the SHLO was received (0-RTT |
| 481 // requests) are now informed of the peer's initial flow control window. |
| 482 uint32 new_window = config_.ReceivedInitialFlowControlWindowBytes(); |
| 483 OnNewStreamFlowControlWindow(new_window); |
| 484 OnNewSessionFlowControlWindow(new_window); |
| 485 } |
| 486 |
| 487 return; |
| 488 } |
| 489 |
| 490 // QUIC_VERSION_20 and higher can have independent stream and session flow |
| 491 // control windows. |
| 492 if (config_.HasReceivedInitialStreamFlowControlWindowBytes()) { |
| 493 // Streams which were created before the SHLO was received (0-RTT |
| 494 // requests) are now informed of the peer's initial flow control window. |
| 495 OnNewStreamFlowControlWindow( |
| 496 config_.ReceivedInitialStreamFlowControlWindowBytes()); |
| 497 } |
| 498 if (config_.HasReceivedInitialSessionFlowControlWindowBytes()) { |
| 499 OnNewSessionFlowControlWindow( |
| 500 config_.ReceivedInitialSessionFlowControlWindowBytes()); |
| 472 } | 501 } |
| 473 } | 502 } |
| 474 | 503 |
| 475 void QuicSession::OnNewStreamFlowControlWindow(uint32 new_window) { | 504 void QuicSession::OnNewStreamFlowControlWindow(uint32 new_window) { |
| 476 if (new_window < kDefaultFlowControlSendWindow) { | 505 if (new_window < kDefaultFlowControlSendWindow) { |
| 477 LOG(ERROR) | 506 LOG(ERROR) |
| 478 << "Peer sent us an invalid stream flow control send window: " | 507 << "Peer sent us an invalid stream flow control send window: " |
| 479 << new_window << ", below default: " << kDefaultFlowControlSendWindow; | 508 << new_window << ", below default: " << kDefaultFlowControlSendWindow; |
| 480 if (connection_->connected()) { | 509 if (connection_->connected()) { |
| 481 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); | 510 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 // with a different version. | 743 // with a different version. |
| 715 for (DataStreamMap::iterator it = stream_map_.begin(); | 744 for (DataStreamMap::iterator it = stream_map_.begin(); |
| 716 it != stream_map_.end(); ++it) { | 745 it != stream_map_.end(); ++it) { |
| 717 if (version < QUIC_VERSION_17) { | 746 if (version < QUIC_VERSION_17) { |
| 718 it->second->flow_controller()->Disable(); | 747 it->second->flow_controller()->Disable(); |
| 719 } | 748 } |
| 720 } | 749 } |
| 721 } | 750 } |
| 722 | 751 |
| 723 } // namespace net | 752 } // namespace net |
| OLD | NEW |