| 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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), send_algorithm); | 494 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), send_algorithm); |
| 495 | 495 |
| 496 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 496 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
| 497 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 497 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
| 498 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 498 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
| 499 | 499 |
| 500 session_.MarkConnectionLevelWriteBlocked(stream2->id()); | 500 session_.MarkConnectionLevelWriteBlocked(stream2->id()); |
| 501 session_.MarkConnectionLevelWriteBlocked(stream6->id()); | 501 session_.MarkConnectionLevelWriteBlocked(stream6->id()); |
| 502 session_.MarkConnectionLevelWriteBlocked(stream4->id()); | 502 session_.MarkConnectionLevelWriteBlocked(stream4->id()); |
| 503 | 503 |
| 504 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)) | 504 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
| 505 .WillRepeatedly(Return(QuicTime::Delta::Zero())); | 505 .WillRepeatedly(Return(QuicTime::Delta::Zero())); |
| 506 EXPECT_CALL(*send_algorithm, GetCongestionWindow()) | 506 EXPECT_CALL(*send_algorithm, GetCongestionWindow()) |
| 507 .WillRepeatedly(Return(kMaxPacketSize * 10)); | 507 .WillRepeatedly(Return(kMaxPacketSize * 10)); |
| 508 EXPECT_CALL(*stream2, OnCanWrite()) | 508 EXPECT_CALL(*stream2, OnCanWrite()) |
| 509 .WillOnce(testing::IgnoreResult(Invoke(CreateFunctor( | 509 .WillOnce(testing::IgnoreResult(Invoke(CreateFunctor( |
| 510 &TestSession::SendStreamData, | 510 &TestSession::SendStreamData, |
| 511 base::Unretained(&session_), stream2->id())))); | 511 base::Unretained(&session_), stream2->id())))); |
| 512 EXPECT_CALL(*stream4, OnCanWrite()) | 512 EXPECT_CALL(*stream4, OnCanWrite()) |
| 513 .WillOnce(testing::IgnoreResult(Invoke(CreateFunctor( | 513 .WillOnce(testing::IgnoreResult(Invoke(CreateFunctor( |
| 514 &TestSession::SendStreamData, | 514 &TestSession::SendStreamData, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 540 | 540 |
| 541 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 541 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
| 542 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 542 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
| 543 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 543 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
| 544 | 544 |
| 545 session_.MarkConnectionLevelWriteBlocked(stream2->id()); | 545 session_.MarkConnectionLevelWriteBlocked(stream2->id()); |
| 546 session_.MarkConnectionLevelWriteBlocked(stream6->id()); | 546 session_.MarkConnectionLevelWriteBlocked(stream6->id()); |
| 547 session_.MarkConnectionLevelWriteBlocked(stream4->id()); | 547 session_.MarkConnectionLevelWriteBlocked(stream4->id()); |
| 548 | 548 |
| 549 StreamBlocker stream2_blocker(&session_, stream2->id()); | 549 StreamBlocker stream2_blocker(&session_, stream2->id()); |
| 550 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)) | 550 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
| 551 .WillOnce(Return(QuicTime::Delta::Zero())); | 551 .WillOnce(Return(QuicTime::Delta::Zero())); |
| 552 EXPECT_CALL(*stream2, OnCanWrite()); | 552 EXPECT_CALL(*stream2, OnCanWrite()); |
| 553 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)) | 553 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
| 554 .WillOnce(Return(QuicTime::Delta::Zero())); | 554 .WillOnce(Return(QuicTime::Delta::Zero())); |
| 555 EXPECT_CALL(*stream6, OnCanWrite()); | 555 EXPECT_CALL(*stream6, OnCanWrite()); |
| 556 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)) | 556 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
| 557 .WillOnce(Return(QuicTime::Delta::Infinite())); | 557 .WillOnce(Return(QuicTime::Delta::Infinite())); |
| 558 // stream4->OnCanWrite is not called. | 558 // stream4->OnCanWrite is not called. |
| 559 | 559 |
| 560 session_.OnCanWrite(); | 560 session_.OnCanWrite(); |
| 561 EXPECT_TRUE(session_.WillingAndAbleToWrite()); | 561 EXPECT_TRUE(session_.WillingAndAbleToWrite()); |
| 562 | 562 |
| 563 // Still congestion-control blocked. | 563 // Still congestion-control blocked. |
| 564 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)) | 564 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
| 565 .WillOnce(Return(QuicTime::Delta::Infinite())); | 565 .WillOnce(Return(QuicTime::Delta::Infinite())); |
| 566 session_.OnCanWrite(); | 566 session_.OnCanWrite(); |
| 567 EXPECT_TRUE(session_.WillingAndAbleToWrite()); | 567 EXPECT_TRUE(session_.WillingAndAbleToWrite()); |
| 568 | 568 |
| 569 // stream4->OnCanWrite is called once the connection stops being | 569 // stream4->OnCanWrite is called once the connection stops being |
| 570 // congestion-control blocked. | 570 // congestion-control blocked. |
| 571 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)) | 571 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) |
| 572 .WillOnce(Return(QuicTime::Delta::Zero())); | 572 .WillOnce(Return(QuicTime::Delta::Zero())); |
| 573 EXPECT_CALL(*stream4, OnCanWrite()); | 573 EXPECT_CALL(*stream4, OnCanWrite()); |
| 574 session_.OnCanWrite(); | 574 session_.OnCanWrite(); |
| 575 EXPECT_FALSE(session_.WillingAndAbleToWrite()); | 575 EXPECT_FALSE(session_.WillingAndAbleToWrite()); |
| 576 } | 576 } |
| 577 | 577 |
| 578 TEST_P(QuicSessionTestServer, BufferedHandshake) { | 578 TEST_P(QuicSessionTestServer, BufferedHandshake) { |
| 579 EXPECT_FALSE(session_.HasPendingHandshake()); // Default value. | 579 EXPECT_FALSE(session_.HasPendingHandshake()); // Default value. |
| 580 | 580 |
| 581 // Test that blocking other streams does not change our status. | 581 // Test that blocking other streams does not change our status. |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 session_.max_open_incoming_streams()); | 1196 session_.max_open_incoming_streams()); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 EXPECT_EQ(session_.max_open_outgoing_streams(), | 1199 EXPECT_EQ(session_.max_open_outgoing_streams(), |
| 1200 kDefaultMaxStreamsPerConnection); | 1200 kDefaultMaxStreamsPerConnection); |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 } // namespace | 1203 } // namespace |
| 1204 } // namespace test | 1204 } // namespace test |
| 1205 } // namespace net | 1205 } // namespace net |
| OLD | NEW |