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 <memory> | 5 #include <memory> |
6 #include <ostream> | 6 #include <ostream> |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 base::RunLoop().RunUntilIdle(); | 281 base::RunLoop().RunUntilIdle(); |
282 } | 282 } |
283 | 283 |
284 void TearDown() override { | 284 void TearDown() override { |
285 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 285 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
286 // Empty the current queue. | 286 // Empty the current queue. |
287 base::RunLoop().RunUntilIdle(); | 287 base::RunLoop().RunUntilIdle(); |
288 PlatformTest::TearDown(); | 288 PlatformTest::TearDown(); |
289 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 289 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
290 base::RunLoop().RunUntilIdle(); | 290 base::RunLoop().RunUntilIdle(); |
| 291 session_.reset(); |
291 } | 292 } |
292 | 293 |
293 std::unique_ptr<QuicEncryptedPacket> ConstructClientConnectionClosePacket( | 294 std::unique_ptr<QuicEncryptedPacket> ConstructClientConnectionClosePacket( |
294 QuicPacketNumber num) { | 295 QuicPacketNumber num) { |
295 return client_maker_.MakeConnectionClosePacket(num); | 296 return client_maker_.MakeConnectionClosePacket(num); |
296 } | 297 } |
297 | 298 |
298 std::unique_ptr<QuicEncryptedPacket> ConstructServerConnectionClosePacket( | 299 std::unique_ptr<QuicEncryptedPacket> ConstructServerConnectionClosePacket( |
299 QuicPacketNumber num) { | 300 QuicPacketNumber num) { |
300 return server_maker_.MakeConnectionClosePacket(num); | 301 return server_maker_.MakeConnectionClosePacket(num); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 params_.quic_crypto_client_stream_factory = &crypto_client_stream_factory_; | 509 params_.quic_crypto_client_stream_factory = &crypto_client_stream_factory_; |
509 params_.host_resolver = &host_resolver_; | 510 params_.host_resolver = &host_resolver_; |
510 params_.cert_verifier = &cert_verifier_; | 511 params_.cert_verifier = &cert_verifier_; |
511 params_.transport_security_state = &transport_security_state_; | 512 params_.transport_security_state = &transport_security_state_; |
512 params_.cert_transparency_verifier = cert_transparency_verifier_.get(); | 513 params_.cert_transparency_verifier = cert_transparency_verifier_.get(); |
513 params_.socket_performance_watcher_factory = | 514 params_.socket_performance_watcher_factory = |
514 &test_socket_performance_watcher_factory_; | 515 &test_socket_performance_watcher_factory_; |
515 params_.proxy_service = proxy_service_.get(); | 516 params_.proxy_service = proxy_service_.get(); |
516 params_.ssl_config_service = ssl_config_service_.get(); | 517 params_.ssl_config_service = ssl_config_service_.get(); |
517 params_.http_auth_handler_factory = auth_handler_factory_.get(); | 518 params_.http_auth_handler_factory = auth_handler_factory_.get(); |
518 params_.http_server_properties = http_server_properties_.GetWeakPtr(); | 519 params_.http_server_properties = &http_server_properties_; |
519 params_.quic_supported_versions = SupportedVersions(GetParam()); | 520 params_.quic_supported_versions = SupportedVersions(GetParam()); |
520 for (const char* host : | 521 for (const char* host : |
521 {kDefaultServerHostName, "www.example.org", "news.example.org", | 522 {kDefaultServerHostName, "www.example.org", "news.example.org", |
522 "bar.example.org", "foo.example.org", "invalid.example.org", | 523 "bar.example.org", "foo.example.org", "invalid.example.org", |
523 "mail.example.com"}) { | 524 "mail.example.com"}) { |
524 params_.quic_host_whitelist.insert(host); | 525 params_.quic_host_whitelist.insert(host); |
525 } | 526 } |
526 | 527 |
527 session_.reset(new HttpNetworkSession(params_)); | 528 session_.reset(new HttpNetworkSession(params_)); |
528 session_->quic_stream_factory()->set_require_confirmation(false); | 529 session_->quic_stream_factory()->set_require_confirmation(false); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 0); | 1011 0); |
1011 | 1012 |
1012 socket_factory_.AddSocketDataProvider(&http_data); | 1013 socket_factory_.AddSocketDataProvider(&http_data); |
1013 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 1014 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
1014 | 1015 |
1015 CreateSession(); | 1016 CreateSession(); |
1016 // Send http request, ignore alternative service advertising if response | 1017 // Send http request, ignore alternative service advertising if response |
1017 // header advertises alternative service for mail.example.org. | 1018 // header advertises alternative service for mail.example.org. |
1018 request_.url = GURL("http://mail.example.org:443"); | 1019 request_.url = GURL("http://mail.example.org:443"); |
1019 SendRequestAndExpectHttpResponse("hello world"); | 1020 SendRequestAndExpectHttpResponse("hello world"); |
1020 base::WeakPtr<HttpServerProperties> http_server_properties = | 1021 HttpServerProperties* http_server_properties = |
1021 session_->http_server_properties(); | 1022 session_->http_server_properties(); |
1022 url::SchemeHostPort http_server("http", "mail.example.org", 443); | 1023 url::SchemeHostPort http_server("http", "mail.example.org", 443); |
1023 url::SchemeHostPort https_server("https", "mail.example.org", 443); | 1024 url::SchemeHostPort https_server("https", "mail.example.org", 443); |
1024 // Check alternative service is set for the correct origin. | 1025 // Check alternative service is set for the correct origin. |
1025 EXPECT_EQ(2u, | 1026 EXPECT_EQ(2u, |
1026 http_server_properties->GetAlternativeServices(http_server).size()); | 1027 http_server_properties->GetAlternativeServices(http_server).size()); |
1027 EXPECT_EQ( | 1028 EXPECT_EQ( |
1028 0u, http_server_properties->GetAlternativeServices(https_server).size()); | 1029 0u, http_server_properties->GetAlternativeServices(https_server).size()); |
1029 } | 1030 } |
1030 | 1031 |
(...skipping 11 matching lines...) Expand all Loading... |
1042 socket_factory_.AddSocketDataProvider(&http_data); | 1043 socket_factory_.AddSocketDataProvider(&http_data); |
1043 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 1044 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
1044 socket_factory_.AddSocketDataProvider(&http_data); | 1045 socket_factory_.AddSocketDataProvider(&http_data); |
1045 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 1046 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
1046 | 1047 |
1047 CreateSession(); | 1048 CreateSession(); |
1048 | 1049 |
1049 // Send https request and set alternative services if response header | 1050 // Send https request and set alternative services if response header |
1050 // advertises alternative service for mail.example.org. | 1051 // advertises alternative service for mail.example.org. |
1051 SendRequestAndExpectHttpResponse("hello world"); | 1052 SendRequestAndExpectHttpResponse("hello world"); |
1052 base::WeakPtr<HttpServerProperties> http_server_properties = | 1053 HttpServerProperties* http_server_properties = |
1053 session_->http_server_properties(); | 1054 session_->http_server_properties(); |
1054 | 1055 |
1055 const url::SchemeHostPort https_server(request_.url); | 1056 const url::SchemeHostPort https_server(request_.url); |
1056 // Check alternative service is set. | 1057 // Check alternative service is set. |
1057 AlternativeServiceVector alternative_service_vector = | 1058 AlternativeServiceVector alternative_service_vector = |
1058 http_server_properties->GetAlternativeServices(https_server); | 1059 http_server_properties->GetAlternativeServices(https_server); |
1059 EXPECT_EQ(2u, alternative_service_vector.size()); | 1060 EXPECT_EQ(2u, alternative_service_vector.size()); |
1060 | 1061 |
1061 // Send http request to the same origin but with diffrent scheme, should not | 1062 // Send http request to the same origin but with diffrent scheme, should not |
1062 // use QUIC. | 1063 // use QUIC. |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 params.client_socket_factory = &socket_factory_; | 2184 params.client_socket_factory = &socket_factory_; |
2184 params.host_resolver = &host_resolver_; | 2185 params.host_resolver = &host_resolver_; |
2185 params.cert_verifier = &cert_verifier_; | 2186 params.cert_verifier = &cert_verifier_; |
2186 params.transport_security_state = &transport_security_state_; | 2187 params.transport_security_state = &transport_security_state_; |
2187 params.cert_transparency_verifier = cert_transparency_verifier_.get(); | 2188 params.cert_transparency_verifier = cert_transparency_verifier_.get(); |
2188 params.socket_performance_watcher_factory = | 2189 params.socket_performance_watcher_factory = |
2189 &test_socket_performance_watcher_factory_; | 2190 &test_socket_performance_watcher_factory_; |
2190 params.ssl_config_service = ssl_config_service_.get(); | 2191 params.ssl_config_service = ssl_config_service_.get(); |
2191 params.proxy_service = proxy_service_.get(); | 2192 params.proxy_service = proxy_service_.get(); |
2192 params.http_auth_handler_factory = auth_handler_factory_.get(); | 2193 params.http_auth_handler_factory = auth_handler_factory_.get(); |
2193 params.http_server_properties = http_server_properties_.GetWeakPtr(); | 2194 params.http_server_properties = &http_server_properties_; |
2194 params.quic_supported_versions = SupportedVersions(version_); | 2195 params.quic_supported_versions = SupportedVersions(version_); |
2195 params.quic_host_whitelist.insert("news.example.org"); | 2196 params.quic_host_whitelist.insert("news.example.org"); |
2196 params.quic_host_whitelist.insert("mail.example.org"); | 2197 params.quic_host_whitelist.insert("mail.example.org"); |
2197 params.quic_host_whitelist.insert("mail.example.com"); | 2198 params.quic_host_whitelist.insert("mail.example.com"); |
2198 | 2199 |
2199 session_.reset(new HttpNetworkSession(params)); | 2200 session_.reset(new HttpNetworkSession(params)); |
2200 session_->quic_stream_factory()->set_require_confirmation(true); | 2201 session_->quic_stream_factory()->set_require_confirmation(true); |
2201 ASSERT_EQ(params.quic_socket_receive_buffer_size, | 2202 ASSERT_EQ(params.quic_socket_receive_buffer_size, |
2202 session_->quic_stream_factory()->socket_receive_buffer_size()); | 2203 session_->quic_stream_factory()->socket_receive_buffer_size()); |
2203 } | 2204 } |
2204 | 2205 |
2205 void TearDown() override { | 2206 void TearDown() override { |
2206 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 2207 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
2207 // Empty the current queue. | 2208 // Empty the current queue. |
2208 base::RunLoop().RunUntilIdle(); | 2209 base::RunLoop().RunUntilIdle(); |
2209 PlatformTest::TearDown(); | 2210 PlatformTest::TearDown(); |
2210 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 2211 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
2211 base::RunLoop().RunUntilIdle(); | 2212 base::RunLoop().RunUntilIdle(); |
| 2213 session_.reset(); |
2212 } | 2214 } |
2213 | 2215 |
2214 void SetAlternativeService(const std::string& origin) { | 2216 void SetAlternativeService(const std::string& origin) { |
2215 HostPortPair destination; | 2217 HostPortPair destination; |
2216 switch (destination_type_) { | 2218 switch (destination_type_) { |
2217 case SAME_AS_FIRST: | 2219 case SAME_AS_FIRST: |
2218 destination = HostPortPair(origin1_, 443); | 2220 destination = HostPortPair(origin1_, 443); |
2219 break; | 2221 break; |
2220 case SAME_AS_SECOND: | 2222 case SAME_AS_SECOND: |
2221 destination = HostPortPair(origin2_, 443); | 2223 destination = HostPortPair(origin2_, 443); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2561 AddHangingSocketData(); | 2563 AddHangingSocketData(); |
2562 | 2564 |
2563 SendRequestAndExpectQuicResponse(origin1_); | 2565 SendRequestAndExpectQuicResponse(origin1_); |
2564 SendRequestAndExpectQuicResponse(origin2_); | 2566 SendRequestAndExpectQuicResponse(origin2_); |
2565 | 2567 |
2566 EXPECT_TRUE(AllDataConsumed()); | 2568 EXPECT_TRUE(AllDataConsumed()); |
2567 } | 2569 } |
2568 | 2570 |
2569 } // namespace test | 2571 } // namespace test |
2570 } // namespace net | 2572 } // namespace net |
OLD | NEW |