| 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/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_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" | 9 #include "net/quic/quic_flags.h" |
| 10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 const int kDataSize = 16 * 1024; | 393 const int kDataSize = 16 * 1024; |
| 394 const string kData(kDataSize, 'a'); | 394 const string kData(kDataSize, 'a'); |
| 395 | 395 |
| 396 const int kFirstWriteSize = 100; | 396 const int kFirstWriteSize = 100; |
| 397 const int kSecondWriteSize = 50; | 397 const int kSecondWriteSize = 50; |
| 398 const int kLastWriteSize = kDataSize - kFirstWriteSize - kSecondWriteSize; | 398 const int kLastWriteSize = kDataSize - kFirstWriteSize - kSecondWriteSize; |
| 399 | 399 |
| 400 // Set a large flow control send window so this doesn't interfere with test. | 400 // Set a large flow control send window so this doesn't interfere with test. |
| 401 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 401 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
| 402 if (FLAGS_enable_quic_connection_flow_control) { | 402 if (FLAGS_enable_quic_connection_flow_control_2) { |
| 403 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 403 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
| 404 } | 404 } |
| 405 | 405 |
| 406 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; | 406 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; |
| 407 | 407 |
| 408 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) | 408 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) |
| 409 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( | 409 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( |
| 410 &SaveProxyAckNotifierDelegate, &proxy_delegate))), | 410 &SaveProxyAckNotifierDelegate, &proxy_delegate))), |
| 411 Return(QuicConsumedData(kFirstWriteSize, false)))); | 411 Return(QuicConsumedData(kFirstWriteSize, false)))); |
| 412 stream_->WriteOrBufferData(kData, false, delegate.get()); | 412 stream_->WriteOrBufferData(kData, false, delegate.get()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 scoped_refptr<MockAckNotifierDelegate> delegate( | 447 scoped_refptr<MockAckNotifierDelegate> delegate( |
| 448 new StrictMock<MockAckNotifierDelegate>); | 448 new StrictMock<MockAckNotifierDelegate>); |
| 449 | 449 |
| 450 const int kDataSize = 16 * 1024; | 450 const int kDataSize = 16 * 1024; |
| 451 const string kData(kDataSize, 'a'); | 451 const string kData(kDataSize, 'a'); |
| 452 | 452 |
| 453 const int kInitialWriteSize = 100; | 453 const int kInitialWriteSize = 100; |
| 454 | 454 |
| 455 // Set a large flow control send window so this doesn't interfere with test. | 455 // Set a large flow control send window so this doesn't interfere with test. |
| 456 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 456 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
| 457 if (FLAGS_enable_quic_connection_flow_control) { | 457 if (FLAGS_enable_quic_connection_flow_control_2) { |
| 458 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 458 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
| 459 } | 459 } |
| 460 | 460 |
| 461 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; | 461 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; |
| 462 | 462 |
| 463 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) | 463 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) |
| 464 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( | 464 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( |
| 465 &SaveProxyAckNotifierDelegate, &proxy_delegate))), | 465 &SaveProxyAckNotifierDelegate, &proxy_delegate))), |
| 466 Return(QuicConsumedData(kInitialWriteSize, false)))); | 466 Return(QuicConsumedData(kInitialWriteSize, false)))); |
| 467 stream_->WriteOrBufferData(kData, false, delegate.get()); | 467 stream_->WriteOrBufferData(kData, false, delegate.get()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 558 } |
| 559 | 559 |
| 560 // Verify that when we receive a packet which violates flow control (i.e. sends | 560 // Verify that when we receive a packet which violates flow control (i.e. sends |
| 561 // too much data on the stream) that the stream sequencer never sees this frame, | 561 // too much data on the stream) that the stream sequencer never sees this frame, |
| 562 // as we check for violation and close the connection early. | 562 // as we check for violation and close the connection early. |
| 563 TEST_F(ReliableQuicStreamTest, | 563 TEST_F(ReliableQuicStreamTest, |
| 564 StreamSequencerNeverSeesPacketsViolatingFlowControl) { | 564 StreamSequencerNeverSeesPacketsViolatingFlowControl) { |
| 565 ValueRestore<bool> old_stream_flag( | 565 ValueRestore<bool> old_stream_flag( |
| 566 &FLAGS_enable_quic_stream_flow_control_2, true); | 566 &FLAGS_enable_quic_stream_flow_control_2, true); |
| 567 ValueRestore<bool> old_connection_flag( | 567 ValueRestore<bool> old_connection_flag( |
| 568 &FLAGS_enable_quic_connection_flow_control, true); | 568 &FLAGS_enable_quic_connection_flow_control_2, true); |
| 569 | 569 |
| 570 Initialize(kShouldProcessData); | 570 Initialize(kShouldProcessData); |
| 571 | 571 |
| 572 // Receive a stream frame that violates flow control: the byte offset is | 572 // Receive a stream frame that violates flow control: the byte offset is |
| 573 // higher than the receive window offset. | 573 // higher than the receive window offset. |
| 574 QuicStreamFrame frame(stream_->id(), false, | 574 QuicStreamFrame frame(stream_->id(), false, |
| 575 kInitialFlowControlWindowForTest + 1, | 575 kInitialFlowControlWindowForTest + 1, |
| 576 MakeIOVector(".")); | 576 MakeIOVector(".")); |
| 577 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( | 577 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( |
| 578 stream_->flow_controller())); | 578 stream_->flow_controller())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 604 | 604 |
| 605 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); | 605 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
| 606 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); | 606 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); |
| 607 stream_->OnStreamReset(rst_frame); | 607 stream_->OnStreamReset(rst_frame); |
| 608 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 608 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 609 } | 609 } |
| 610 | 610 |
| 611 } // namespace | 611 } // namespace |
| 612 } // namespace test | 612 } // namespace test |
| 613 } // namespace net | 613 } // namespace net |
| OLD | NEW |