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

Side by Side Diff: net/quic/quic_http_stream_test.cc

Issue 475113005: Refactoring: Create per-connection packet writers in QuicDispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add new files to net/BUILD.gn Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_dispatcher.cc ('k') | net/quic/quic_per_connection_packet_writer.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic_http_stream.h" 5 #include "net/quic/quic_http_stream.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/test_completion_callback.h" 10 #include "net/base/test_completion_callback.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const char kUploadData[] = "hello world!"; 52 const char kUploadData[] = "hello world!";
53 const char kServerHostname[] = "www.google.com"; 53 const char kServerHostname[] = "www.google.com";
54 const uint16 kServerPort = 80; 54 const uint16 kServerPort = 80;
55 55
56 class TestQuicConnection : public QuicConnection { 56 class TestQuicConnection : public QuicConnection {
57 public: 57 public:
58 TestQuicConnection(const QuicVersionVector& versions, 58 TestQuicConnection(const QuicVersionVector& versions,
59 QuicConnectionId connection_id, 59 QuicConnectionId connection_id,
60 IPEndPoint address, 60 IPEndPoint address,
61 QuicConnectionHelper* helper, 61 QuicConnectionHelper* helper,
62 QuicPacketWriter* writer) 62 const QuicConnection::PacketWriterFactory& writer_factory)
63 : QuicConnection(connection_id, 63 : QuicConnection(connection_id,
64 address, 64 address,
65 helper, 65 helper,
66 writer, 66 writer_factory,
67 false /* owns_writer */, 67 true /* owns_writer */,
68 false /* is_server */, 68 false /* is_server */,
69 versions) { 69 versions) {
70 } 70 }
71 71
72 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { 72 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
73 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); 73 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
74 } 74 }
75 75
76 void SetReceiveAlgorithm(ReceiveAlgorithmInterface* receive_algorithm) { 76 void SetReceiveAlgorithm(ReceiveAlgorithmInterface* receive_algorithm) {
77 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm); 77 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm);
(...skipping 18 matching lines...) Expand all
96 explicit AutoClosingStream(const base::WeakPtr<QuicClientSession>& session) 96 explicit AutoClosingStream(const base::WeakPtr<QuicClientSession>& session)
97 : QuicHttpStream(session) { 97 : QuicHttpStream(session) {
98 } 98 }
99 99
100 virtual int OnDataReceived(const char* data, int length) OVERRIDE { 100 virtual int OnDataReceived(const char* data, int length) OVERRIDE {
101 Close(false); 101 Close(false);
102 return OK; 102 return OK;
103 } 103 }
104 }; 104 };
105 105
106 class TestPacketWriterFactory : public QuicConnection::PacketWriterFactory {
107 public:
108 explicit TestPacketWriterFactory(DatagramClientSocket* socket)
109 : socket_(socket) {}
110 virtual ~TestPacketWriterFactory() {}
111
112 virtual QuicPacketWriter* Create(QuicConnection* connection) const OVERRIDE {
113 return new QuicDefaultPacketWriter(socket_);
114 }
115
116 private:
117 DatagramClientSocket* socket_;
118 };
119
106 } // namespace 120 } // namespace
107 121
108 class QuicHttpStreamPeer { 122 class QuicHttpStreamPeer {
109 public: 123 public:
110 static QuicReliableClientStream* GetQuicReliableClientStream( 124 static QuicReliableClientStream* GetQuicReliableClientStream(
111 QuicHttpStream* stream) { 125 QuicHttpStream* stream) {
112 return stream->stream_; 126 return stream->stream_;
113 } 127 }
114 }; 128 };
115 129
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 Return(QuicTime::Delta::Zero())); 209 Return(QuicTime::Delta::Zero()));
196 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( 210 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
197 Return(kMaxPacketSize)); 211 Return(kMaxPacketSize));
198 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)). 212 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).
199 WillRepeatedly(Return(QuicTime::Delta::Zero())); 213 WillRepeatedly(Return(QuicTime::Delta::Zero()));
200 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly( 214 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(
201 Return(QuicBandwidth::Zero())); 215 Return(QuicBandwidth::Zero()));
202 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber()); 216 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber());
203 helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_, 217 helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_,
204 &random_generator_)); 218 &random_generator_));
205 writer_.reset(new QuicDefaultPacketWriter(socket)); 219 TestPacketWriterFactory writer_factory(socket);
206 connection_ = new TestQuicConnection(SupportedVersions(GetParam()), 220 connection_ = new TestQuicConnection(SupportedVersions(GetParam()),
207 connection_id_, peer_addr_, 221 connection_id_, peer_addr_,
208 helper_.get(), writer_.get()); 222 helper_.get(), writer_factory);
209 connection_->set_visitor(&visitor_); 223 connection_->set_visitor(&visitor_);
210 connection_->SetSendAlgorithm(send_algorithm_); 224 connection_->SetSendAlgorithm(send_algorithm_);
211 connection_->SetReceiveAlgorithm(receive_algorithm_); 225 connection_->SetReceiveAlgorithm(receive_algorithm_);
212 crypto_config_.SetDefaults(); 226 crypto_config_.SetDefaults();
213 session_.reset( 227 session_.reset(
214 new QuicClientSession(connection_, 228 new QuicClientSession(connection_,
215 scoped_ptr<DatagramClientSocket>(socket), 229 scoped_ptr<DatagramClientSocket>(socket),
216 writer_.Pass(), NULL, 230 NULL,
217 &crypto_client_stream_factory_, 231 &crypto_client_stream_factory_,
218 &transport_security_state_, 232 &transport_security_state_,
219 make_scoped_ptr((QuicServerInfo*)NULL), 233 make_scoped_ptr((QuicServerInfo*)NULL),
220 QuicServerId(kServerHostname, kServerPort, 234 QuicServerId(kServerHostname, kServerPort,
221 false, PRIVACY_MODE_DISABLED), 235 false, PRIVACY_MODE_DISABLED),
222 DefaultQuicConfig(), &crypto_config_, 236 DefaultQuicConfig(), &crypto_config_,
223 base::MessageLoop::current()-> 237 base::MessageLoop::current()->
224 message_loop_proxy().get(), 238 message_loop_proxy().get(),
225 NULL)); 239 NULL));
226 session_->InitializeSession(); 240 session_->InitializeSession();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool use_closing_stream_; 307 bool use_closing_stream_;
294 MockSendAlgorithm* send_algorithm_; 308 MockSendAlgorithm* send_algorithm_;
295 TestReceiveAlgorithm* receive_algorithm_; 309 TestReceiveAlgorithm* receive_algorithm_;
296 scoped_refptr<TestTaskRunner> runner_; 310 scoped_refptr<TestTaskRunner> runner_;
297 scoped_ptr<MockWrite[]> mock_writes_; 311 scoped_ptr<MockWrite[]> mock_writes_;
298 MockClock clock_; 312 MockClock clock_;
299 TestQuicConnection* connection_; 313 TestQuicConnection* connection_;
300 scoped_ptr<QuicConnectionHelper> helper_; 314 scoped_ptr<QuicConnectionHelper> helper_;
301 testing::StrictMock<MockConnectionVisitor> visitor_; 315 testing::StrictMock<MockConnectionVisitor> visitor_;
302 scoped_ptr<QuicHttpStream> stream_; 316 scoped_ptr<QuicHttpStream> stream_;
303 scoped_ptr<QuicDefaultPacketWriter> writer_;
304 TransportSecurityState transport_security_state_; 317 TransportSecurityState transport_security_state_;
305 scoped_ptr<QuicClientSession> session_; 318 scoped_ptr<QuicClientSession> session_;
306 QuicCryptoClientConfig crypto_config_; 319 QuicCryptoClientConfig crypto_config_;
307 TestCompletionCallback callback_; 320 TestCompletionCallback callback_;
308 HttpRequestInfo request_; 321 HttpRequestInfo request_;
309 HttpRequestHeaders headers_; 322 HttpRequestHeaders headers_;
310 HttpResponseInfo response_; 323 HttpResponseInfo response_;
311 scoped_refptr<IOBufferWithSize> read_buffer_; 324 scoped_refptr<IOBufferWithSize> read_buffer_;
312 SpdyHeaderBlock request_headers_; 325 SpdyHeaderBlock request_headers_;
313 SpdyHeaderBlock response_headers_; 326 SpdyHeaderBlock response_headers_;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 // Set Delegate to NULL and make sure EffectivePriority returns highest 634 // Set Delegate to NULL and make sure EffectivePriority returns highest
622 // priority. 635 // priority.
623 reliable_stream->SetDelegate(NULL); 636 reliable_stream->SetDelegate(NULL);
624 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, 637 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority,
625 reliable_stream->EffectivePriority()); 638 reliable_stream->EffectivePriority());
626 reliable_stream->SetDelegate(delegate); 639 reliable_stream->SetDelegate(delegate);
627 } 640 }
628 641
629 } // namespace test 642 } // namespace test
630 } // namespace net 643 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_dispatcher.cc ('k') | net/quic/quic_per_connection_packet_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698