| OLD | NEW |
| 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 data2_reads.push_back( | 1487 data2_reads.push_back( |
| 1488 MockRead(ASYNC, kHttpResponse, strlen(kHttpResponse), 1)); | 1488 MockRead(ASYNC, kHttpResponse, strlen(kHttpResponse), 1)); |
| 1489 data2_reads.push_back(MockRead(ASYNC, kHttpData, strlen(kHttpData), 2)); | 1489 data2_reads.push_back(MockRead(ASYNC, kHttpData, strlen(kHttpData), 2)); |
| 1490 data2_reads.push_back(MockRead(ASYNC, OK, 3)); | 1490 data2_reads.push_back(MockRead(ASYNC, OK, 3)); |
| 1491 } | 1491 } |
| 1492 SequencedSocketData data2(&data2_reads[0], data2_reads.size(), | 1492 SequencedSocketData data2(&data2_reads[0], data2_reads.size(), |
| 1493 &data2_writes[0], data2_writes.size()); | 1493 &data2_writes[0], data2_writes.size()); |
| 1494 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 1494 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
| 1495 | 1495 |
| 1496 // Preconnect a socket. | 1496 // Preconnect a socket. |
| 1497 SSLConfig ssl_config; | 1497 session->http_stream_factory()->PreconnectStreams(1, request); |
| 1498 session->ssl_config_service()->GetSSLConfig(&ssl_config); | |
| 1499 session->GetAlpnProtos(&ssl_config.alpn_protos); | |
| 1500 session->GetNpnProtos(&ssl_config.npn_protos); | |
| 1501 session->http_stream_factory()->PreconnectStreams(1, request, ssl_config, | |
| 1502 ssl_config); | |
| 1503 // Wait for the preconnect to complete. | 1498 // Wait for the preconnect to complete. |
| 1504 // TODO(davidben): Some way to wait for an idle socket count might be handy. | 1499 // TODO(davidben): Some way to wait for an idle socket count might be handy. |
| 1505 base::RunLoop().RunUntilIdle(); | 1500 base::RunLoop().RunUntilIdle(); |
| 1506 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); | 1501 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session.get())); |
| 1507 | 1502 |
| 1508 // Make the request. | 1503 // Make the request. |
| 1509 TestCompletionCallback callback; | 1504 TestCompletionCallback callback; |
| 1510 | 1505 |
| 1511 scoped_ptr<HttpTransaction> trans( | 1506 scoped_ptr<HttpTransaction> trans( |
| 1512 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 1507 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| (...skipping 13160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14673 HttpStreamRequest::Delegate* delegate, | 14668 HttpStreamRequest::Delegate* delegate, |
| 14674 WebSocketHandshakeStreamBase::CreateHelper* create_helper, | 14669 WebSocketHandshakeStreamBase::CreateHelper* create_helper, |
| 14675 const BoundNetLog& net_log) override { | 14670 const BoundNetLog& net_log) override { |
| 14676 FakeStreamRequest* fake_request = | 14671 FakeStreamRequest* fake_request = |
| 14677 new FakeStreamRequest(priority, delegate, create_helper); | 14672 new FakeStreamRequest(priority, delegate, create_helper); |
| 14678 last_stream_request_ = fake_request->AsWeakPtr(); | 14673 last_stream_request_ = fake_request->AsWeakPtr(); |
| 14679 return fake_request; | 14674 return fake_request; |
| 14680 } | 14675 } |
| 14681 | 14676 |
| 14682 void PreconnectStreams(int num_streams, | 14677 void PreconnectStreams(int num_streams, |
| 14683 const HttpRequestInfo& info, | 14678 const HttpRequestInfo& info) override { |
| 14684 const SSLConfig& server_ssl_config, | |
| 14685 const SSLConfig& proxy_ssl_config) override { | |
| 14686 ADD_FAILURE(); | 14679 ADD_FAILURE(); |
| 14687 } | 14680 } |
| 14688 | 14681 |
| 14689 const HostMappingRules* GetHostMappingRules() const override { | 14682 const HostMappingRules* GetHostMappingRules() const override { |
| 14690 ADD_FAILURE(); | 14683 ADD_FAILURE(); |
| 14691 return NULL; | 14684 return NULL; |
| 14692 } | 14685 } |
| 14693 | 14686 |
| 14694 private: | 14687 private: |
| 14695 base::WeakPtr<FakeStreamRequest> last_stream_request_; | 14688 base::WeakPtr<FakeStreamRequest> last_stream_request_; |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15084 }; | 15077 }; |
| 15085 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), | 15078 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
| 15086 http_writes, arraysize(http_writes)); | 15079 http_writes, arraysize(http_writes)); |
| 15087 session_deps_.socket_factory->AddSocketDataProvider(&http_data); | 15080 session_deps_.socket_factory->AddSocketDataProvider(&http_data); |
| 15088 | 15081 |
| 15089 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 15082 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 15090 | 15083 |
| 15091 // Preconnect an SSL socket. A preconnect is needed because connect jobs are | 15084 // Preconnect an SSL socket. A preconnect is needed because connect jobs are |
| 15092 // cancelled when a normal transaction is cancelled. | 15085 // cancelled when a normal transaction is cancelled. |
| 15093 HttpStreamFactory* http_stream_factory = session->http_stream_factory(); | 15086 HttpStreamFactory* http_stream_factory = session->http_stream_factory(); |
| 15094 SSLConfig ssl_config; | 15087 http_stream_factory->PreconnectStreams(1, ssl_request); |
| 15095 session->ssl_config_service()->GetSSLConfig(&ssl_config); | |
| 15096 http_stream_factory->PreconnectStreams(1, ssl_request, ssl_config, | |
| 15097 ssl_config); | |
| 15098 EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session.get())); | 15088 EXPECT_EQ(0, GetIdleSocketCountInSSLSocketPool(session.get())); |
| 15099 | 15089 |
| 15100 // Start the HTTP request. Pool should stall. | 15090 // Start the HTTP request. Pool should stall. |
| 15101 TestCompletionCallback http_callback; | 15091 TestCompletionCallback http_callback; |
| 15102 scoped_ptr<HttpTransaction> http_trans( | 15092 scoped_ptr<HttpTransaction> http_trans( |
| 15103 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 15093 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 15104 ASSERT_EQ(ERR_IO_PENDING, | 15094 ASSERT_EQ(ERR_IO_PENDING, |
| 15105 http_trans->Start(&http_request, http_callback.callback(), | 15095 http_trans->Start(&http_request, http_callback.callback(), |
| 15106 BoundNetLog())); | 15096 BoundNetLog())); |
| 15107 EXPECT_TRUE(IsTransportSocketPoolStalled(session.get())); | 15097 EXPECT_TRUE(IsTransportSocketPoolStalled(session.get())); |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15971 base::MessageLoop::current()->RunUntilIdle(); | 15961 base::MessageLoop::current()->RunUntilIdle(); |
| 15972 | 15962 |
| 15973 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15963 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15974 HttpRequestHeaders headers; | 15964 HttpRequestHeaders headers; |
| 15975 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15965 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15976 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15966 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15977 } | 15967 } |
| 15978 #endif // !defined(OS_IOS) | 15968 #endif // !defined(OS_IOS) |
| 15979 | 15969 |
| 15980 } // namespace net | 15970 } // namespace net |
| OLD | NEW |