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/chunked_upload_data_stream.h" | 9 #include "net/base/chunked_upload_data_stream.h" |
10 #include "net/base/elements_upload_data_stream.h" | 10 #include "net/base/elements_upload_data_stream.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 using testing::_; | 44 using testing::_; |
45 using testing::AnyNumber; | 45 using testing::AnyNumber; |
46 using testing::Return; | 46 using testing::Return; |
47 | 47 |
48 namespace net { | 48 namespace net { |
49 namespace test { | 49 namespace test { |
50 namespace { | 50 namespace { |
51 | 51 |
52 const char kUploadData[] = "Really nifty data!"; | 52 const char kUploadData[] = "Really nifty data!"; |
53 const char kServerHostname[] = "www.google.com"; | 53 const char kDefaultServerHostName[] = "www.google.com"; |
54 const uint16 kServerPort = 80; | 54 const uint16 kDefaultServerPort = 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 const QuicConnection::PacketWriterFactory& writer_factory) | 62 const QuicConnection::PacketWriterFactory& writer_factory) |
63 : QuicConnection(connection_id, | 63 : QuicConnection(connection_id, |
64 address, | 64 address, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 IoMode mode; | 128 IoMode mode; |
129 QuicEncryptedPacket* packet; | 129 QuicEncryptedPacket* packet; |
130 }; | 130 }; |
131 | 131 |
132 QuicHttpStreamTest() | 132 QuicHttpStreamTest() |
133 : net_log_(BoundNetLog()), | 133 : net_log_(BoundNetLog()), |
134 use_closing_stream_(false), | 134 use_closing_stream_(false), |
135 read_buffer_(new IOBufferWithSize(4096)), | 135 read_buffer_(new IOBufferWithSize(4096)), |
136 connection_id_(2), | 136 connection_id_(2), |
137 stream_id_(kClientDataStreamId1), | 137 stream_id_(kClientDataStreamId1), |
138 maker_(GetParam(), connection_id_, &clock_), | 138 maker_(GetParam(), connection_id_, &clock_, kDefaultServerHostName), |
139 random_generator_(0) { | 139 random_generator_(0) { |
140 IPAddressNumber ip; | 140 IPAddressNumber ip; |
141 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip)); | 141 CHECK(ParseIPLiteralToNumber("192.0.2.33", &ip)); |
142 peer_addr_ = IPEndPoint(ip, 443); | 142 peer_addr_ = IPEndPoint(ip, 443); |
143 self_addr_ = IPEndPoint(ip, 8435); | 143 self_addr_ = IPEndPoint(ip, 8435); |
144 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(20)); | 144 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(20)); |
145 } | 145 } |
146 | 146 |
147 ~QuicHttpStreamTest() { | 147 ~QuicHttpStreamTest() { |
148 session_->CloseSessionOnError(ERR_ABORTED, QUIC_INTERNAL_ERROR); | 148 session_->CloseSessionOnError(ERR_ABORTED, QUIC_INTERNAL_ERROR); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 connection_ = new TestQuicConnection(SupportedVersions(GetParam()), | 203 connection_ = new TestQuicConnection(SupportedVersions(GetParam()), |
204 connection_id_, peer_addr_, | 204 connection_id_, peer_addr_, |
205 helper_.get(), writer_factory); | 205 helper_.get(), writer_factory); |
206 connection_->set_visitor(&visitor_); | 206 connection_->set_visitor(&visitor_); |
207 connection_->SetSendAlgorithm(send_algorithm_); | 207 connection_->SetSendAlgorithm(send_algorithm_); |
208 session_.reset(new QuicClientSession( | 208 session_.reset(new QuicClientSession( |
209 connection_, scoped_ptr<DatagramClientSocket>(socket), nullptr, | 209 connection_, scoped_ptr<DatagramClientSocket>(socket), nullptr, |
210 &transport_security_state_, make_scoped_ptr((QuicServerInfo*)nullptr), | 210 &transport_security_state_, make_scoped_ptr((QuicServerInfo*)nullptr), |
211 DefaultQuicConfig(), "CONNECTION_UNKNOWN", base::TimeTicks::Now(), | 211 DefaultQuicConfig(), "CONNECTION_UNKNOWN", base::TimeTicks::Now(), |
212 base::MessageLoop::current()->message_loop_proxy().get(), nullptr)); | 212 base::MessageLoop::current()->message_loop_proxy().get(), nullptr)); |
213 session_->InitializeSession(QuicServerId(kServerHostname, kServerPort, | 213 session_->InitializeSession( |
214 /*is_secure=*/false, | 214 QuicServerId(kDefaultServerHostName, kDefaultServerPort, |
215 PRIVACY_MODE_DISABLED), | 215 /*is_secure=*/false, PRIVACY_MODE_DISABLED), |
216 &crypto_config_, | 216 &crypto_config_, &crypto_client_stream_factory_); |
217 &crypto_client_stream_factory_); | |
218 session_->GetCryptoStream()->CryptoConnect(); | 217 session_->GetCryptoStream()->CryptoConnect(); |
219 EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed()); | 218 EXPECT_TRUE(session_->IsCryptoHandshakeConfirmed()); |
220 stream_.reset(use_closing_stream_ ? | 219 stream_.reset(use_closing_stream_ ? |
221 new AutoClosingStream(session_->GetWeakPtr()) : | 220 new AutoClosingStream(session_->GetWeakPtr()) : |
222 new QuicHttpStream(session_->GetWeakPtr())); | 221 new QuicHttpStream(session_->GetWeakPtr())); |
223 } | 222 } |
224 | 223 |
225 void SetRequest(const std::string& method, | 224 void SetRequest(const std::string& method, |
226 const std::string& path, | 225 const std::string& path, |
227 RequestPriority priority) { | 226 RequestPriority priority) { |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 // Set Delegate to nullptr and make sure EffectivePriority returns highest | 751 // Set Delegate to nullptr and make sure EffectivePriority returns highest |
753 // priority. | 752 // priority. |
754 reliable_stream->SetDelegate(nullptr); | 753 reliable_stream->SetDelegate(nullptr); |
755 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, | 754 DCHECK_EQ(QuicWriteBlockedList::kHighestPriority, |
756 reliable_stream->EffectivePriority()); | 755 reliable_stream->EffectivePriority()); |
757 reliable_stream->SetDelegate(delegate); | 756 reliable_stream->SetDelegate(delegate); |
758 } | 757 } |
759 | 758 |
760 } // namespace test | 759 } // namespace test |
761 } // namespace net | 760 } // namespace net |
OLD | NEW |