| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 void Initialize(bool stream_should_process_data) { | 112 void Initialize(bool stream_should_process_data) { |
| 113 connection_ = | 113 connection_ = |
| 114 new StrictMock<MockConnection>(kIsServer, supported_versions_); | 114 new StrictMock<MockConnection>(kIsServer, supported_versions_); |
| 115 session_.reset(new StrictMock<MockSession>(connection_)); | 115 session_.reset(new StrictMock<MockSession>(connection_)); |
| 116 | 116 |
| 117 // New streams rely on having the peer's flow control receive window | 117 // New streams rely on having the peer's flow control receive window |
| 118 // negotiated in the config. | 118 // negotiated in the config. |
| 119 QuicConfigPeer::SetReceivedInitialFlowControlWindow( | 119 QuicConfigPeer::SetReceivedInitialFlowControlWindow( |
| 120 session_->config(), initial_flow_control_window_bytes_); | 120 session_->config(), initial_flow_control_window_bytes_); |
| 121 QuicConfigPeer::SetReceivedInitialStreamFlowControlWindow( |
| 122 session_->config(), initial_flow_control_window_bytes_); |
| 121 | 123 |
| 122 stream_.reset(new TestStream(kHeadersStreamId, session_.get(), | 124 stream_.reset(new TestStream(kHeadersStreamId, session_.get(), |
| 123 stream_should_process_data)); | 125 stream_should_process_data)); |
| 124 write_blocked_list_ = | 126 write_blocked_list_ = |
| 125 QuicSessionPeer::GetWriteBlockedStreams(session_.get()); | 127 QuicSessionPeer::GetWriteBlockedStreams(session_.get()); |
| 126 } | 128 } |
| 127 | 129 |
| 128 bool fin_sent() { return ReliableQuicStreamPeer::FinSent(stream_.get()); } | 130 bool fin_sent() { return ReliableQuicStreamPeer::FinSent(stream_.get()); } |
| 129 bool rst_sent() { return ReliableQuicStreamPeer::RstSent(stream_.get()); } | 131 bool rst_sent() { return ReliableQuicStreamPeer::RstSent(stream_.get()); } |
| 130 | 132 |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 ValueRestore<bool> old_stream_flag( | 639 ValueRestore<bool> old_stream_flag( |
| 638 &FLAGS_enable_quic_stream_flow_control_2, true); | 640 &FLAGS_enable_quic_stream_flow_control_2, true); |
| 639 ValueRestore<bool> old_connection_flag( | 641 ValueRestore<bool> old_connection_flag( |
| 640 &FLAGS_enable_quic_connection_flow_control_2, true); | 642 &FLAGS_enable_quic_connection_flow_control_2, true); |
| 641 | 643 |
| 642 Initialize(kShouldProcessData); | 644 Initialize(kShouldProcessData); |
| 643 | 645 |
| 644 // Receive a stream frame that violates flow control: the byte offset is | 646 // Receive a stream frame that violates flow control: the byte offset is |
| 645 // higher than the receive window offset. | 647 // higher than the receive window offset. |
| 646 QuicStreamFrame frame(stream_->id(), false, | 648 QuicStreamFrame frame(stream_->id(), false, |
| 647 kInitialFlowControlWindowForTest + 1, | 649 kInitialSessionFlowControlWindowForTest + 1, |
| 648 MakeIOVector(".")); | 650 MakeIOVector(".")); |
| 649 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( | 651 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( |
| 650 stream_->flow_controller())); | 652 stream_->flow_controller())); |
| 651 | 653 |
| 652 // Stream should not accept the frame, and the connection should be closed. | 654 // Stream should not accept the frame, and the connection should be closed. |
| 653 EXPECT_CALL(*connection_, | 655 EXPECT_CALL(*connection_, |
| 654 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); | 656 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); |
| 655 EXPECT_FALSE(stream_->OnStreamFrame(frame)); | 657 EXPECT_FALSE(stream_->OnStreamFrame(frame)); |
| 656 } | 658 } |
| 657 | 659 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 676 | 678 |
| 677 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); | 679 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
| 678 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); | 680 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); |
| 679 stream_->OnStreamReset(rst_frame); | 681 stream_->OnStreamReset(rst_frame); |
| 680 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 682 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 681 } | 683 } |
| 682 | 684 |
| 683 } // namespace | 685 } // namespace |
| 684 } // namespace test | 686 } // namespace test |
| 685 } // namespace net | 687 } // namespace net |
| OLD | NEW |