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/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 EXPECT_CALL(*stream2, OnCanWrite()) | 487 EXPECT_CALL(*stream2, OnCanWrite()) |
488 .WillOnce(DoAll(testing::IgnoreResult(Invoke(CreateFunctor( | 488 .WillOnce(DoAll(testing::IgnoreResult(Invoke(CreateFunctor( |
489 &TestSession::SendLargeFakeData, | 489 &TestSession::SendLargeFakeData, |
490 base::Unretained(&session_), stream2, 6000))), | 490 base::Unretained(&session_), stream2, 6000))), |
491 Invoke(&stream2_blocker, | 491 Invoke(&stream2_blocker, |
492 &StreamBlocker::MarkConnectionLevelWriteBlocked))); | 492 &StreamBlocker::MarkConnectionLevelWriteBlocked))); |
493 session_.OnCanWrite(); | 493 session_.OnCanWrite(); |
494 } | 494 } |
495 | 495 |
496 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) { | 496 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) { |
497 FLAGS_quic_enable_app_limited_check = true; | |
498 | |
499 // Encryption needs to be established before data can be sent. | 497 // Encryption needs to be established before data can be sent. |
500 CryptoHandshakeMessage msg; | 498 CryptoHandshakeMessage msg; |
501 session_.GetCryptoStream()->OnHandshakeMessage(msg); | 499 session_.GetCryptoStream()->OnHandshakeMessage(msg); |
502 | 500 |
503 // Drive congestion control manually. | 501 // Drive congestion control manually. |
504 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; | 502 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; |
505 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, | 503 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, |
506 send_algorithm); | 504 send_algorithm); |
507 | 505 |
508 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 506 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
(...skipping 28 matching lines...) Expand all Loading... |
537 QuicConnectionPeer::GetWriter(session_.connection())); | 535 QuicConnectionPeer::GetWriter(session_.connection())); |
538 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) | 536 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) |
539 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); | 537 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); |
540 EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _)); | 538 EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _)); |
541 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)); | 539 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)); |
542 session_.OnCanWrite(); | 540 session_.OnCanWrite(); |
543 EXPECT_FALSE(session_.WillingAndAbleToWrite()); | 541 EXPECT_FALSE(session_.WillingAndAbleToWrite()); |
544 } | 542 } |
545 | 543 |
546 TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) { | 544 TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) { |
547 FLAGS_quic_enable_app_limited_check = true; | |
548 | |
549 InSequence s; | 545 InSequence s; |
550 | 546 |
551 // Drive congestion control manually. | 547 // Drive congestion control manually. |
552 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; | 548 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; |
553 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, | 549 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, |
554 send_algorithm); | 550 send_algorithm); |
555 | 551 |
556 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 552 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
557 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 553 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
558 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 554 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
(...skipping 26 matching lines...) Expand all Loading... |
585 // congestion-control blocked. | 581 // congestion-control blocked. |
586 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) | 582 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
587 .WillOnce(Return(QuicTime::Delta::Zero())); | 583 .WillOnce(Return(QuicTime::Delta::Zero())); |
588 EXPECT_CALL(*stream4, OnCanWrite()); | 584 EXPECT_CALL(*stream4, OnCanWrite()); |
589 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)); | 585 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)); |
590 session_.OnCanWrite(); | 586 session_.OnCanWrite(); |
591 EXPECT_FALSE(session_.WillingAndAbleToWrite()); | 587 EXPECT_FALSE(session_.WillingAndAbleToWrite()); |
592 } | 588 } |
593 | 589 |
594 TEST_P(QuicSessionTestServer, OnCanWriteWriterBlocks) { | 590 TEST_P(QuicSessionTestServer, OnCanWriteWriterBlocks) { |
595 FLAGS_quic_enable_app_limited_check = true; | |
596 | |
597 // Drive congestion control manually in order to ensure that | 591 // Drive congestion control manually in order to ensure that |
598 // application-limited signaling is handled correctly. | 592 // application-limited signaling is handled correctly. |
599 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; | 593 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; |
600 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, | 594 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, |
601 send_algorithm); | 595 send_algorithm); |
602 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) | 596 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
603 .WillRepeatedly(Return(QuicTime::Delta::Zero())); | 597 .WillRepeatedly(Return(QuicTime::Delta::Zero())); |
604 | 598 |
605 // Drive packet writer manually. | 599 // Drive packet writer manually. |
606 MockPacketWriter* writer = static_cast<MockPacketWriter*>( | 600 MockPacketWriter* writer = static_cast<MockPacketWriter*>( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 CloseStream(stream6->id()); | 670 CloseStream(stream6->id()); |
677 | 671 |
678 InSequence s; | 672 InSequence s; |
679 EXPECT_CALL(*stream2, OnCanWrite()); | 673 EXPECT_CALL(*stream2, OnCanWrite()); |
680 EXPECT_CALL(*stream4, OnCanWrite()); | 674 EXPECT_CALL(*stream4, OnCanWrite()); |
681 session_.OnCanWrite(); | 675 session_.OnCanWrite(); |
682 EXPECT_FALSE(session_.WillingAndAbleToWrite()); | 676 EXPECT_FALSE(session_.WillingAndAbleToWrite()); |
683 } | 677 } |
684 | 678 |
685 TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) { | 679 TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) { |
686 FLAGS_quic_enable_app_limited_check = true; | |
687 | |
688 // Drive congestion control manually in order to ensure that | 680 // Drive congestion control manually in order to ensure that |
689 // application-limited signaling is handled correctly. | 681 // application-limited signaling is handled correctly. |
690 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; | 682 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; |
691 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, | 683 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, |
692 send_algorithm); | 684 send_algorithm); |
693 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) | 685 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
694 .WillRepeatedly(Return(QuicTime::Delta::Zero())); | 686 .WillRepeatedly(Return(QuicTime::Delta::Zero())); |
695 | 687 |
696 // Ensure connection level flow control blockage. | 688 // Ensure connection level flow control blockage. |
697 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0); | 689 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 if (version() <= QUIC_VERSION_35) { | 1248 if (version() <= QUIC_VERSION_35) { |
1257 EXPECT_FALSE(session_.force_hol_blocking()); | 1249 EXPECT_FALSE(session_.force_hol_blocking()); |
1258 } else { | 1250 } else { |
1259 EXPECT_TRUE(session_.force_hol_blocking()); | 1251 EXPECT_TRUE(session_.force_hol_blocking()); |
1260 } | 1252 } |
1261 } | 1253 } |
1262 | 1254 |
1263 } // namespace | 1255 } // namespace |
1264 } // namespace test | 1256 } // namespace test |
1265 } // namespace net | 1257 } // namespace net |
OLD | NEW |