OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 namespace net { | 46 namespace net { |
47 namespace test { | 47 namespace test { |
48 namespace { | 48 namespace { |
49 | 49 |
50 const char kUploadData[] = "hello world!"; | 50 const char kUploadData[] = "hello world!"; |
51 | 51 |
52 class TestQuicConnection : public QuicConnection { | 52 class TestQuicConnection : public QuicConnection { |
53 public: | 53 public: |
54 TestQuicConnection(const QuicVersionVector& versions, | 54 TestQuicConnection(const QuicVersionVector& versions, |
55 QuicGuid guid, | 55 QuicConnectionId connection_id, |
56 IPEndPoint address, | 56 IPEndPoint address, |
57 QuicConnectionHelper* helper, | 57 QuicConnectionHelper* helper, |
58 QuicPacketWriter* writer) | 58 QuicPacketWriter* writer) |
59 : QuicConnection(guid, address, helper, writer, false, versions) { | 59 : QuicConnection(connection_id, address, helper, writer, false, |
| 60 versions) { |
60 } | 61 } |
61 | 62 |
62 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { | 63 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { |
63 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); | 64 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); |
64 } | 65 } |
65 | 66 |
66 void SetReceiveAlgorithm(ReceiveAlgorithmInterface* receive_algorithm) { | 67 void SetReceiveAlgorithm(ReceiveAlgorithmInterface* receive_algorithm) { |
67 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm); | 68 QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm); |
68 } | 69 } |
69 }; | 70 }; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 packet(packet) { | 118 packet(packet) { |
118 } | 119 } |
119 IoMode mode; | 120 IoMode mode; |
120 QuicEncryptedPacket* packet; | 121 QuicEncryptedPacket* packet; |
121 }; | 122 }; |
122 | 123 |
123 QuicHttpStreamTest() | 124 QuicHttpStreamTest() |
124 : net_log_(BoundNetLog()), | 125 : net_log_(BoundNetLog()), |
125 use_closing_stream_(false), | 126 use_closing_stream_(false), |
126 read_buffer_(new IOBufferWithSize(4096)), | 127 read_buffer_(new IOBufferWithSize(4096)), |
127 guid_(2), | 128 connection_id_(2), |
128 stream_id_(GetParam() > QUIC_VERSION_12 ? 5 : 3), | 129 stream_id_(GetParam() > QUIC_VERSION_12 ? 5 : 3), |
129 maker_(GetParam(), guid_), | 130 maker_(GetParam(), connection_id_), |
130 random_generator_(0) { | 131 random_generator_(0) { |
131 IPAddressNumber ip; | 132 IPAddressNumber ip; |
132 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip)); | 133 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip)); |
133 peer_addr_ = IPEndPoint(ip, 443); | 134 peer_addr_ = IPEndPoint(ip, 443); |
134 self_addr_ = IPEndPoint(ip, 8435); | 135 self_addr_ = IPEndPoint(ip, 8435); |
135 } | 136 } |
136 | 137 |
137 ~QuicHttpStreamTest() { | 138 ~QuicHttpStreamTest() { |
138 session_->CloseSessionOnError(ERR_ABORTED); | 139 session_->CloseSessionOnError(ERR_ABORTED); |
139 for (size_t i = 0; i < writes_.size(); i++) { | 140 for (size_t i = 0; i < writes_.size(); i++) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _, _)). | 187 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _, _)). |
187 WillRepeatedly(Return(QuicTime::Delta::Zero())); | 188 WillRepeatedly(Return(QuicTime::Delta::Zero())); |
188 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly( | 189 EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly( |
189 Return(QuicTime::Delta::Zero())); | 190 Return(QuicTime::Delta::Zero())); |
190 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly( | 191 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly( |
191 Return(QuicBandwidth::Zero())); | 192 Return(QuicBandwidth::Zero())); |
192 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber()); | 193 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber()); |
193 helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_, | 194 helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_, |
194 &random_generator_)); | 195 &random_generator_)); |
195 writer_.reset(new QuicDefaultPacketWriter(socket)); | 196 writer_.reset(new QuicDefaultPacketWriter(socket)); |
196 connection_ = new TestQuicConnection(SupportedVersions(GetParam()), guid_, | 197 connection_ = new TestQuicConnection(SupportedVersions(GetParam()), |
197 peer_addr_, helper_.get(), | 198 connection_id_, peer_addr_, |
198 writer_.get()); | 199 helper_.get(), writer_.get()); |
199 connection_->set_visitor(&visitor_); | 200 connection_->set_visitor(&visitor_); |
200 connection_->SetSendAlgorithm(send_algorithm_); | 201 connection_->SetSendAlgorithm(send_algorithm_); |
201 connection_->SetReceiveAlgorithm(receive_algorithm_); | 202 connection_->SetReceiveAlgorithm(receive_algorithm_); |
202 crypto_config_.SetDefaults(); | 203 crypto_config_.SetDefaults(); |
203 session_.reset( | 204 session_.reset( |
204 new QuicClientSession(connection_, | 205 new QuicClientSession(connection_, |
205 scoped_ptr<DatagramClientSocket>(socket), | 206 scoped_ptr<DatagramClientSocket>(socket), |
206 writer_.Pass(), NULL, | 207 writer_.Pass(), NULL, |
207 &crypto_client_stream_factory_, | 208 &crypto_client_stream_factory_, |
208 "www.google.com", DefaultQuicConfig(), | 209 "www.google.com", DefaultQuicConfig(), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 bool write_priority, | 308 bool write_priority, |
308 RequestPriority priority) { | 309 RequestPriority priority) { |
309 QuicSpdyCompressor compressor; | 310 QuicSpdyCompressor compressor; |
310 if (write_priority) { | 311 if (write_priority) { |
311 return compressor.CompressHeadersWithPriority( | 312 return compressor.CompressHeadersWithPriority( |
312 ConvertRequestPriorityToQuicPriority(priority), headers); | 313 ConvertRequestPriorityToQuicPriority(priority), headers); |
313 } | 314 } |
314 return compressor.CompressHeaders(headers); | 315 return compressor.CompressHeaders(headers); |
315 } | 316 } |
316 | 317 |
317 const QuicGuid guid_; | 318 const QuicConnectionId connection_id_; |
318 const QuicStreamId stream_id_; | 319 const QuicStreamId stream_id_; |
319 QuicTestPacketMaker maker_; | 320 QuicTestPacketMaker maker_; |
320 IPEndPoint self_addr_; | 321 IPEndPoint self_addr_; |
321 IPEndPoint peer_addr_; | 322 IPEndPoint peer_addr_; |
322 MockRandom random_generator_; | 323 MockRandom random_generator_; |
323 MockCryptoClientStreamFactory crypto_client_stream_factory_; | 324 MockCryptoClientStreamFactory crypto_client_stream_factory_; |
324 scoped_ptr<StaticSocketDataProvider> socket_data_; | 325 scoped_ptr<StaticSocketDataProvider> socket_data_; |
325 std::vector<PacketToWrite> writes_; | 326 std::vector<PacketToWrite> writes_; |
326 }; | 327 }; |
327 | 328 |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 WillRepeatedly(Return(QuicTime::Delta::Zero())); | 763 WillRepeatedly(Return(QuicTime::Delta::Zero())); |
763 | 764 |
764 // Data should flush out now. | 765 // Data should flush out now. |
765 connection_->OnCanWrite(); | 766 connection_->OnCanWrite(); |
766 EXPECT_FALSE(reliable_stream->HasBufferedData()); | 767 EXPECT_FALSE(reliable_stream->HasBufferedData()); |
767 EXPECT_TRUE(AtEof()); | 768 EXPECT_TRUE(AtEof()); |
768 } | 769 } |
769 | 770 |
770 } // namespace test | 771 } // namespace test |
771 } // namespace net | 772 } // namespace net |
OLD | NEW |