| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 12 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
| 13 #include "net/quic/core/crypto/quic_random.h" | 13 #include "net/quic/core/crypto/quic_random.h" |
| 14 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 14 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
| 15 #include "net/quic/core/quic_connection.h" | 15 #include "net/quic/core/quic_connection.h" |
| 16 #include "net/quic/core/quic_crypto_server_stream.h" | 16 #include "net/quic/core/quic_crypto_server_stream.h" |
| 17 #include "net/quic/core/quic_utils.h" | 17 #include "net/quic/core/quic_utils.h" |
| 18 #include "net/quic/test_tools/crypto_test_utils.h" | 18 #include "net/quic/test_tools/crypto_test_utils.h" |
| 19 #include "net/quic/test_tools/fake_proof_source.h" | 19 #include "net/quic/test_tools/fake_proof_source.h" |
| 20 #include "net/quic/test_tools/quic_config_peer.h" | 20 #include "net/quic/test_tools/quic_config_peer.h" |
| 21 #include "net/quic/test_tools/quic_connection_peer.h" | 21 #include "net/quic/test_tools/quic_connection_peer.h" |
| 22 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" | 22 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" |
| 23 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 23 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| 24 #include "net/quic/test_tools/quic_session_peer.h" | 24 #include "net/quic/test_tools/quic_session_peer.h" |
| 25 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 25 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
| 26 #include "net/quic/test_tools/quic_spdy_stream_peer.h" | 26 #include "net/quic/test_tools/quic_spdy_stream_peer.h" |
| 27 #include "net/quic/test_tools/quic_stream_peer.h" |
| 27 #include "net/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" | 28 #include "net/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" |
| 28 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
| 29 #include "net/test/gtest_util.h" | 30 #include "net/test/gtest_util.h" |
| 31 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 30 #include "net/tools/quic/quic_simple_server_stream.h" | 32 #include "net/tools/quic/quic_simple_server_stream.h" |
| 31 #include "net/tools/quic/test_tools/mock_quic_server_session_visitor.h" | 33 #include "net/tools/quic/test_tools/mock_quic_server_session_visitor.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 34 | 36 |
| 35 using net::test::CryptoTestUtils; | 37 using net::test::CryptoTestUtils; |
| 36 using net::test::MockQuicConnection; | 38 using net::test::MockQuicConnection; |
| 37 using net::test::MockQuicConnectionHelper; | 39 using net::test::MockQuicConnectionHelper; |
| 38 using net::test::QuicConfigPeer; | 40 using net::test::QuicConfigPeer; |
| 39 using net::test::QuicConnectionPeer; | 41 using net::test::QuicConnectionPeer; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 using net::test::kInitialStreamFlowControlWindowForTest; | 52 using net::test::kInitialStreamFlowControlWindowForTest; |
| 51 using std::string; | 53 using std::string; |
| 52 using testing::StrictMock; | 54 using testing::StrictMock; |
| 53 using testing::_; | 55 using testing::_; |
| 54 | 56 |
| 55 namespace net { | 57 namespace net { |
| 56 namespace test { | 58 namespace test { |
| 57 | 59 |
| 58 class QuicServerSessionBasePeer { | 60 class QuicServerSessionBasePeer { |
| 59 public: | 61 public: |
| 60 static ReliableQuicStream* GetOrCreateDynamicStream(QuicServerSessionBase* s, | 62 static QuicStream* GetOrCreateDynamicStream(QuicServerSessionBase* s, |
| 61 QuicStreamId id) { | 63 QuicStreamId id) { |
| 62 return s->GetOrCreateDynamicStream(id); | 64 return s->GetOrCreateDynamicStream(id); |
| 63 } | 65 } |
| 64 static void SetCryptoStream(QuicServerSessionBase* s, | 66 static void SetCryptoStream(QuicServerSessionBase* s, |
| 65 QuicCryptoServerStream* crypto_stream) { | 67 QuicCryptoServerStream* crypto_stream) { |
| 66 s->crypto_stream_.reset(crypto_stream); | 68 s->crypto_stream_.reset(crypto_stream); |
| 67 s->static_streams()[kCryptoStreamId] = crypto_stream; | 69 s->static_streams()[kCryptoStreamId] = crypto_stream; |
| 68 } | 70 } |
| 69 static bool IsBandwidthResumptionEnabled(QuicServerSessionBase* s) { | 71 static bool IsBandwidthResumptionEnabled(QuicServerSessionBase* s) { |
| 70 return s->bandwidth_resumption_enabled_; | 72 return s->bandwidth_resumption_enabled_; |
| 71 } | 73 } |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 600 |
| 599 INSTANTIATE_TEST_CASE_P(StreamMemberLifetimeTests, | 601 INSTANTIATE_TEST_CASE_P(StreamMemberLifetimeTests, |
| 600 StreamMemberLifetimeTest, | 602 StreamMemberLifetimeTest, |
| 601 ::testing::ValuesIn(AllSupportedVersions())); | 603 ::testing::ValuesIn(AllSupportedVersions())); |
| 602 | 604 |
| 603 // Trigger an operation which causes an async invocation of | 605 // Trigger an operation which causes an async invocation of |
| 604 // ProofSource::GetProof. Delay the completion of the operation until after the | 606 // ProofSource::GetProof. Delay the completion of the operation until after the |
| 605 // stream has been destroyed, and verify that there are no memory bugs. | 607 // stream has been destroyed, and verify that there are no memory bugs. |
| 606 TEST_P(StreamMemberLifetimeTest, Basic) { | 608 TEST_P(StreamMemberLifetimeTest, Basic) { |
| 607 FLAGS_enable_async_get_proof = true; | 609 FLAGS_enable_async_get_proof = true; |
| 608 FLAGS_quic_buffer_packet_till_chlo = true; | |
| 609 FLAGS_enable_quic_stateless_reject_support = true; | 610 FLAGS_enable_quic_stateless_reject_support = true; |
| 610 FLAGS_quic_use_cheap_stateless_rejects = true; | 611 FLAGS_quic_use_cheap_stateless_rejects = true; |
| 611 FLAGS_quic_create_session_after_insertion = true; | 612 FLAGS_quic_create_session_after_insertion = true; |
| 612 | 613 |
| 613 const QuicClock* clock = helper_.GetClock(); | 614 const QuicClock* clock = helper_.GetClock(); |
| 614 QuicVersion version = AllSupportedVersions().front(); | 615 QuicVersion version = AllSupportedVersions().front(); |
| 615 CryptoHandshakeMessage chlo = CryptoTestUtils::GenerateDefaultInchoateCHLO( | 616 CryptoHandshakeMessage chlo = CryptoTestUtils::GenerateDefaultInchoateCHLO( |
| 616 clock, version, &crypto_config_); | 617 clock, version, &crypto_config_); |
| 617 chlo.SetVector(kCOPT, QuicTagVector{kSREJ}); | 618 chlo.SetVector(kCOPT, QuicTagVector{kSREJ}); |
| 618 std::vector<QuicVersion> packet_version_list = {version}; | 619 std::vector<QuicVersion> packet_version_list = {version}; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 646 | 647 |
| 647 // Allow the async ProofSource::GetProof call to complete. Verify (under | 648 // Allow the async ProofSource::GetProof call to complete. Verify (under |
| 648 // asan) that this does not result in accesses to any freed memory from the | 649 // asan) that this does not result in accesses to any freed memory from the |
| 649 // session or its subobjects. | 650 // session or its subobjects. |
| 650 GetFakeProofSource()->InvokePendingCallback(0); | 651 GetFakeProofSource()->InvokePendingCallback(0); |
| 651 } | 652 } |
| 652 | 653 |
| 653 } // namespace | 654 } // namespace |
| 654 } // namespace test | 655 } // namespace test |
| 655 } // namespace net | 656 } // namespace net |
| OLD | NEW |