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

Side by Side Diff: net/tools/quic/quic_simple_server_session_test.cc

Issue 1898793003: Make QuicDispatcher's helper and alarm factory arguments unique_ptrs to make ownership clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119871679
Patch Set: fixing rebase Created 4 years, 8 months 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/tools/quic/quic_simple_server.cc ('k') | net/tools/quic/quic_simple_server_stream_test.cc » ('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/tools/quic/quic_simple_server_session.h" 5 #include "net/tools/quic/quic_simple_server_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 encryption_established_ = has_established; 98 encryption_established_ = has_established;
99 } 99 }
100 100
101 private: 101 private:
102 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream); 102 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream);
103 }; 103 };
104 104
105 class MockConnectionWithSendStreamData : public MockConnection { 105 class MockConnectionWithSendStreamData : public MockConnection {
106 public: 106 public:
107 MockConnectionWithSendStreamData(MockConnectionHelper* helper, 107 MockConnectionWithSendStreamData(MockConnectionHelper* helper,
108 MockAlarmFactory* alarm_factory,
108 Perspective perspective, 109 Perspective perspective,
109 const QuicVersionVector& supported_versions) 110 const QuicVersionVector& supported_versions)
110 : MockConnection(helper, perspective, supported_versions) {} 111 : MockConnection(helper, alarm_factory, perspective, supported_versions) {
112 }
111 113
112 MOCK_METHOD5(SendStreamData, 114 MOCK_METHOD5(SendStreamData,
113 QuicConsumedData(QuicStreamId id, 115 QuicConsumedData(QuicStreamId id,
114 QuicIOVector iov, 116 QuicIOVector iov,
115 QuicStreamOffset offset, 117 QuicStreamOffset offset,
116 bool fin, 118 bool fin,
117 QuicAckListenerInterface* listern)); 119 QuicAckListenerInterface* listern));
118 }; 120 };
119 121
120 class QuicSimpleServerSessionPeer { 122 class QuicSimpleServerSessionPeer {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 compressed_certs_cache_( 162 compressed_certs_cache_(
161 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { 163 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) {
162 FLAGS_quic_always_log_bugs_for_tests = true; 164 FLAGS_quic_always_log_bugs_for_tests = true;
163 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); 165 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest);
164 config_.SetInitialStreamFlowControlWindowToSend( 166 config_.SetInitialStreamFlowControlWindowToSend(
165 kInitialStreamFlowControlWindowForTest); 167 kInitialStreamFlowControlWindowForTest);
166 config_.SetInitialSessionFlowControlWindowToSend( 168 config_.SetInitialSessionFlowControlWindowToSend(
167 kInitialSessionFlowControlWindowForTest); 169 kInitialSessionFlowControlWindowForTest);
168 170
169 connection_ = new StrictMock<MockConnectionWithSendStreamData>( 171 connection_ = new StrictMock<MockConnectionWithSendStreamData>(
170 &helper_, Perspective::IS_SERVER, SupportedVersions(GetParam())); 172 &helper_, &alarm_factory_, Perspective::IS_SERVER,
173 SupportedVersions(GetParam()));
171 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_, 174 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_,
172 &crypto_config_, 175 &crypto_config_,
173 &compressed_certs_cache_)); 176 &compressed_certs_cache_));
174 MockClock clock; 177 MockClock clock;
175 handshake_message_.reset(crypto_config_.AddDefaultConfig( 178 handshake_message_.reset(crypto_config_.AddDefaultConfig(
176 QuicRandom::GetInstance(), &clock, 179 QuicRandom::GetInstance(), &clock,
177 QuicCryptoServerConfig::ConfigOptions())); 180 QuicCryptoServerConfig::ConfigOptions()));
178 session_->Initialize(); 181 session_->Initialize();
179 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 182 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
180 headers_stream_ = new MockQuicHeadersStream(session_.get()); 183 headers_stream_ = new MockQuicHeadersStream(session_.get());
181 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_); 184 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_);
182 // TODO(jri): Remove this line once tests pass. 185 // TODO(jri): Remove this line once tests pass.
183 FLAGS_quic_cede_correctly = false; 186 FLAGS_quic_cede_correctly = false;
184 } 187 }
185 188
186 StrictMock<MockQuicServerSessionVisitor> owner_; 189 StrictMock<MockQuicServerSessionVisitor> owner_;
187 MockConnectionHelper helper_; 190 MockConnectionHelper helper_;
191 MockAlarmFactory alarm_factory_;
188 StrictMock<MockConnectionWithSendStreamData>* connection_; 192 StrictMock<MockConnectionWithSendStreamData>* connection_;
189 QuicConfig config_; 193 QuicConfig config_;
190 QuicCryptoServerConfig crypto_config_; 194 QuicCryptoServerConfig crypto_config_;
191 QuicCompressedCertsCache compressed_certs_cache_; 195 QuicCompressedCertsCache compressed_certs_cache_;
192 scoped_ptr<QuicSimpleServerSession> session_; 196 scoped_ptr<QuicSimpleServerSession> session_;
193 scoped_ptr<CryptoHandshakeMessage> handshake_message_; 197 scoped_ptr<CryptoHandshakeMessage> handshake_message_;
194 QuicConnectionVisitorInterface* visitor_; 198 QuicConnectionVisitorInterface* visitor_;
195 MockQuicHeadersStream* headers_stream_; 199 MockQuicHeadersStream* headers_stream_;
196 }; 200 };
197 201
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // enough that it won't block any stream to write before stream level flow 399 // enough that it won't block any stream to write before stream level flow
396 // control blocks it. 400 // control blocks it.
397 QuicConfigPeer::SetReceivedInitialSessionFlowControlWindow( 401 QuicConfigPeer::SetReceivedInitialSessionFlowControlWindow(
398 &config_, kInitialSessionFlowControlWindowForTest); 402 &config_, kInitialSessionFlowControlWindowForTest);
399 // Enable server push. 403 // Enable server push.
400 QuicTagVector copt; 404 QuicTagVector copt;
401 copt.push_back(kSPSH); 405 copt.push_back(kSPSH);
402 QuicConfigPeer::SetReceivedConnectionOptions(&config_, copt); 406 QuicConfigPeer::SetReceivedConnectionOptions(&config_, copt);
403 407
404 connection_ = new StrictMock<MockConnectionWithSendStreamData>( 408 connection_ = new StrictMock<MockConnectionWithSendStreamData>(
405 &helper_, Perspective::IS_SERVER, SupportedVersions(GetParam())); 409 &helper_, &alarm_factory_, Perspective::IS_SERVER,
410 SupportedVersions(GetParam()));
406 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_, 411 session_.reset(new QuicSimpleServerSession(config_, connection_, &owner_,
407 &crypto_config_, 412 &crypto_config_,
408 &compressed_certs_cache_)); 413 &compressed_certs_cache_));
409 session_->Initialize(); 414 session_->Initialize();
410 // Needed to make new session flow control window and server push work. 415 // Needed to make new session flow control window and server push work.
411 session_->OnConfigNegotiated(); 416 session_->OnConfigNegotiated();
412 417
413 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 418 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
414 headers_stream_ = new MockQuicHeadersStream(session_.get()); 419 headers_stream_ = new MockQuicHeadersStream(session_.get());
415 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_); 420 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); 569 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false)));
565 570
566 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); 571 EXPECT_CALL(*connection_, SendBlocked(stream_to_open));
567 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); 572 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0);
568 visitor_->OnRstStream(rst); 573 visitor_->OnRstStream(rst);
569 } 574 }
570 575
571 } // namespace 576 } // namespace
572 } // namespace test 577 } // namespace test
573 } // namespace net 578 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server.cc ('k') | net/tools/quic/quic_simple_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698