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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 EXPECT_TRUE(rst_sent()); | 388 EXPECT_TRUE(rst_sent()); |
389 | 389 |
390 // Now close the stream (any further resets being sent would break the | 390 // Now close the stream (any further resets being sent would break the |
391 // expectation above). | 391 // expectation above). |
392 stream_->OnClose(); | 392 stream_->OnClose(); |
393 EXPECT_FALSE(fin_sent()); | 393 EXPECT_FALSE(fin_sent()); |
394 EXPECT_TRUE(rst_sent()); | 394 EXPECT_TRUE(rst_sent()); |
395 } | 395 } |
396 | 396 |
397 TEST_F(ReliableQuicStreamTest, StreamFlowControlMultipleWindowUpdates) { | 397 TEST_F(ReliableQuicStreamTest, StreamFlowControlMultipleWindowUpdates) { |
398 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); | |
399 set_initial_flow_control_window_bytes(1000); | 398 set_initial_flow_control_window_bytes(1000); |
400 | 399 |
401 Initialize(kShouldProcessData); | 400 Initialize(kShouldProcessData); |
402 | 401 |
403 // If we receive multiple WINDOW_UPDATES (potentially out of order), then we | 402 // If we receive multiple WINDOW_UPDATES (potentially out of order), then we |
404 // want to make sure we latch the largest offset we see. | 403 // want to make sure we latch the largest offset we see. |
405 | 404 |
406 // Initially should be default. | 405 // Initially should be default. |
407 EXPECT_EQ( | 406 EXPECT_EQ( |
408 initial_flow_control_window_bytes_, | 407 initial_flow_control_window_bytes_, |
(...skipping 15 matching lines...) Expand all Loading... |
424 stream_->OnWindowUpdateFrame(window_update_3); | 423 stream_->OnWindowUpdateFrame(window_update_3); |
425 stream_->OnWindowUpdateFrame(window_update_4); | 424 stream_->OnWindowUpdateFrame(window_update_4); |
426 EXPECT_EQ( | 425 EXPECT_EQ( |
427 window_update_3.byte_offset, | 426 window_update_3.byte_offset, |
428 QuicFlowControllerPeer::SendWindowOffset(stream_->flow_controller())); | 427 QuicFlowControllerPeer::SendWindowOffset(stream_->flow_controller())); |
429 } | 428 } |
430 | 429 |
431 TEST_F(ReliableQuicStreamTest, StreamFlowControlShouldNotBlockInLessThanQ017) { | 430 TEST_F(ReliableQuicStreamTest, StreamFlowControlShouldNotBlockInLessThanQ017) { |
432 // TODO(rjshade): Remove this test when we no longer have any versions < | 431 // TODO(rjshade): Remove this test when we no longer have any versions < |
433 // QUIC_VERSION_17. | 432 // QUIC_VERSION_17. |
434 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); | |
435 | 433 |
436 // Make sure we are using a version which does not support flow control. | 434 // Make sure we are using a version which does not support flow control. |
437 QuicVersion kTestQuicVersions[] = {QUIC_VERSION_16}; | 435 QuicVersion kTestQuicVersions[] = {QUIC_VERSION_16}; |
438 QuicVersionVector versions; | 436 QuicVersionVector versions; |
439 for (size_t i = 0; i < arraysize(kTestQuicVersions); ++i) { | 437 for (size_t i = 0; i < arraysize(kTestQuicVersions); ++i) { |
440 versions.push_back(kTestQuicVersions[i]); | 438 versions.push_back(kTestQuicVersions[i]); |
441 } | 439 } |
442 set_supported_versions(versions); | 440 set_supported_versions(versions); |
443 | 441 |
444 // Peer is not talking QUIC_VERSION_17 so assumes that it can send a zero | 442 // Peer is not talking QUIC_VERSION_17 so assumes that it can send a zero |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); | 627 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); |
630 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); | 628 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); |
631 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); | 629 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); |
632 } | 630 } |
633 | 631 |
634 // Verify that when we receive a packet which violates flow control (i.e. sends | 632 // Verify that when we receive a packet which violates flow control (i.e. sends |
635 // too much data on the stream) that the stream sequencer never sees this frame, | 633 // too much data on the stream) that the stream sequencer never sees this frame, |
636 // as we check for violation and close the connection early. | 634 // as we check for violation and close the connection early. |
637 TEST_F(ReliableQuicStreamTest, | 635 TEST_F(ReliableQuicStreamTest, |
638 StreamSequencerNeverSeesPacketsViolatingFlowControl) { | 636 StreamSequencerNeverSeesPacketsViolatingFlowControl) { |
639 ValueRestore<bool> old_stream_flag( | |
640 &FLAGS_enable_quic_stream_flow_control_2, true); | |
641 ValueRestore<bool> old_connection_flag( | 637 ValueRestore<bool> old_connection_flag( |
642 &FLAGS_enable_quic_connection_flow_control_2, true); | 638 &FLAGS_enable_quic_connection_flow_control_2, true); |
643 | 639 |
644 Initialize(kShouldProcessData); | 640 Initialize(kShouldProcessData); |
645 | 641 |
646 // Receive a stream frame that violates flow control: the byte offset is | 642 // Receive a stream frame that violates flow control: the byte offset is |
647 // higher than the receive window offset. | 643 // higher than the receive window offset. |
648 QuicStreamFrame frame(stream_->id(), false, | 644 QuicStreamFrame frame(stream_->id(), false, |
649 kInitialSessionFlowControlWindowForTest + 1, | 645 kInitialSessionFlowControlWindowForTest + 1, |
650 MakeIOVector(".")); | 646 MakeIOVector(".")); |
(...skipping 27 matching lines...) Expand all Loading... |
678 | 674 |
679 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); | 675 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
680 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); | 676 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); |
681 stream_->OnStreamReset(rst_frame); | 677 stream_->OnStreamReset(rst_frame); |
682 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 678 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
683 } | 679 } |
684 | 680 |
685 } // namespace | 681 } // namespace |
686 } // namespace test | 682 } // namespace test |
687 } // namespace net | 683 } // namespace net |
OLD | NEW |