| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_data_stream.h" | 5 #include "net/quic/quic_data_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/quic_ack_notifier.h" | 7 #include "net/quic/quic_ack_notifier.h" |
| 8 #include "net/quic/quic_connection.h" | 8 #include "net/quic/quic_connection.h" |
| 9 #include "net/quic/quic_flags.h" | |
| 10 #include "net/quic/quic_utils.h" | 9 #include "net/quic/quic_utils.h" |
| 11 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
| 12 #include "net/quic/spdy_utils.h" | 11 #include "net/quic/spdy_utils.h" |
| 13 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 12 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
| 14 #include "net/quic/test_tools/quic_session_peer.h" | 13 #include "net/quic/test_tools/quic_session_peer.h" |
| 15 #include "net/quic/test_tools/quic_test_utils.h" | 14 #include "net/quic/test_tools/quic_test_utils.h" |
| 16 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 15 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 17 #include "net/test/gtest_util.h" | 16 #include "net/test/gtest_util.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 19 | 18 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 stream_->flow_controller())); | 410 stream_->flow_controller())); |
| 412 } | 411 } |
| 413 | 412 |
| 414 TEST_P(QuicDataStreamTest, ConnectionFlowControlWindowUpdate) { | 413 TEST_P(QuicDataStreamTest, ConnectionFlowControlWindowUpdate) { |
| 415 // Tests that on receipt of data, the connection updates its receive window | 414 // Tests that on receipt of data, the connection updates its receive window |
| 416 // offset appropriately, and sends WINDOW_UPDATE frames when its receive | 415 // offset appropriately, and sends WINDOW_UPDATE frames when its receive |
| 417 // window drops too low. | 416 // window drops too low. |
| 418 if (GetParam() < QUIC_VERSION_19) { | 417 if (GetParam() < QUIC_VERSION_19) { |
| 419 return; | 418 return; |
| 420 } | 419 } |
| 421 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2, | |
| 422 true); | |
| 423 | |
| 424 Initialize(kShouldProcessData); | 420 Initialize(kShouldProcessData); |
| 425 | 421 |
| 426 // Set a small flow control limit for streams and connection. | 422 // Set a small flow control limit for streams and connection. |
| 427 const uint64 kWindow = 36; | 423 const uint64 kWindow = 36; |
| 428 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), | 424 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
| 429 kWindow); | 425 kWindow); |
| 430 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), | 426 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), |
| 431 kWindow); | 427 kWindow); |
| 432 QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_->flow_controller(), | 428 QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_->flow_controller(), |
| 433 kWindow); | 429 kWindow); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 stream_->OnStreamFrame(frame); | 494 stream_->OnStreamFrame(frame); |
| 499 } | 495 } |
| 500 | 496 |
| 501 TEST_P(QuicDataStreamTest, ConnectionFlowControlViolation) { | 497 TEST_P(QuicDataStreamTest, ConnectionFlowControlViolation) { |
| 502 // Tests that on if the peer sends too much data (i.e. violates the flow | 498 // Tests that on if the peer sends too much data (i.e. violates the flow |
| 503 // control protocol), at the connection level (rather than the stream level) | 499 // control protocol), at the connection level (rather than the stream level) |
| 504 // then we terminate the connection. | 500 // then we terminate the connection. |
| 505 if (GetParam() < QUIC_VERSION_19) { | 501 if (GetParam() < QUIC_VERSION_19) { |
| 506 return; | 502 return; |
| 507 } | 503 } |
| 508 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2, | |
| 509 true); | |
| 510 | 504 |
| 511 // Stream should not process data, so that data gets buffered in the | 505 // Stream should not process data, so that data gets buffered in the |
| 512 // sequencer, triggering flow control limits. | 506 // sequencer, triggering flow control limits. |
| 513 Initialize(!kShouldProcessData); | 507 Initialize(!kShouldProcessData); |
| 514 | 508 |
| 515 // Set a small flow control window on streams, and connection. | 509 // Set a small flow control window on streams, and connection. |
| 516 const uint64 kStreamWindow = 50; | 510 const uint64 kStreamWindow = 50; |
| 517 const uint64 kConnectionWindow = 10; | 511 const uint64 kConnectionWindow = 10; |
| 518 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), | 512 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
| 519 kStreamWindow); | 513 kStreamWindow); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0); | 551 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0); |
| 558 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) | 552 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) |
| 559 .WillOnce(Return(QuicConsumedData(0, fin))); | 553 .WillOnce(Return(QuicConsumedData(0, fin))); |
| 560 | 554 |
| 561 stream_->WriteOrBufferData(body, fin, NULL); | 555 stream_->WriteOrBufferData(body, fin, NULL); |
| 562 } | 556 } |
| 563 | 557 |
| 564 } // namespace | 558 } // namespace |
| 565 } // namespace test | 559 } // namespace test |
| 566 } // namespace net | 560 } // namespace net |
| OLD | NEW |