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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 string error_details; | 62 string error_details; |
63 session()->config()->SetInitialStreamFlowControlWindowToSend( | 63 session()->config()->SetInitialStreamFlowControlWindowToSend( |
64 kInitialStreamFlowControlWindowForTest); | 64 kInitialStreamFlowControlWindowForTest); |
65 session()->config()->SetInitialSessionFlowControlWindowToSend( | 65 session()->config()->SetInitialSessionFlowControlWindowToSend( |
66 kInitialSessionFlowControlWindowForTest); | 66 kInitialSessionFlowControlWindowForTest); |
67 session()->config()->ToHandshakeMessage(&msg); | 67 session()->config()->ToHandshakeMessage(&msg); |
68 const QuicErrorCode error = | 68 const QuicErrorCode error = |
69 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); | 69 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); |
70 EXPECT_EQ(QUIC_NO_ERROR, error); | 70 EXPECT_EQ(QUIC_NO_ERROR, error); |
71 session()->OnConfigNegotiated(); | 71 session()->OnConfigNegotiated(); |
| 72 session()->connection()->SetDefaultEncryptionLevel( |
| 73 ENCRYPTION_FORWARD_SECURE); |
72 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); | 74 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
73 } | 75 } |
74 | 76 |
75 MOCK_METHOD0(OnCanWrite, void()); | 77 MOCK_METHOD0(OnCanWrite, void()); |
76 }; | 78 }; |
77 | 79 |
78 class TestHeadersStream : public QuicHeadersStream { | 80 class TestHeadersStream : public QuicHeadersStream { |
79 public: | 81 public: |
80 explicit TestHeadersStream(QuicSpdySession* session) | 82 explicit TestHeadersStream(QuicSpdySession* session) |
81 : QuicHeadersStream(session) {} | 83 : QuicHeadersStream(session) {} |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 &TestSession::SendLargeFakeData, | 510 &TestSession::SendLargeFakeData, |
509 base::Unretained(&session_), stream2, 6000))), | 511 base::Unretained(&session_), stream2, 6000))), |
510 Invoke(&stream2_blocker, | 512 Invoke(&stream2_blocker, |
511 &StreamBlocker::MarkConnectionLevelWriteBlocked))); | 513 &StreamBlocker::MarkConnectionLevelWriteBlocked))); |
512 session_.OnCanWrite(); | 514 session_.OnCanWrite(); |
513 } | 515 } |
514 | 516 |
515 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) { | 517 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) { |
516 // Encryption needs to be established before data can be sent. | 518 // Encryption needs to be established before data can be sent. |
517 CryptoHandshakeMessage msg; | 519 CryptoHandshakeMessage msg; |
| 520 MockPacketWriter* writer = static_cast<MockPacketWriter*>( |
| 521 QuicConnectionPeer::GetWriter(session_.connection())); |
| 522 if (FLAGS_quic_send_max_header_list_size) { |
| 523 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) |
| 524 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); |
| 525 } |
518 session_.GetCryptoStream()->OnHandshakeMessage(msg); | 526 session_.GetCryptoStream()->OnHandshakeMessage(msg); |
519 | 527 |
520 // Drive congestion control manually. | 528 // Drive congestion control manually. |
521 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; | 529 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; |
522 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, | 530 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, |
523 send_algorithm); | 531 send_algorithm); |
524 | 532 |
525 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 533 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
526 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 534 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
527 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); | 535 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
(...skipping 15 matching lines...) Expand all Loading... |
543 .WillOnce(testing::IgnoreResult( | 551 .WillOnce(testing::IgnoreResult( |
544 Invoke(CreateFunctor(&TestSession::SendStreamData, | 552 Invoke(CreateFunctor(&TestSession::SendStreamData, |
545 base::Unretained(&session_), stream4)))); | 553 base::Unretained(&session_), stream4)))); |
546 EXPECT_CALL(*stream6, OnCanWrite()) | 554 EXPECT_CALL(*stream6, OnCanWrite()) |
547 .WillOnce(testing::IgnoreResult( | 555 .WillOnce(testing::IgnoreResult( |
548 Invoke(CreateFunctor(&TestSession::SendStreamData, | 556 Invoke(CreateFunctor(&TestSession::SendStreamData, |
549 base::Unretained(&session_), stream6)))); | 557 base::Unretained(&session_), stream6)))); |
550 | 558 |
551 // Expect that we only send one packet, the writes from different streams | 559 // Expect that we only send one packet, the writes from different streams |
552 // should be bundled together. | 560 // should be bundled together. |
553 MockPacketWriter* writer = static_cast<MockPacketWriter*>( | |
554 QuicConnectionPeer::GetWriter(session_.connection())); | |
555 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) | 561 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) |
556 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); | 562 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); |
557 EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _)); | 563 EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _)); |
558 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)); | 564 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)); |
559 session_.OnCanWrite(); | 565 session_.OnCanWrite(); |
560 EXPECT_FALSE(session_.WillingAndAbleToWrite()); | 566 EXPECT_FALSE(session_.WillingAndAbleToWrite()); |
561 } | 567 } |
562 | 568 |
563 TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) { | 569 TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) { |
564 session_.set_writev_consumes_all_data(true); | 570 session_.set_writev_consumes_all_data(true); |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 if (version() <= QUIC_VERSION_35) { | 1300 if (version() <= QUIC_VERSION_35) { |
1295 EXPECT_FALSE(session_.force_hol_blocking()); | 1301 EXPECT_FALSE(session_.force_hol_blocking()); |
1296 } else { | 1302 } else { |
1297 EXPECT_TRUE(session_.force_hol_blocking()); | 1303 EXPECT_TRUE(session_.force_hol_blocking()); |
1298 } | 1304 } |
1299 } | 1305 } |
1300 | 1306 |
1301 } // namespace | 1307 } // namespace |
1302 } // namespace test | 1308 } // namespace test |
1303 } // namespace net | 1309 } // namespace net |
OLD | NEW |