| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 return GetCryptoStream()->handshake_confirmed(); | 460 return GetCryptoStream()->handshake_confirmed(); |
| 461 } | 461 } |
| 462 | 462 |
| 463 void QuicSession::OnConfigNegotiated() { | 463 void QuicSession::OnConfigNegotiated() { |
| 464 connection_->SetFromConfig(config_); | 464 connection_->SetFromConfig(config_); |
| 465 // Tell all streams about the newly received peer receive window. | 465 // Tell all streams about the newly received peer receive window. |
| 466 if (connection()->version() >= QUIC_VERSION_17 && | 466 if (connection()->version() >= QUIC_VERSION_17 && |
| 467 config_.HasReceivedInitialFlowControlWindowBytes()) { | 467 config_.HasReceivedInitialFlowControlWindowBytes()) { |
| 468 // Streams which were created before the SHLO was received (0RTT requests) | 468 // Streams which were created before the SHLO was received (0RTT requests) |
| 469 // are now informed of the peer's initial flow control window. | 469 // are now informed of the peer's initial flow control window. |
| 470 uint32 new_flow_control_send_window = | 470 uint32 new_window = config_.ReceivedInitialFlowControlWindowBytes(); |
| 471 config_.ReceivedInitialFlowControlWindowBytes(); | 471 OnNewStreamFlowControlWindow(new_window); |
| 472 if (new_flow_control_send_window < kDefaultFlowControlSendWindow) { | 472 OnNewSessionFlowControlWindow(new_window); |
| 473 LOG(ERROR) | 473 } |
| 474 << "Peer sent us an invalid flow control send window: " | 474 } |
| 475 << new_flow_control_send_window | 475 |
| 476 << ", below default: " << kDefaultFlowControlSendWindow; | 476 void QuicSession::OnNewStreamFlowControlWindow(uint32 new_window) { |
| 477 if (new_window < kDefaultFlowControlSendWindow) { |
| 478 LOG(ERROR) |
| 479 << "Peer sent us an invalid stream flow control send window: " |
| 480 << new_window << ", below default: " << kDefaultFlowControlSendWindow; |
| 481 if (connection_->connected()) { |
| 477 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); | 482 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
| 478 return; | |
| 479 } | 483 } |
| 480 DataStreamMap::iterator it = stream_map_.begin(); | 484 return; |
| 481 while (it != stream_map_.end()) { | 485 } |
| 482 it->second->flow_controller()->UpdateSendWindowOffset( | 486 |
| 483 new_flow_control_send_window); | 487 DataStreamMap::iterator it = stream_map_.begin(); |
| 484 it++; | 488 while (it != stream_map_.end()) { |
| 489 it->second->flow_controller()->UpdateSendWindowOffset(new_window); |
| 490 it++; |
| 491 } |
| 492 } |
| 493 |
| 494 void QuicSession::OnNewSessionFlowControlWindow(uint32 new_window) { |
| 495 if (new_window < kDefaultFlowControlSendWindow) { |
| 496 LOG(ERROR) |
| 497 << "Peer sent us an invalid session flow control send window: " |
| 498 << new_window << ", below default: " << kDefaultFlowControlSendWindow; |
| 499 if (connection_->connected()) { |
| 500 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
| 485 } | 501 } |
| 502 return; |
| 503 } |
| 486 | 504 |
| 487 // Update connection level window. | 505 flow_controller_->UpdateSendWindowOffset(new_window); |
| 488 flow_controller_->UpdateSendWindowOffset(new_flow_control_send_window); | |
| 489 } | |
| 490 } | 506 } |
| 491 | 507 |
| 492 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { | 508 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { |
| 493 switch (event) { | 509 switch (event) { |
| 494 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter | 510 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter |
| 495 // to QuicSession since it is the glue. | 511 // to QuicSession since it is the glue. |
| 496 case ENCRYPTION_FIRST_ESTABLISHED: | 512 case ENCRYPTION_FIRST_ESTABLISHED: |
| 497 break; | 513 break; |
| 498 | 514 |
| 499 case ENCRYPTION_REESTABLISHED: | 515 case ENCRYPTION_REESTABLISHED: |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // with a different version. | 716 // with a different version. |
| 701 for (DataStreamMap::iterator it = stream_map_.begin(); | 717 for (DataStreamMap::iterator it = stream_map_.begin(); |
| 702 it != stream_map_.end(); ++it) { | 718 it != stream_map_.end(); ++it) { |
| 703 if (version < QUIC_VERSION_17) { | 719 if (version < QUIC_VERSION_17) { |
| 704 it->second->flow_controller()->Disable(); | 720 it->second->flow_controller()->Disable(); |
| 705 } | 721 } |
| 706 } | 722 } |
| 707 } | 723 } |
| 708 | 724 |
| 709 } // namespace net | 725 } // namespace net |
| OLD | NEW |