| 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_flow_controller.h" | 10 #include "net/quic/quic_flow_controller.h" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 void QuicSession::UpdateFlowControlOnFinalReceivedByteOffset( | 430 void QuicSession::UpdateFlowControlOnFinalReceivedByteOffset( |
| 431 QuicStreamId stream_id, QuicStreamOffset final_byte_offset) { | 431 QuicStreamId stream_id, QuicStreamOffset final_byte_offset) { |
| 432 map<QuicStreamId, QuicStreamOffset>::iterator it = | 432 map<QuicStreamId, QuicStreamOffset>::iterator it = |
| 433 locally_closed_streams_highest_offset_.find(stream_id); | 433 locally_closed_streams_highest_offset_.find(stream_id); |
| 434 if (it == locally_closed_streams_highest_offset_.end()) { | 434 if (it == locally_closed_streams_highest_offset_.end()) { |
| 435 return; | 435 return; |
| 436 } | 436 } |
| 437 | 437 |
| 438 DVLOG(1) << ENDPOINT << "Received final byte offset " << final_byte_offset | 438 DVLOG(1) << ENDPOINT << "Received final byte offset " << final_byte_offset |
| 439 << " for stream " << stream_id; | 439 << " for stream " << stream_id; |
| 440 uint64 offset_diff = final_byte_offset - it->second; | 440 QuicByteCount offset_diff = final_byte_offset - it->second; |
| 441 if (flow_controller_->UpdateHighestReceivedOffset( | 441 if (flow_controller_->UpdateHighestReceivedOffset( |
| 442 flow_controller_->highest_received_byte_offset() + offset_diff)) { | 442 flow_controller_->highest_received_byte_offset() + offset_diff)) { |
| 443 // If the final offset violates flow control, close the connection now. | 443 // If the final offset violates flow control, close the connection now. |
| 444 if (flow_controller_->FlowControlViolation()) { | 444 if (flow_controller_->FlowControlViolation()) { |
| 445 connection_->SendConnectionClose( | 445 connection_->SendConnectionClose( |
| 446 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA); | 446 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA); |
| 447 return; | 447 return; |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 | 450 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 476 static_cast<uint32>(max_streams * kMaxStreamsMultiplier)); | 476 static_cast<uint32>(max_streams * kMaxStreamsMultiplier)); |
| 477 } | 477 } |
| 478 set_max_open_streams(max_streams); | 478 set_max_open_streams(max_streams); |
| 479 | 479 |
| 480 if (version == QUIC_VERSION_19) { | 480 if (version == QUIC_VERSION_19) { |
| 481 // QUIC_VERSION_19 doesn't support independent stream/session flow | 481 // QUIC_VERSION_19 doesn't support independent stream/session flow |
| 482 // control windows. | 482 // control windows. |
| 483 if (config_.HasReceivedInitialFlowControlWindowBytes()) { | 483 if (config_.HasReceivedInitialFlowControlWindowBytes()) { |
| 484 // Streams which were created before the SHLO was received (0-RTT | 484 // Streams which were created before the SHLO was received (0-RTT |
| 485 // requests) are now informed of the peer's initial flow control window. | 485 // requests) are now informed of the peer's initial flow control window. |
| 486 uint32 new_window = config_.ReceivedInitialFlowControlWindowBytes(); | 486 QuicStreamOffset new_window = |
| 487 config_.ReceivedInitialFlowControlWindowBytes(); |
| 487 OnNewStreamFlowControlWindow(new_window); | 488 OnNewStreamFlowControlWindow(new_window); |
| 488 OnNewSessionFlowControlWindow(new_window); | 489 OnNewSessionFlowControlWindow(new_window); |
| 489 } | 490 } |
| 490 | 491 |
| 491 return; | 492 return; |
| 492 } | 493 } |
| 493 | 494 |
| 494 // QUIC_VERSION_21 and higher can have independent stream and session flow | 495 // QUIC_VERSION_21 and higher can have independent stream and session flow |
| 495 // control windows. | 496 // control windows. |
| 496 if (config_.HasReceivedInitialStreamFlowControlWindowBytes()) { | 497 if (config_.HasReceivedInitialStreamFlowControlWindowBytes()) { |
| 497 // Streams which were created before the SHLO was received (0-RTT | 498 // Streams which were created before the SHLO was received (0-RTT |
| 498 // requests) are now informed of the peer's initial flow control window. | 499 // requests) are now informed of the peer's initial flow control window. |
| 499 OnNewStreamFlowControlWindow( | 500 OnNewStreamFlowControlWindow( |
| 500 config_.ReceivedInitialStreamFlowControlWindowBytes()); | 501 config_.ReceivedInitialStreamFlowControlWindowBytes()); |
| 501 } | 502 } |
| 502 if (config_.HasReceivedInitialSessionFlowControlWindowBytes()) { | 503 if (config_.HasReceivedInitialSessionFlowControlWindowBytes()) { |
| 503 OnNewSessionFlowControlWindow( | 504 OnNewSessionFlowControlWindow( |
| 504 config_.ReceivedInitialSessionFlowControlWindowBytes()); | 505 config_.ReceivedInitialSessionFlowControlWindowBytes()); |
| 505 } | 506 } |
| 506 } | 507 } |
| 507 | 508 |
| 508 void QuicSession::OnNewStreamFlowControlWindow(uint32 new_window) { | 509 void QuicSession::OnNewStreamFlowControlWindow(QuicStreamOffset new_window) { |
| 509 if (new_window < kDefaultFlowControlSendWindow) { | 510 if (new_window < kDefaultFlowControlSendWindow) { |
| 510 LOG(ERROR) | 511 LOG(ERROR) |
| 511 << "Peer sent us an invalid stream flow control send window: " | 512 << "Peer sent us an invalid stream flow control send window: " |
| 512 << new_window << ", below default: " << kDefaultFlowControlSendWindow; | 513 << new_window << ", below default: " << kDefaultFlowControlSendWindow; |
| 513 if (connection_->connected()) { | 514 if (connection_->connected()) { |
| 514 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); | 515 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
| 515 } | 516 } |
| 516 return; | 517 return; |
| 517 } | 518 } |
| 518 | 519 |
| 519 // Inform all existing streams about the new window. | 520 // Inform all existing streams about the new window. |
| 520 if (connection_->version() >= QUIC_VERSION_21) { | 521 if (connection_->version() >= QUIC_VERSION_21) { |
| 521 GetCryptoStream()->UpdateSendWindowOffset(new_window); | 522 GetCryptoStream()->UpdateSendWindowOffset(new_window); |
| 522 headers_stream_->UpdateSendWindowOffset(new_window); | 523 headers_stream_->UpdateSendWindowOffset(new_window); |
| 523 } | 524 } |
| 524 for (DataStreamMap::iterator it = stream_map_.begin(); | 525 for (DataStreamMap::iterator it = stream_map_.begin(); |
| 525 it != stream_map_.end(); ++it) { | 526 it != stream_map_.end(); ++it) { |
| 526 it->second->UpdateSendWindowOffset(new_window); | 527 it->second->UpdateSendWindowOffset(new_window); |
| 527 } | 528 } |
| 528 } | 529 } |
| 529 | 530 |
| 530 void QuicSession::OnNewSessionFlowControlWindow(uint32 new_window) { | 531 void QuicSession::OnNewSessionFlowControlWindow(QuicStreamOffset new_window) { |
| 531 if (new_window < kDefaultFlowControlSendWindow) { | 532 if (new_window < kDefaultFlowControlSendWindow) { |
| 532 LOG(ERROR) | 533 LOG(ERROR) |
| 533 << "Peer sent us an invalid session flow control send window: " | 534 << "Peer sent us an invalid session flow control send window: " |
| 534 << new_window << ", below default: " << kDefaultFlowControlSendWindow; | 535 << new_window << ", below default: " << kDefaultFlowControlSendWindow; |
| 535 if (connection_->connected()) { | 536 if (connection_->connected()) { |
| 536 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); | 537 connection_->SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
| 537 } | 538 } |
| 538 return; | 539 return; |
| 539 } | 540 } |
| 540 | 541 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 for (DataStreamMap::iterator it = stream_map_.begin(); | 776 for (DataStreamMap::iterator it = stream_map_.begin(); |
| 776 it != stream_map_.end(); ++it) { | 777 it != stream_map_.end(); ++it) { |
| 777 if (it->second->flow_controller()->IsBlocked()) { | 778 if (it->second->flow_controller()->IsBlocked()) { |
| 778 return true; | 779 return true; |
| 779 } | 780 } |
| 780 } | 781 } |
| 781 return false; | 782 return false; |
| 782 } | 783 } |
| 783 | 784 |
| 784 } // namespace net | 785 } // namespace net |
| OLD | NEW |