| 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/tools/quic/quic_server_session_base.h" | 5 #include "net/tools/quic/quic_server_session_base.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "net/quic/crypto/quic_crypto_server_config.h" | 8 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 9 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
| 10 #include "net/quic/proto/cached_network_parameters.pb.h" | 10 #include "net/quic/proto/cached_network_parameters.pb.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 namespace { | 69 namespace { |
| 70 | 70 |
| 71 class TestServerSession : public QuicServerSessionBase { | 71 class TestServerSession : public QuicServerSessionBase { |
| 72 public: | 72 public: |
| 73 TestServerSession(const QuicConfig& config, | 73 TestServerSession(const QuicConfig& config, |
| 74 QuicConnection* connection, | 74 QuicConnection* connection, |
| 75 QuicServerSessionVisitor* visitor, | 75 QuicServerSessionVisitor* visitor, |
| 76 const QuicCryptoServerConfig* crypto_config) | 76 const QuicCryptoServerConfig* crypto_config, |
| 77 : QuicServerSessionBase(config, connection, visitor, crypto_config) {} | 77 QuicCompressedCertsCache* compressed_certs_cache) |
| 78 : QuicServerSessionBase(config, |
| 79 connection, |
| 80 visitor, |
| 81 crypto_config, |
| 82 compressed_certs_cache) {} |
| 78 | 83 |
| 79 ~TestServerSession() override{}; | 84 ~TestServerSession() override{}; |
| 80 | 85 |
| 81 protected: | 86 protected: |
| 82 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { | 87 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { |
| 83 if (!ShouldCreateIncomingDynamicStream(id)) { | 88 if (!ShouldCreateIncomingDynamicStream(id)) { |
| 84 return nullptr; | 89 return nullptr; |
| 85 } | 90 } |
| 86 QuicSpdyStream* stream = new QuicSimpleServerStream(id, this); | 91 QuicSpdyStream* stream = new QuicSimpleServerStream(id, this); |
| 87 ActivateStream(stream); | 92 ActivateStream(stream); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 107 } | 112 } |
| 108 }; | 113 }; |
| 109 | 114 |
| 110 const size_t kMaxStreamsForTest = 10; | 115 const size_t kMaxStreamsForTest = 10; |
| 111 | 116 |
| 112 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { | 117 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { |
| 113 protected: | 118 protected: |
| 114 QuicServerSessionBaseTest() | 119 QuicServerSessionBaseTest() |
| 115 : crypto_config_(QuicCryptoServerConfig::TESTING, | 120 : crypto_config_(QuicCryptoServerConfig::TESTING, |
| 116 QuicRandom::GetInstance(), | 121 QuicRandom::GetInstance(), |
| 117 CryptoTestUtils::ProofSourceForTesting()) { | 122 CryptoTestUtils::ProofSourceForTesting()), |
| 123 compressed_certs_cache_( |
| 124 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { |
| 125 FLAGS_quic_always_log_bugs_for_tests = true; |
| 118 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); | 126 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); |
| 119 config_.SetInitialStreamFlowControlWindowToSend( | 127 config_.SetInitialStreamFlowControlWindowToSend( |
| 120 kInitialStreamFlowControlWindowForTest); | 128 kInitialStreamFlowControlWindowForTest); |
| 121 config_.SetInitialSessionFlowControlWindowToSend( | 129 config_.SetInitialSessionFlowControlWindowToSend( |
| 122 kInitialSessionFlowControlWindowForTest); | 130 kInitialSessionFlowControlWindowForTest); |
| 123 | 131 |
| 124 connection_ = new StrictMock<MockConnection>( | 132 connection_ = new StrictMock<MockConnection>( |
| 125 &helper_, Perspective::IS_SERVER, SupportedVersions(GetParam())); | 133 &helper_, Perspective::IS_SERVER, SupportedVersions(GetParam())); |
| 126 session_.reset( | 134 session_.reset(new TestServerSession(config_, connection_, &owner_, |
| 127 new TestServerSession(config_, connection_, &owner_, &crypto_config_)); | 135 &crypto_config_, |
| 136 &compressed_certs_cache_)); |
| 128 MockClock clock; | 137 MockClock clock; |
| 129 handshake_message_.reset(crypto_config_.AddDefaultConfig( | 138 handshake_message_.reset(crypto_config_.AddDefaultConfig( |
| 130 QuicRandom::GetInstance(), &clock, | 139 QuicRandom::GetInstance(), &clock, |
| 131 QuicCryptoServerConfig::ConfigOptions())); | 140 QuicCryptoServerConfig::ConfigOptions())); |
| 132 session_->Initialize(); | 141 session_->Initialize(); |
| 133 visitor_ = QuicConnectionPeer::GetVisitor(connection_); | 142 visitor_ = QuicConnectionPeer::GetVisitor(connection_); |
| 134 } | 143 } |
| 135 | 144 |
| 136 StrictMock<MockQuicServerSessionVisitor> owner_; | 145 StrictMock<MockQuicServerSessionVisitor> owner_; |
| 137 MockConnectionHelper helper_; | 146 MockConnectionHelper helper_; |
| 138 StrictMock<MockConnection>* connection_; | 147 StrictMock<MockConnection>* connection_; |
| 139 QuicConfig config_; | 148 QuicConfig config_; |
| 140 QuicCryptoServerConfig crypto_config_; | 149 QuicCryptoServerConfig crypto_config_; |
| 150 QuicCompressedCertsCache compressed_certs_cache_; |
| 141 scoped_ptr<TestServerSession> session_; | 151 scoped_ptr<TestServerSession> session_; |
| 142 scoped_ptr<CryptoHandshakeMessage> handshake_message_; | 152 scoped_ptr<CryptoHandshakeMessage> handshake_message_; |
| 143 QuicConnectionVisitorInterface* visitor_; | 153 QuicConnectionVisitorInterface* visitor_; |
| 144 }; | 154 }; |
| 145 | 155 |
| 146 // Compares CachedNetworkParameters. | 156 // Compares CachedNetworkParameters. |
| 147 MATCHER_P(EqualsProto, network_params, "") { | 157 MATCHER_P(EqualsProto, network_params, "") { |
| 148 CachedNetworkParameters reference(network_params); | 158 CachedNetworkParameters reference(network_params); |
| 149 return (arg->bandwidth_estimate_bytes_per_second() == | 159 return (arg->bandwidth_estimate_bytes_per_second() == |
| 150 reference.bandwidth_estimate_bytes_per_second() && | 160 reference.bandwidth_estimate_bytes_per_second() && |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 EXPECT_FALSE( | 522 EXPECT_FALSE( |
| 513 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 523 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 514 session_->OnConfigNegotiated(); | 524 session_->OnConfigNegotiated(); |
| 515 EXPECT_FALSE( | 525 EXPECT_FALSE( |
| 516 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 526 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 517 } | 527 } |
| 518 | 528 |
| 519 } // namespace | 529 } // namespace |
| 520 } // namespace test | 530 } // namespace test |
| 521 } // namespace net | 531 } // namespace net |
| OLD | NEW |