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/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <ostream> | 8 #include <ostream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return QuicStreamFactoryPeer::HasActiveCertVerifierJob(factory_.get(), | 255 return QuicStreamFactoryPeer::HasActiveCertVerifierJob(factory_.get(), |
256 server_id); | 256 server_id); |
257 } | 257 } |
258 | 258 |
259 QuicChromiumClientSession* GetActiveSession( | 259 QuicChromiumClientSession* GetActiveSession( |
260 const HostPortPair& host_port_pair) { | 260 const HostPortPair& host_port_pair) { |
261 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED); | 261 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED); |
262 return QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server_id); | 262 return QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server_id); |
263 } | 263 } |
264 | 264 |
265 std::unique_ptr<QuicHttpStream> CreateFromSession( | |
266 const HostPortPair& host_port_pair) { | |
267 QuicChromiumClientSession* session = GetActiveSession(host_port_pair); | |
268 return QuicStreamFactoryPeer::CreateFromSession(factory_.get(), session); | |
269 } | |
270 | |
271 int GetSourcePortForNewSession(const HostPortPair& destination) { | 265 int GetSourcePortForNewSession(const HostPortPair& destination) { |
272 return GetSourcePortForNewSessionInner(destination, false); | 266 return GetSourcePortForNewSessionInner(destination, false); |
273 } | 267 } |
274 | 268 |
275 int GetSourcePortForNewSessionAndGoAway(const HostPortPair& destination) { | 269 int GetSourcePortForNewSessionAndGoAway(const HostPortPair& destination) { |
276 return GetSourcePortForNewSessionInner(destination, true); | 270 return GetSourcePortForNewSessionInner(destination, true); |
277 } | 271 } |
278 | 272 |
279 int GetSourcePortForNewSessionInner(const HostPortPair& destination, | 273 int GetSourcePortForNewSessionInner(const HostPortPair& destination, |
280 bool goaway_received) { | 274 bool goaway_received) { |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 QuicStreamRequest request(factory_.get(), &http_server_properties_); | 767 QuicStreamRequest request(factory_.get(), &http_server_properties_); |
774 EXPECT_EQ(ERR_IO_PENDING, | 768 EXPECT_EQ(ERR_IO_PENDING, |
775 request.Request(host_port_pair_, privacy_mode_, | 769 request.Request(host_port_pair_, privacy_mode_, |
776 /*cert_verify_flags=*/0, url_, "GET", net_log_, | 770 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
777 callback_.callback())); | 771 callback_.callback())); |
778 | 772 |
779 EXPECT_THAT(callback_.WaitForResult(), IsOk()); | 773 EXPECT_THAT(callback_.WaitForResult(), IsOk()); |
780 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); | 774 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); |
781 EXPECT_TRUE(stream.get()); | 775 EXPECT_TRUE(stream.get()); |
782 | 776 |
| 777 QuicStreamRequest request2(factory_.get(), &http_server_properties_); |
| 778 EXPECT_EQ(OK, request2.Request(host_port_pair_, privacy_mode_, |
| 779 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 780 callback_.callback())); |
783 // Will reset stream 3. | 781 // Will reset stream 3. |
784 stream = CreateFromSession(host_port_pair_); | 782 stream = request.CreateStream(); |
| 783 |
785 EXPECT_TRUE(stream.get()); | 784 EXPECT_TRUE(stream.get()); |
786 | 785 |
787 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result | 786 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result |
788 // in streams on different sessions. | 787 // in streams on different sessions. |
789 QuicStreamRequest request2(factory_.get(), &http_server_properties_); | 788 QuicStreamRequest request3(factory_.get(), &http_server_properties_); |
790 EXPECT_EQ(OK, request2.Request(host_port_pair_, privacy_mode_, | 789 EXPECT_EQ(OK, request3.Request(host_port_pair_, privacy_mode_, |
791 /*cert_verify_flags=*/0, url_, "GET", net_log_, | 790 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
792 callback_.callback())); | 791 callback_.callback())); |
793 stream = request2.CreateStream(); // Will reset stream 5. | 792 stream = request3.CreateStream(); // Will reset stream 5. |
794 stream.reset(); // Will reset stream 7. | 793 stream.reset(); // Will reset stream 7. |
795 | 794 |
796 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 795 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
797 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 796 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
798 } | 797 } |
799 | 798 |
800 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { | 799 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { |
801 Initialize(); | 800 Initialize(); |
802 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 801 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
803 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 802 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 { | 1524 { |
1526 QuicStreamRequest request(factory_.get(), &http_server_properties_); | 1525 QuicStreamRequest request(factory_.get(), &http_server_properties_); |
1527 EXPECT_EQ(ERR_IO_PENDING, | 1526 EXPECT_EQ(ERR_IO_PENDING, |
1528 request.Request(host_port_pair_, privacy_mode_, | 1527 request.Request(host_port_pair_, privacy_mode_, |
1529 /*cert_verify_flags=*/0, url_, "GET", net_log_, | 1528 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
1530 callback_.callback())); | 1529 callback_.callback())); |
1531 } | 1530 } |
1532 | 1531 |
1533 base::RunLoop().RunUntilIdle(); | 1532 base::RunLoop().RunUntilIdle(); |
1534 | 1533 |
1535 std::unique_ptr<QuicHttpStream> stream(CreateFromSession(host_port_pair_)); | 1534 QuicStreamRequest request2(factory_.get(), &http_server_properties_); |
| 1535 EXPECT_EQ(OK, request2.Request(host_port_pair_, privacy_mode_, |
| 1536 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1537 callback_.callback())); |
| 1538 std::unique_ptr<QuicHttpStream> stream = request2.CreateStream(); |
| 1539 |
1536 EXPECT_TRUE(stream.get()); | 1540 EXPECT_TRUE(stream.get()); |
1537 stream.reset(); | 1541 stream.reset(); |
1538 | 1542 |
1539 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1543 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
1540 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1544 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
1541 } | 1545 } |
1542 | 1546 |
1543 TEST_P(QuicStreamFactoryTest, CloseAllSessions) { | 1547 TEST_P(QuicStreamFactoryTest, CloseAllSessions) { |
1544 Initialize(); | 1548 Initialize(); |
1545 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 1549 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
(...skipping 3664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5210 // Clear all cached states. | 5214 // Clear all cached states. |
5211 factory_->ClearCachedStatesInCryptoConfig( | 5215 factory_->ClearCachedStatesInCryptoConfig( |
5212 base::Callback<bool(const GURL&)>()); | 5216 base::Callback<bool(const GURL&)>()); |
5213 EXPECT_TRUE(test_cases[0].state->certs().empty()); | 5217 EXPECT_TRUE(test_cases[0].state->certs().empty()); |
5214 EXPECT_TRUE(test_cases[1].state->certs().empty()); | 5218 EXPECT_TRUE(test_cases[1].state->certs().empty()); |
5215 EXPECT_TRUE(test_cases[2].state->certs().empty()); | 5219 EXPECT_TRUE(test_cases[2].state->certs().empty()); |
5216 } | 5220 } |
5217 | 5221 |
5218 } // namespace test | 5222 } // namespace test |
5219 } // namespace net | 5223 } // namespace net |
OLD | NEW |