OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_server_session_base.h" | 5 #include "net/quic/core/quic_server_session_base.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream); | 402 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream); |
403 }; | 403 }; |
404 | 404 |
405 TEST_P(QuicServerSessionBaseTest, BandwidthEstimates) { | 405 TEST_P(QuicServerSessionBaseTest, BandwidthEstimates) { |
406 // Test that bandwidth estimate updates are sent to the client, only when | 406 // Test that bandwidth estimate updates are sent to the client, only when |
407 // bandwidth resumption is enabled, the bandwidth estimate has changed | 407 // bandwidth resumption is enabled, the bandwidth estimate has changed |
408 // sufficiently, enough time has passed, | 408 // sufficiently, enough time has passed, |
409 // and we don't have any other data to write. | 409 // and we don't have any other data to write. |
410 | 410 |
411 // Client has sent kBWRE connection option to trigger bandwidth resumption. | 411 // Client has sent kBWRE connection option to trigger bandwidth resumption. |
412 // Disable this flag because if connection uses multipath sent packet manager, | |
413 // static_cast here does not work. | |
414 QuicTagVector copt; | 412 QuicTagVector copt; |
415 copt.push_back(kBWRE); | 413 copt.push_back(kBWRE); |
416 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 414 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
417 session_->OnConfigNegotiated(); | 415 session_->OnConfigNegotiated(); |
418 EXPECT_TRUE( | 416 EXPECT_TRUE( |
419 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 417 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
420 | 418 |
421 int32_t bandwidth_estimate_kbytes_per_second = 123; | 419 int32_t bandwidth_estimate_kbytes_per_second = 123; |
422 int32_t max_bandwidth_estimate_kbytes_per_second = 134; | 420 int32_t max_bandwidth_estimate_kbytes_per_second = 134; |
423 int32_t max_bandwidth_estimate_timestamp = 1122334455; | 421 int32_t max_bandwidth_estimate_timestamp = 1122334455; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects = true; | 604 FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects = true; |
607 FLAGS_quic_reloadable_flag_quic_create_session_after_insertion = true; | 605 FLAGS_quic_reloadable_flag_quic_create_session_after_insertion = true; |
608 | 606 |
609 const QuicClock* clock = helper_.GetClock(); | 607 const QuicClock* clock = helper_.GetClock(); |
610 QuicVersion version = AllSupportedVersions().front(); | 608 QuicVersion version = AllSupportedVersions().front(); |
611 CryptoHandshakeMessage chlo = crypto_test_utils::GenerateDefaultInchoateCHLO( | 609 CryptoHandshakeMessage chlo = crypto_test_utils::GenerateDefaultInchoateCHLO( |
612 clock, version, &crypto_config_); | 610 clock, version, &crypto_config_); |
613 chlo.SetVector(kCOPT, QuicTagVector{kSREJ}); | 611 chlo.SetVector(kCOPT, QuicTagVector{kSREJ}); |
614 std::vector<QuicVersion> packet_version_list = {version}; | 612 std::vector<QuicVersion> packet_version_list = {version}; |
615 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( | 613 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( |
616 1, true, false, false, 1, | 614 1, true, false, 1, |
617 chlo.GetSerialized().AsStringPiece().as_string(), | 615 string(chlo.GetSerialized().AsStringPiece().as_string()), |
618 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, | 616 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, |
619 &packet_version_list)); | 617 &packet_version_list)); |
620 | 618 |
621 EXPECT_CALL(stream_helper_, CanAcceptClientHello(_, _, _)) | 619 EXPECT_CALL(stream_helper_, CanAcceptClientHello(_, _, _)) |
622 .WillOnce(testing::Return(true)); | 620 .WillOnce(testing::Return(true)); |
623 EXPECT_CALL(stream_helper_, GenerateConnectionIdForReject(_)) | 621 EXPECT_CALL(stream_helper_, GenerateConnectionIdForReject(_)) |
624 .WillOnce(testing::Return(12345)); | 622 .WillOnce(testing::Return(12345)); |
625 | 623 |
626 // Set the current packet | 624 // Set the current packet |
627 QuicConnectionPeer::SetCurrentPacket(session_->connection(), | 625 QuicConnectionPeer::SetCurrentPacket(session_->connection(), |
628 packet->AsStringPiece()); | 626 packet->AsStringPiece().as_string()); |
629 | 627 |
630 // Yes, this is horrible. But it's the easiest way to trigger the behavior we | 628 // Yes, this is horrible. But it's the easiest way to trigger the behavior we |
631 // need to exercise. | 629 // need to exercise. |
632 QuicCryptoServerStreamBase* crypto_stream = | 630 QuicCryptoServerStreamBase* crypto_stream = |
633 const_cast<QuicCryptoServerStreamBase*>(session_->crypto_stream()); | 631 const_cast<QuicCryptoServerStreamBase*>(session_->crypto_stream()); |
634 | 632 |
635 // Feed the CHLO into the crypto stream, which will trigger a call to | 633 // Feed the CHLO into the crypto stream, which will trigger a call to |
636 // ProofSource::GetProof | 634 // ProofSource::GetProof |
637 crypto_stream->OnHandshakeMessage(chlo); | 635 crypto_stream->OnHandshakeMessage(chlo); |
638 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 1); | 636 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 1); |
639 | 637 |
640 // Destroy the stream | 638 // Destroy the stream |
641 session_.reset(); | 639 session_.reset(); |
642 | 640 |
643 // Allow the async ProofSource::GetProof call to complete. Verify (under | 641 // Allow the async ProofSource::GetProof call to complete. Verify (under |
644 // asan) that this does not result in accesses to any freed memory from the | 642 // asan) that this does not result in accesses to any freed memory from the |
645 // session or its subobjects. | 643 // session or its subobjects. |
646 GetFakeProofSource()->InvokePendingCallback(0); | 644 GetFakeProofSource()->InvokePendingCallback(0); |
647 } | 645 } |
648 | 646 |
649 } // namespace | 647 } // namespace |
650 } // namespace test | 648 } // namespace test |
651 } // namespace net | 649 } // namespace net |
OLD | NEW |