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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 connection, | 73 connection, |
74 visitor, | 74 visitor, |
75 helper, | 75 helper, |
76 crypto_config, | 76 crypto_config, |
77 compressed_certs_cache), | 77 compressed_certs_cache), |
78 response_cache_(response_cache) {} | 78 response_cache_(response_cache) {} |
79 | 79 |
80 ~TestServerSession() override { delete connection(); }; | 80 ~TestServerSession() override { delete connection(); }; |
81 | 81 |
82 protected: | 82 protected: |
| 83 // TODO(ckrasic) - for two below, remove when |
| 84 // quic_reloadable_flag_quic_refactor_stream_creation is deprecated. |
83 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { | 85 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { |
84 if (!ShouldCreateIncomingDynamicStream(id)) { | 86 if (!ShouldCreateIncomingDynamicStream(id)) { |
85 return nullptr; | 87 return nullptr; |
86 } | 88 } |
87 QuicSpdyStream* stream = | 89 QuicSpdyStream* stream = |
88 new QuicSimpleServerStream(id, this, response_cache_); | 90 new QuicSimpleServerStream(id, this, response_cache_); |
89 ActivateStream(QuicWrapUnique(stream)); | 91 ActivateStream(QuicWrapUnique(stream)); |
90 return stream; | 92 return stream; |
91 } | 93 } |
92 | 94 |
93 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { | 95 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { |
94 if (!ShouldCreateOutgoingDynamicStream()) { | 96 if (!ShouldCreateOutgoingDynamicStream()) { |
95 return nullptr; | 97 return nullptr; |
96 } | 98 } |
97 | 99 |
98 QuicSpdyStream* stream = new QuicSimpleServerStream( | 100 QuicSpdyStream* stream = new QuicSimpleServerStream( |
99 GetNextOutgoingStreamId(), this, response_cache_); | 101 GetNextOutgoingStreamId(), this, response_cache_); |
100 stream->SetPriority(priority); | 102 stream->SetPriority(priority); |
101 ActivateStream(QuicWrapUnique(stream)); | 103 ActivateStream(QuicWrapUnique(stream)); |
102 return stream; | 104 return stream; |
103 } | 105 } |
104 | 106 |
| 107 std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) override { |
| 108 return QuicMakeUnique<QuicSimpleServerStream>(id, this, response_cache_); |
| 109 } |
| 110 |
105 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( | 111 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( |
106 const QuicCryptoServerConfig* crypto_config, | 112 const QuicCryptoServerConfig* crypto_config, |
107 QuicCompressedCertsCache* compressed_certs_cache) override { | 113 QuicCompressedCertsCache* compressed_certs_cache) override { |
108 return new QuicCryptoServerStream( | 114 return new QuicCryptoServerStream( |
109 crypto_config, compressed_certs_cache, | 115 crypto_config, compressed_certs_cache, |
110 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this, | 116 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this, |
111 stream_helper()); | 117 stream_helper()); |
112 } | 118 } |
113 | 119 |
114 private: | 120 private: |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { | 374 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { |
369 // Incoming streams on the server session must be odd. | 375 // Incoming streams on the server session must be odd. |
370 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID, _, _)); | 376 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID, _, _)); |
371 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 377 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
372 session_.get(), GetNthServerInitiatedId(0))); | 378 session_.get(), GetNthServerInitiatedId(0))); |
373 } | 379 } |
374 | 380 |
375 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) { | 381 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) { |
376 // Don't create new streams if the connection is disconnected. | 382 // Don't create new streams if the connection is disconnected. |
377 QuicConnectionPeer::TearDownLocalConnectionState(connection_); | 383 QuicConnectionPeer::TearDownLocalConnectionState(connection_); |
378 EXPECT_QUIC_BUG(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 384 if (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation) { |
379 session_.get(), GetNthClientInitiatedId(0)), | 385 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
380 "ShouldCreateIncomingDynamicStream called when disconnected"); | 386 session_.get(), GetNthClientInitiatedId(0))); |
| 387 } else { |
| 388 EXPECT_QUIC_BUG( |
| 389 QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
| 390 session_.get(), GetNthClientInitiatedId(0)), |
| 391 "ShouldCreateIncomingDynamicStream called when disconnected"); |
| 392 } |
381 } | 393 } |
382 | 394 |
383 class MockQuicCryptoServerStream : public QuicCryptoServerStream { | 395 class MockQuicCryptoServerStream : public QuicCryptoServerStream { |
384 public: | 396 public: |
385 explicit MockQuicCryptoServerStream( | 397 explicit MockQuicCryptoServerStream( |
386 const QuicCryptoServerConfig* crypto_config, | 398 const QuicCryptoServerConfig* crypto_config, |
387 QuicCompressedCertsCache* compressed_certs_cache, | 399 QuicCompressedCertsCache* compressed_certs_cache, |
388 QuicServerSessionBase* session, | 400 QuicServerSessionBase* session, |
389 QuicCryptoServerStream::Helper* helper) | 401 QuicCryptoServerStream::Helper* helper) |
390 : QuicCryptoServerStream( | 402 : QuicCryptoServerStream( |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 658 |
647 // Allow the async ProofSource::GetProof call to complete. Verify (under | 659 // 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 | 660 // asan) that this does not result in accesses to any freed memory from the |
649 // session or its subobjects. | 661 // session or its subobjects. |
650 GetFakeProofSource()->InvokePendingCallback(0); | 662 GetFakeProofSource()->InvokePendingCallback(0); |
651 } | 663 } |
652 | 664 |
653 } // namespace | 665 } // namespace |
654 } // namespace test | 666 } // namespace test |
655 } // namespace net | 667 } // namespace net |
OLD | NEW |