Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: net/quic/core/quic_server_session_base_test.cc

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_server_session_base.h ('k') | net/quic/core/quic_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 namespace { 77 namespace {
78 78
79 class TestServerSession : public QuicServerSessionBase { 79 class TestServerSession : public QuicServerSessionBase {
80 public: 80 public:
81 TestServerSession(const QuicConfig& config, 81 TestServerSession(const QuicConfig& config,
82 QuicConnection* connection, 82 QuicConnection* connection,
83 QuicSession::Visitor* visitor, 83 QuicSession::Visitor* visitor,
84 QuicCryptoServerStream::Helper* helper, 84 QuicCryptoServerStream::Helper* helper,
85 const QuicCryptoServerConfig* crypto_config, 85 const QuicCryptoServerConfig* crypto_config,
86 QuicCompressedCertsCache* compressed_certs_cache, 86 QuicCompressedCertsCache* compressed_certs_cache,
87 QuicInMemoryCache* in_memory_cache) 87 QuicHttpResponseCache* response_cache)
88 : QuicServerSessionBase(config, 88 : QuicServerSessionBase(config,
89 connection, 89 connection,
90 visitor, 90 visitor,
91 helper, 91 helper,
92 crypto_config, 92 crypto_config,
93 compressed_certs_cache), 93 compressed_certs_cache),
94 in_memory_cache_(in_memory_cache) {} 94 response_cache_(response_cache) {}
95 95
96 ~TestServerSession() override { delete connection(); }; 96 ~TestServerSession() override { delete connection(); };
97 97
98 protected: 98 protected:
99 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { 99 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override {
100 if (!ShouldCreateIncomingDynamicStream(id)) { 100 if (!ShouldCreateIncomingDynamicStream(id)) {
101 return nullptr; 101 return nullptr;
102 } 102 }
103 QuicSpdyStream* stream = 103 QuicSpdyStream* stream =
104 new QuicSimpleServerStream(id, this, in_memory_cache_); 104 new QuicSimpleServerStream(id, this, response_cache_);
105 ActivateStream(base::WrapUnique(stream)); 105 ActivateStream(base::WrapUnique(stream));
106 return stream; 106 return stream;
107 } 107 }
108 108
109 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { 109 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override {
110 if (!ShouldCreateOutgoingDynamicStream()) { 110 if (!ShouldCreateOutgoingDynamicStream()) {
111 return nullptr; 111 return nullptr;
112 } 112 }
113 113
114 QuicSpdyStream* stream = new QuicSimpleServerStream( 114 QuicSpdyStream* stream = new QuicSimpleServerStream(
115 GetNextOutgoingStreamId(), this, in_memory_cache_); 115 GetNextOutgoingStreamId(), this, response_cache_);
116 stream->SetPriority(priority); 116 stream->SetPriority(priority);
117 ActivateStream(base::WrapUnique(stream)); 117 ActivateStream(base::WrapUnique(stream));
118 return stream; 118 return stream;
119 } 119 }
120 120
121 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( 121 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream(
122 const QuicCryptoServerConfig* crypto_config, 122 const QuicCryptoServerConfig* crypto_config,
123 QuicCompressedCertsCache* compressed_certs_cache) override { 123 QuicCompressedCertsCache* compressed_certs_cache) override {
124 return new QuicCryptoServerStream( 124 return new QuicCryptoServerStream(
125 crypto_config, compressed_certs_cache, 125 crypto_config, compressed_certs_cache,
126 FLAGS_enable_quic_stateless_reject_support, this, stream_helper()); 126 FLAGS_enable_quic_stateless_reject_support, this, stream_helper());
127 } 127 }
128 128
129 private: 129 private:
130 QuicInMemoryCache* in_memory_cache_; // Owned by QuicServerSessionBaseTest. 130 QuicHttpResponseCache* response_cache_; // Owned by QuicServerSessionBaseTest
131 }; 131 };
132 132
133 const size_t kMaxStreamsForTest = 10; 133 const size_t kMaxStreamsForTest = 10;
134 134
135 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { 135 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> {
136 protected: 136 protected:
137 QuicServerSessionBaseTest() 137 QuicServerSessionBaseTest()
138 : QuicServerSessionBaseTest(CryptoTestUtils::ProofSourceForTesting()) {} 138 : QuicServerSessionBaseTest(CryptoTestUtils::ProofSourceForTesting()) {}
139 139
140 explicit QuicServerSessionBaseTest(std::unique_ptr<ProofSource> proof_source) 140 explicit QuicServerSessionBaseTest(std::unique_ptr<ProofSource> proof_source)
141 : crypto_config_(QuicCryptoServerConfig::TESTING, 141 : crypto_config_(QuicCryptoServerConfig::TESTING,
142 QuicRandom::GetInstance(), 142 QuicRandom::GetInstance(),
143 std::move(proof_source)), 143 std::move(proof_source)),
144 compressed_certs_cache_( 144 compressed_certs_cache_(
145 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { 145 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) {
146 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); 146 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest);
147 config_.SetMaxIncomingDynamicStreamsToSend(kMaxStreamsForTest); 147 config_.SetMaxIncomingDynamicStreamsToSend(kMaxStreamsForTest);
148 QuicConfigPeer::SetReceivedMaxIncomingDynamicStreams(&config_, 148 QuicConfigPeer::SetReceivedMaxIncomingDynamicStreams(&config_,
149 kMaxStreamsForTest); 149 kMaxStreamsForTest);
150 config_.SetInitialStreamFlowControlWindowToSend( 150 config_.SetInitialStreamFlowControlWindowToSend(
151 kInitialStreamFlowControlWindowForTest); 151 kInitialStreamFlowControlWindowForTest);
152 config_.SetInitialSessionFlowControlWindowToSend( 152 config_.SetInitialSessionFlowControlWindowToSend(
153 kInitialSessionFlowControlWindowForTest); 153 kInitialSessionFlowControlWindowForTest);
154 154
155 connection_ = new StrictMock<MockQuicConnection>( 155 connection_ = new StrictMock<MockQuicConnection>(
156 &helper_, &alarm_factory_, Perspective::IS_SERVER, 156 &helper_, &alarm_factory_, Perspective::IS_SERVER,
157 SupportedVersions(GetParam())); 157 SupportedVersions(GetParam()));
158 session_.reset(new TestServerSession( 158 session_.reset(new TestServerSession(
159 config_, connection_, &owner_, &stream_helper_, &crypto_config_, 159 config_, connection_, &owner_, &stream_helper_, &crypto_config_,
160 &compressed_certs_cache_, &in_memory_cache_)); 160 &compressed_certs_cache_, &response_cache_));
161 MockClock clock; 161 MockClock clock;
162 handshake_message_.reset(crypto_config_.AddDefaultConfig( 162 handshake_message_.reset(crypto_config_.AddDefaultConfig(
163 QuicRandom::GetInstance(), &clock, 163 QuicRandom::GetInstance(), &clock,
164 QuicCryptoServerConfig::ConfigOptions())); 164 QuicCryptoServerConfig::ConfigOptions()));
165 session_->Initialize(); 165 session_->Initialize();
166 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 166 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
167 } 167 }
168 168
169 StrictMock<MockQuicSessionVisitor> owner_; 169 StrictMock<MockQuicSessionVisitor> owner_;
170 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_; 170 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_;
171 MockQuicConnectionHelper helper_; 171 MockQuicConnectionHelper helper_;
172 MockAlarmFactory alarm_factory_; 172 MockAlarmFactory alarm_factory_;
173 StrictMock<MockQuicConnection>* connection_; 173 StrictMock<MockQuicConnection>* connection_;
174 QuicConfig config_; 174 QuicConfig config_;
175 QuicCryptoServerConfig crypto_config_; 175 QuicCryptoServerConfig crypto_config_;
176 QuicCompressedCertsCache compressed_certs_cache_; 176 QuicCompressedCertsCache compressed_certs_cache_;
177 QuicInMemoryCache in_memory_cache_; 177 QuicHttpResponseCache response_cache_;
178 std::unique_ptr<TestServerSession> session_; 178 std::unique_ptr<TestServerSession> session_;
179 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; 179 std::unique_ptr<CryptoHandshakeMessage> handshake_message_;
180 QuicConnectionVisitorInterface* visitor_; 180 QuicConnectionVisitorInterface* visitor_;
181 QuicFlagSaver flags_; // Save/restore all QUIC flag values. 181 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
182 }; 182 };
183 183
184 // Compares CachedNetworkParameters. 184 // Compares CachedNetworkParameters.
185 MATCHER_P(EqualsProto, network_params, "") { 185 MATCHER_P(EqualsProto, network_params, "") {
186 CachedNetworkParameters reference(network_params); 186 CachedNetworkParameters reference(network_params);
187 return (arg->bandwidth_estimate_bytes_per_second() == 187 return (arg->bandwidth_estimate_bytes_per_second() ==
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 655
656 // Allow the async ProofSource::GetProof call to complete. Verify (under 656 // Allow the async ProofSource::GetProof call to complete. Verify (under
657 // asan) that this does not result in accesses to any freed memory from the 657 // asan) that this does not result in accesses to any freed memory from the
658 // session or its subobjects. 658 // session or its subobjects.
659 GetFakeProofSource()->InvokePendingCallback(0); 659 GetFakeProofSource()->InvokePendingCallback(0);
660 } 660 }
661 661
662 } // namespace 662 } // namespace
663 } // namespace test 663 } // namespace test
664 } // namespace net 664 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_server_session_base.h ('k') | net/quic/core/quic_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698