| 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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 if (waiting_for_preconnect_) | 172 if (waiting_for_preconnect_) |
| 173 base::MessageLoop::current()->QuitWhenIdle(); | 173 base::MessageLoop::current()->QuitWhenIdle(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool preconnect_done_; | 176 bool preconnect_done_; |
| 177 bool waiting_for_preconnect_; | 177 bool waiting_for_preconnect_; |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 class StreamRequestWaiter : public HttpStreamRequest::Delegate { | 180 class StreamRequestWaiter : public HttpStreamRequest::Delegate { |
| 181 public: | 181 public: |
| 182 StreamRequestWaiter() | 182 StreamRequestWaiter() : stream_done_(false), error_status_(OK) {} |
| 183 : waiting_for_stream_(false), stream_done_(false), error_status_(OK) {} | |
| 184 | 183 |
| 185 // HttpStreamRequest::Delegate | 184 // HttpStreamRequest::Delegate |
| 186 | 185 |
| 187 void OnStreamReady(const SSLConfig& used_ssl_config, | 186 void OnStreamReady(const SSLConfig& used_ssl_config, |
| 188 const ProxyInfo& used_proxy_info, | 187 const ProxyInfo& used_proxy_info, |
| 189 HttpStream* stream) override { | 188 HttpStream* stream) override { |
| 190 stream_done_ = true; | 189 stream_done_ = true; |
| 191 if (waiting_for_stream_) | 190 loop_.Quit(); |
| 192 loop_.Quit(); | |
| 193 stream_.reset(stream); | 191 stream_.reset(stream); |
| 194 used_ssl_config_ = used_ssl_config; | 192 used_ssl_config_ = used_ssl_config; |
| 195 used_proxy_info_ = used_proxy_info; | 193 used_proxy_info_ = used_proxy_info; |
| 196 } | 194 } |
| 197 | 195 |
| 198 void OnWebSocketHandshakeStreamReady( | 196 void OnWebSocketHandshakeStreamReady( |
| 199 const SSLConfig& used_ssl_config, | 197 const SSLConfig& used_ssl_config, |
| 200 const ProxyInfo& used_proxy_info, | 198 const ProxyInfo& used_proxy_info, |
| 201 WebSocketHandshakeStreamBase* stream) override { | 199 WebSocketHandshakeStreamBase* stream) override { |
| 202 stream_done_ = true; | 200 stream_done_ = true; |
| 203 if (waiting_for_stream_) | 201 loop_.Quit(); |
| 204 loop_.Quit(); | |
| 205 websocket_stream_.reset(stream); | 202 websocket_stream_.reset(stream); |
| 206 used_ssl_config_ = used_ssl_config; | 203 used_ssl_config_ = used_ssl_config; |
| 207 used_proxy_info_ = used_proxy_info; | 204 used_proxy_info_ = used_proxy_info; |
| 208 } | 205 } |
| 209 | 206 |
| 210 void OnBidirectionalStreamImplReady( | 207 void OnBidirectionalStreamImplReady( |
| 211 const SSLConfig& used_ssl_config, | 208 const SSLConfig& used_ssl_config, |
| 212 const ProxyInfo& used_proxy_info, | 209 const ProxyInfo& used_proxy_info, |
| 213 BidirectionalStreamImpl* stream) override { | 210 BidirectionalStreamImpl* stream) override { |
| 214 stream_done_ = true; | 211 stream_done_ = true; |
| 215 if (waiting_for_stream_) | 212 loop_.Quit(); |
| 216 loop_.Quit(); | |
| 217 bidirectional_stream_impl_.reset(stream); | 213 bidirectional_stream_impl_.reset(stream); |
| 218 used_ssl_config_ = used_ssl_config; | 214 used_ssl_config_ = used_ssl_config; |
| 219 used_proxy_info_ = used_proxy_info; | 215 used_proxy_info_ = used_proxy_info; |
| 220 } | 216 } |
| 221 | 217 |
| 222 void OnStreamFailed(int status, const SSLConfig& used_ssl_config) override { | 218 void OnStreamFailed(int status, const SSLConfig& used_ssl_config) override { |
| 223 stream_done_ = true; | 219 stream_done_ = true; |
| 224 if (waiting_for_stream_) | 220 loop_.Quit(); |
| 225 loop_.Quit(); | |
| 226 used_ssl_config_ = used_ssl_config; | 221 used_ssl_config_ = used_ssl_config; |
| 227 error_status_ = status; | 222 error_status_ = status; |
| 228 } | 223 } |
| 229 | 224 |
| 230 void OnCertificateError(int status, | 225 void OnCertificateError(int status, |
| 231 const SSLConfig& used_ssl_config, | 226 const SSLConfig& used_ssl_config, |
| 232 const SSLInfo& ssl_info) override {} | 227 const SSLInfo& ssl_info) override {} |
| 233 | 228 |
| 234 void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response, | 229 void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response, |
| 235 const SSLConfig& used_ssl_config, | 230 const SSLConfig& used_ssl_config, |
| 236 const ProxyInfo& used_proxy_info, | 231 const ProxyInfo& used_proxy_info, |
| 237 HttpAuthController* auth_controller) override {} | 232 HttpAuthController* auth_controller) override {} |
| 238 | 233 |
| 239 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, | 234 void OnNeedsClientAuth(const SSLConfig& used_ssl_config, |
| 240 SSLCertRequestInfo* cert_info) override {} | 235 SSLCertRequestInfo* cert_info) override {} |
| 241 | 236 |
| 242 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, | 237 void OnHttpsProxyTunnelResponse(const HttpResponseInfo& response_info, |
| 243 const SSLConfig& used_ssl_config, | 238 const SSLConfig& used_ssl_config, |
| 244 const ProxyInfo& used_proxy_info, | 239 const ProxyInfo& used_proxy_info, |
| 245 HttpStream* stream) override {} | 240 HttpStream* stream) override {} |
| 246 | 241 |
| 247 void OnQuicBroken() override {} | 242 void OnQuicBroken() override {} |
| 248 | 243 |
| 249 void WaitForStream() { | 244 void WaitForStream() { loop_.Run(); } |
| 250 while (!stream_done_) { | |
| 251 waiting_for_stream_ = true; | |
| 252 loop_.Run(); | |
| 253 waiting_for_stream_ = false; | |
| 254 } | |
| 255 } | |
| 256 | 245 |
| 257 const SSLConfig& used_ssl_config() const { | 246 const SSLConfig& used_ssl_config() const { |
| 258 return used_ssl_config_; | 247 return used_ssl_config_; |
| 259 } | 248 } |
| 260 | 249 |
| 261 const ProxyInfo& used_proxy_info() const { | 250 const ProxyInfo& used_proxy_info() const { |
| 262 return used_proxy_info_; | 251 return used_proxy_info_; |
| 263 } | 252 } |
| 264 | 253 |
| 265 HttpStream* stream() { | 254 HttpStream* stream() { |
| 266 return stream_.get(); | 255 return stream_.get(); |
| 267 } | 256 } |
| 268 | 257 |
| 269 MockWebSocketHandshakeStream* websocket_stream() { | 258 MockWebSocketHandshakeStream* websocket_stream() { |
| 270 return static_cast<MockWebSocketHandshakeStream*>(websocket_stream_.get()); | 259 return static_cast<MockWebSocketHandshakeStream*>(websocket_stream_.get()); |
| 271 } | 260 } |
| 272 | 261 |
| 273 BidirectionalStreamImpl* bidirectional_stream_impl() { | 262 BidirectionalStreamImpl* bidirectional_stream_impl() { |
| 274 return bidirectional_stream_impl_.get(); | 263 return bidirectional_stream_impl_.get(); |
| 275 } | 264 } |
| 276 | 265 |
| 277 bool stream_done() const { return stream_done_; } | 266 bool stream_done() const { return stream_done_; } |
| 278 int error_status() const { return error_status_; } | 267 int error_status() const { return error_status_; } |
| 279 | 268 |
| 280 private: | 269 private: |
| 281 bool waiting_for_stream_; | |
| 282 bool stream_done_; | 270 bool stream_done_; |
| 283 base::RunLoop loop_; | 271 base::RunLoop loop_; |
| 284 std::unique_ptr<HttpStream> stream_; | 272 std::unique_ptr<HttpStream> stream_; |
| 285 std::unique_ptr<WebSocketHandshakeStreamBase> websocket_stream_; | 273 std::unique_ptr<WebSocketHandshakeStreamBase> websocket_stream_; |
| 286 std::unique_ptr<BidirectionalStreamImpl> bidirectional_stream_impl_; | 274 std::unique_ptr<BidirectionalStreamImpl> bidirectional_stream_impl_; |
| 287 SSLConfig used_ssl_config_; | 275 SSLConfig used_ssl_config_; |
| 288 ProxyInfo used_proxy_info_; | 276 ProxyInfo used_proxy_info_; |
| 289 int error_status_; | 277 int error_status_; |
| 290 | 278 |
| 291 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter); | 279 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 socket_data_direct_second_request.set_connect_data( | 947 socket_data_direct_second_request.set_connect_data( |
| 960 MockConnect(ASYNC, OK)); | 948 MockConnect(ASYNC, OK)); |
| 961 socket_factory.AddSocketDataProvider(&socket_data_direct_second_request); | 949 socket_factory.AddSocketDataProvider(&socket_data_direct_second_request); |
| 962 | 950 |
| 963 // Now request a stream. It should succeed using the DIRECT. | 951 // Now request a stream. It should succeed using the DIRECT. |
| 964 HttpRequestInfo request_info; | 952 HttpRequestInfo request_info; |
| 965 request_info.method = "GET"; | 953 request_info.method = "GET"; |
| 966 request_info.url = GURL("http://www.google.com"); | 954 request_info.url = GURL("http://www.google.com"); |
| 967 | 955 |
| 968 SSLConfig ssl_config; | 956 SSLConfig ssl_config; |
| 969 StreamRequestWaiter waiter; | |
| 970 | 957 |
| 971 EXPECT_EQ(set_alternative_proxy_server, | 958 EXPECT_EQ(set_alternative_proxy_server, |
| 972 test_proxy_delegate.alternative_proxy_server().is_quic()); | 959 test_proxy_delegate.alternative_proxy_server().is_quic()); |
| 973 | 960 |
| 974 // Start two requests. The first request should consume data from | 961 // Start two requests. The first request should consume data from |
| 975 // |socket_data_proxy_main_job|, | 962 // |socket_data_proxy_main_job|, |
| 976 // |socket_data_proxy_alternate_job| and | 963 // |socket_data_proxy_alternate_job| and |
| 977 // |socket_data_direct_first_request|. The second request should consume | 964 // |socket_data_direct_first_request|. The second request should consume |
| 978 // data from |socket_data_direct_second_request|. | 965 // data from |socket_data_direct_second_request|. |
| 979 for (size_t i = 0; i < 2; ++i) { | 966 for (size_t i = 0; i < 2; ++i) { |
| 967 StreamRequestWaiter waiter; |
| 980 std::unique_ptr<HttpStreamRequest> request( | 968 std::unique_ptr<HttpStreamRequest> request( |
| 981 session->http_stream_factory()->RequestStream( | 969 session->http_stream_factory()->RequestStream( |
| 982 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, | 970 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, |
| 983 /* enable_ip_based_pooling = */ true, NetLogWithSource())); | 971 /* enable_ip_based_pooling = */ true, NetLogWithSource())); |
| 984 waiter.WaitForStream(); | 972 waiter.WaitForStream(); |
| 985 | 973 |
| 986 // The proxy that failed should now be known to the proxy_service as | 974 // The proxy that failed should now be known to the proxy_service as |
| 987 // bad. | 975 // bad. |
| 988 const ProxyRetryInfoMap retry_info = | 976 const ProxyRetryInfoMap retry_info = |
| 989 session->proxy_service()->proxy_retry_info(); | 977 session->proxy_service()->proxy_retry_info(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 socket_factory.AddSocketDataProvider(&socket_data_https_second); | 1053 socket_factory.AddSocketDataProvider(&socket_data_https_second); |
| 1066 socket_factory.AddSSLSocketDataProvider(&ssl_data); | 1054 socket_factory.AddSSLSocketDataProvider(&ssl_data); |
| 1067 | 1055 |
| 1068 // Now request a stream. It should succeed using the second proxy in the | 1056 // Now request a stream. It should succeed using the second proxy in the |
| 1069 // list. | 1057 // list. |
| 1070 HttpRequestInfo request_info; | 1058 HttpRequestInfo request_info; |
| 1071 request_info.method = "GET"; | 1059 request_info.method = "GET"; |
| 1072 request_info.url = GURL("http://www.google.com"); | 1060 request_info.url = GURL("http://www.google.com"); |
| 1073 | 1061 |
| 1074 SSLConfig ssl_config; | 1062 SSLConfig ssl_config; |
| 1075 StreamRequestWaiter waiter; | |
| 1076 | 1063 |
| 1077 EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic()); | 1064 EXPECT_TRUE(test_proxy_delegate.alternative_proxy_server().is_quic()); |
| 1078 | 1065 |
| 1079 // Start two requests. The first request should consume data from | 1066 // Start two requests. The first request should consume data from |
| 1080 // |socket_data_proxy_main_job| and |socket_data_https_first|. | 1067 // |socket_data_proxy_main_job| and |socket_data_https_first|. |
| 1081 // The second request should consume data from |socket_data_https_second|. | 1068 // The second request should consume data from |socket_data_https_second|. |
| 1082 for (size_t i = 0; i < 2; ++i) { | 1069 for (size_t i = 0; i < 2; ++i) { |
| 1070 StreamRequestWaiter waiter; |
| 1083 std::unique_ptr<HttpStreamRequest> request( | 1071 std::unique_ptr<HttpStreamRequest> request( |
| 1084 session->http_stream_factory()->RequestStream( | 1072 session->http_stream_factory()->RequestStream( |
| 1085 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, | 1073 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, |
| 1086 /* enable_ip_based_pooling = */ true, NetLogWithSource())); | 1074 /* enable_ip_based_pooling = */ true, NetLogWithSource())); |
| 1087 waiter.WaitForStream(); | 1075 waiter.WaitForStream(); |
| 1088 | 1076 |
| 1089 // The proxy that failed should now be known to the proxy_service as | 1077 // The proxy that failed should now be known to the proxy_service as |
| 1090 // bad. | 1078 // bad. |
| 1091 const ProxyRetryInfoMap retry_info = | 1079 const ProxyRetryInfoMap retry_info = |
| 1092 session->proxy_service()->proxy_retry_info(); | 1080 session->proxy_service()->proxy_retry_info(); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 | 1479 |
| 1492 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 0); | 1480 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 0); |
| 1493 | 1481 |
| 1494 HttpRequestInfo request_info; | 1482 HttpRequestInfo request_info; |
| 1495 request_info.method = "GET"; | 1483 request_info.method = "GET"; |
| 1496 request_info.url = GURL("https://www.google.com"); | 1484 request_info.url = GURL("https://www.google.com"); |
| 1497 request_info.load_flags = 0; | 1485 request_info.load_flags = 0; |
| 1498 request_info.privacy_mode = PRIVACY_MODE_DISABLED; | 1486 request_info.privacy_mode = PRIVACY_MODE_DISABLED; |
| 1499 | 1487 |
| 1500 SSLConfig ssl_config; | 1488 SSLConfig ssl_config; |
| 1501 StreamRequestWaiter waiter; | 1489 StreamRequestWaiter waiter1; |
| 1502 | |
| 1503 std::unique_ptr<HttpStreamRequest> request1( | 1490 std::unique_ptr<HttpStreamRequest> request1( |
| 1504 session->http_stream_factory()->RequestStream( | 1491 session->http_stream_factory()->RequestStream( |
| 1505 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, | 1492 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter1, |
| 1506 /* enable_ip_based_pooling = */ true, NetLogWithSource())); | 1493 /* enable_ip_based_pooling = */ true, NetLogWithSource())); |
| 1507 waiter.WaitForStream(); | 1494 waiter1.WaitForStream(); |
| 1508 | 1495 |
| 1509 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 1); | 1496 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 1); |
| 1510 | 1497 |
| 1498 StreamRequestWaiter waiter2; |
| 1511 std::unique_ptr<HttpStreamRequest> request2( | 1499 std::unique_ptr<HttpStreamRequest> request2( |
| 1512 session->http_stream_factory()->RequestStream( | 1500 session->http_stream_factory()->RequestStream( |
| 1513 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, | 1501 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter2, |
| 1514 /* enable_ip_based_pooling = */ true, NetLogWithSource())); | 1502 /* enable_ip_based_pooling = */ true, NetLogWithSource())); |
| 1515 waiter.WaitForStream(); | 1503 waiter2.WaitForStream(); |
| 1516 | 1504 |
| 1517 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 1); | 1505 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 1); |
| 1518 | 1506 |
| 1507 StreamRequestWaiter waiter3; |
| 1519 request_info.privacy_mode = PRIVACY_MODE_ENABLED; | 1508 request_info.privacy_mode = PRIVACY_MODE_ENABLED; |
| 1520 std::unique_ptr<HttpStreamRequest> request3( | 1509 std::unique_ptr<HttpStreamRequest> request3( |
| 1521 session->http_stream_factory()->RequestStream( | 1510 session->http_stream_factory()->RequestStream( |
| 1522 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter, | 1511 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter3, |
| 1523 /* enable_ip_based_pooling = */ true, NetLogWithSource())); | 1512 /* enable_ip_based_pooling = */ true, NetLogWithSource())); |
| 1524 waiter.WaitForStream(); | 1513 waiter3.WaitForStream(); |
| 1525 | 1514 |
| 1526 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 2); | 1515 EXPECT_EQ(GetSocketPoolGroupCount(ssl_pool), 2); |
| 1527 } | 1516 } |
| 1528 | 1517 |
| 1529 TEST_F(HttpStreamFactoryTest, GetLoadState) { | 1518 TEST_F(HttpStreamFactoryTest, GetLoadState) { |
| 1530 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); | 1519 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); |
| 1531 | 1520 |
| 1532 // Force asynchronous host resolutions, so that the LoadState will be | 1521 // Force asynchronous host resolutions, so that the LoadState will be |
| 1533 // resolving the host. | 1522 // resolving the host. |
| 1534 session_deps.host_resolver->set_synchronous_mode(false); | 1523 session_deps.host_resolver->set_synchronous_mode(false); |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 ASSERT_NE(nullptr, waiter1.stream()); | 2125 ASSERT_NE(nullptr, waiter1.stream()); |
| 2137 ASSERT_NE(nullptr, waiter2.stream()); | 2126 ASSERT_NE(nullptr, waiter2.stream()); |
| 2138 ASSERT_NE(waiter1.stream(), waiter2.stream()); | 2127 ASSERT_NE(waiter1.stream(), waiter2.stream()); |
| 2139 | 2128 |
| 2140 // Establishing the SpdySession will close idle H2 sockets. | 2129 // Establishing the SpdySession will close idle H2 sockets. |
| 2141 EXPECT_EQ(0, session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) | 2130 EXPECT_EQ(0, session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) |
| 2142 ->IdleSocketCount()); | 2131 ->IdleSocketCount()); |
| 2143 EXPECT_EQ(1, GetSpdySessionCount(session.get())); | 2132 EXPECT_EQ(1, GetSpdySessionCount(session.get())); |
| 2144 } | 2133 } |
| 2145 | 2134 |
| 2135 // Regression test for crbug.com/706974. |
| 2136 TEST_F(HttpStreamFactoryTest, TwoSpdyConnects) { |
| 2137 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); |
| 2138 |
| 2139 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING)}; |
| 2140 std::vector<std::unique_ptr<SequencedSocketData>> providers; |
| 2141 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); |
| 2142 ssl_socket_data.next_proto = kProtoHTTP2; |
| 2143 for (int i = 0; i < 2; i++) { |
| 2144 auto provider = base::MakeUnique<SequencedSocketData>( |
| 2145 reads, arraysize(reads), nullptr, 0); |
| 2146 provider->set_connect_data(MockConnect(ASYNC, OK)); |
| 2147 session_deps.socket_factory->AddSocketDataProvider(provider.get()); |
| 2148 providers.push_back(std::move(provider)); |
| 2149 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); |
| 2150 } |
| 2151 |
| 2152 std::unique_ptr<HttpNetworkSession> session( |
| 2153 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 2154 |
| 2155 HostPortPair host_port_pair("www.google.com", 443); |
| 2156 |
| 2157 // Request two streams at once and make sure they use the same connection. |
| 2158 HttpRequestInfo request_info; |
| 2159 request_info.method = "GET"; |
| 2160 request_info.url = GURL("https://www.google.com"); |
| 2161 request_info.load_flags = 0; |
| 2162 |
| 2163 SSLConfig ssl_config; |
| 2164 StreamRequestWaiter waiter1; |
| 2165 StreamRequestWaiter waiter2; |
| 2166 std::unique_ptr<HttpStreamRequest> request1( |
| 2167 session->http_stream_factory()->RequestStream( |
| 2168 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter1, |
| 2169 /* enable_ip_based_pooling = */ true, NetLogWithSource())); |
| 2170 std::unique_ptr<HttpStreamRequest> request2( |
| 2171 session->http_stream_factory()->RequestStream( |
| 2172 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, &waiter2, |
| 2173 /* enable_ip_based_pooling = */ true, NetLogWithSource())); |
| 2174 waiter1.WaitForStream(); |
| 2175 waiter2.WaitForStream(); |
| 2176 EXPECT_TRUE(waiter1.stream_done()); |
| 2177 EXPECT_TRUE(waiter2.stream_done()); |
| 2178 ASSERT_NE(nullptr, waiter1.stream()); |
| 2179 ASSERT_NE(nullptr, waiter2.stream()); |
| 2180 ASSERT_NE(waiter1.stream(), waiter2.stream()); |
| 2181 |
| 2182 // Establishing the SpdySession will close the extra H2 socket. |
| 2183 EXPECT_EQ(0, session->GetSSLSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL) |
| 2184 ->IdleSocketCount()); |
| 2185 EXPECT_EQ(1, GetSpdySessionCount(session.get())); |
| 2186 } |
| 2187 |
| 2146 TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImpl) { | 2188 TEST_F(HttpStreamFactoryTest, RequestBidirectionalStreamImpl) { |
| 2147 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); | 2189 SpdySessionDependencies session_deps(ProxyService::CreateDirect()); |
| 2148 | 2190 |
| 2149 MockRead mock_read(ASYNC, OK); | 2191 MockRead mock_read(ASYNC, OK); |
| 2150 SequencedSocketData socket_data(&mock_read, 1, nullptr, 0); | 2192 SequencedSocketData socket_data(&mock_read, 1, nullptr, 0); |
| 2151 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | 2193 socket_data.set_connect_data(MockConnect(ASYNC, OK)); |
| 2152 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | 2194 session_deps.socket_factory->AddSocketDataProvider(&socket_data); |
| 2153 | 2195 |
| 2154 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); | 2196 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); |
| 2155 ssl_socket_data.next_proto = kProtoHTTP2; | 2197 ssl_socket_data.next_proto = kProtoHTTP2; |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 session->GetTransportSocketPool( | 2775 session->GetTransportSocketPool( |
| 2734 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 2776 HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 2735 EXPECT_EQ(1, GetSocketPoolGroupCount( | 2777 EXPECT_EQ(1, GetSocketPoolGroupCount( |
| 2736 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); | 2778 session->GetSSLSocketPool(HttpNetworkSession::WEBSOCKET_SOCKET_POOL))); |
| 2737 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 2779 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
| 2738 } | 2780 } |
| 2739 | 2781 |
| 2740 } // namespace | 2782 } // namespace |
| 2741 | 2783 |
| 2742 } // namespace net | 2784 } // namespace net |
| OLD | NEW |