Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: net/quic/quic_network_transaction_unittest.cc

Issue 2041863002: Remove HttpServerProperies::GetWeakPtr(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 base::MessageLoop::current()->RunUntilIdle(); 277 base::MessageLoop::current()->RunUntilIdle();
278 } 278 }
279 279
280 void TearDown() override { 280 void TearDown() override {
281 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 281 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
282 // Empty the current queue. 282 // Empty the current queue.
283 base::MessageLoop::current()->RunUntilIdle(); 283 base::MessageLoop::current()->RunUntilIdle();
284 PlatformTest::TearDown(); 284 PlatformTest::TearDown();
285 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 285 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
286 base::MessageLoop::current()->RunUntilIdle(); 286 base::MessageLoop::current()->RunUntilIdle();
287 session_.reset();
287 } 288 }
288 289
289 std::unique_ptr<QuicEncryptedPacket> ConstructClientConnectionClosePacket( 290 std::unique_ptr<QuicEncryptedPacket> ConstructClientConnectionClosePacket(
290 QuicPacketNumber num) { 291 QuicPacketNumber num) {
291 return client_maker_.MakeConnectionClosePacket(num); 292 return client_maker_.MakeConnectionClosePacket(num);
292 } 293 }
293 294
294 std::unique_ptr<QuicEncryptedPacket> ConstructServerConnectionClosePacket( 295 std::unique_ptr<QuicEncryptedPacket> ConstructServerConnectionClosePacket(
295 QuicPacketNumber num) { 296 QuicPacketNumber num) {
296 return server_maker_.MakeConnectionClosePacket(num); 297 return server_maker_.MakeConnectionClosePacket(num);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 params_.quic_crypto_client_stream_factory = &crypto_client_stream_factory_; 505 params_.quic_crypto_client_stream_factory = &crypto_client_stream_factory_;
505 params_.host_resolver = &host_resolver_; 506 params_.host_resolver = &host_resolver_;
506 params_.cert_verifier = &cert_verifier_; 507 params_.cert_verifier = &cert_verifier_;
507 params_.transport_security_state = &transport_security_state_; 508 params_.transport_security_state = &transport_security_state_;
508 params_.cert_transparency_verifier = cert_transparency_verifier_.get(); 509 params_.cert_transparency_verifier = cert_transparency_verifier_.get();
509 params_.socket_performance_watcher_factory = 510 params_.socket_performance_watcher_factory =
510 &test_socket_performance_watcher_factory_; 511 &test_socket_performance_watcher_factory_;
511 params_.proxy_service = proxy_service_.get(); 512 params_.proxy_service = proxy_service_.get();
512 params_.ssl_config_service = ssl_config_service_.get(); 513 params_.ssl_config_service = ssl_config_service_.get();
513 params_.http_auth_handler_factory = auth_handler_factory_.get(); 514 params_.http_auth_handler_factory = auth_handler_factory_.get();
514 params_.http_server_properties = http_server_properties_.GetWeakPtr(); 515 params_.http_server_properties = &http_server_properties_;
515 params_.quic_supported_versions = SupportedVersions(GetParam()); 516 params_.quic_supported_versions = SupportedVersions(GetParam());
516 for (const char* host : 517 for (const char* host :
517 {kDefaultServerHostName, "www.example.org", "news.example.org", 518 {kDefaultServerHostName, "www.example.org", "news.example.org",
518 "bar.example.org", "foo.example.org", "invalid.example.org", 519 "bar.example.org", "foo.example.org", "invalid.example.org",
519 "mail.example.com"}) { 520 "mail.example.com"}) {
520 params_.quic_host_whitelist.insert(host); 521 params_.quic_host_whitelist.insert(host);
521 } 522 }
522 523
523 session_.reset(new HttpNetworkSession(params_)); 524 session_.reset(new HttpNetworkSession(params_));
524 session_->quic_stream_factory()->set_require_confirmation(false); 525 session_->quic_stream_factory()->set_require_confirmation(false);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 0); 1007 0);
1007 1008
1008 socket_factory_.AddSocketDataProvider(&http_data); 1009 socket_factory_.AddSocketDataProvider(&http_data);
1009 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); 1010 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
1010 1011
1011 CreateSession(); 1012 CreateSession();
1012 // Send http request, ignore alternative service advertising if response 1013 // Send http request, ignore alternative service advertising if response
1013 // header advertises alternative service for mail.example.org. 1014 // header advertises alternative service for mail.example.org.
1014 request_.url = GURL("http://mail.example.org:443"); 1015 request_.url = GURL("http://mail.example.org:443");
1015 SendRequestAndExpectHttpResponse("hello world"); 1016 SendRequestAndExpectHttpResponse("hello world");
1016 base::WeakPtr<HttpServerProperties> http_server_properties = 1017 HttpServerProperties* http_server_properties =
1017 session_->http_server_properties(); 1018 session_->http_server_properties();
1018 url::SchemeHostPort http_server("http", "mail.example.org", 443); 1019 url::SchemeHostPort http_server("http", "mail.example.org", 443);
1019 url::SchemeHostPort https_server("https", "mail.example.org", 443); 1020 url::SchemeHostPort https_server("https", "mail.example.org", 443);
1020 // Check alternative service is set for the correct origin. 1021 // Check alternative service is set for the correct origin.
1021 EXPECT_EQ(2u, 1022 EXPECT_EQ(2u,
1022 http_server_properties->GetAlternativeServices(http_server).size()); 1023 http_server_properties->GetAlternativeServices(http_server).size());
1023 EXPECT_EQ( 1024 EXPECT_EQ(
1024 0u, http_server_properties->GetAlternativeServices(https_server).size()); 1025 0u, http_server_properties->GetAlternativeServices(https_server).size());
1025 } 1026 }
1026 1027
(...skipping 11 matching lines...) Expand all
1038 socket_factory_.AddSocketDataProvider(&http_data); 1039 socket_factory_.AddSocketDataProvider(&http_data);
1039 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); 1040 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
1040 socket_factory_.AddSocketDataProvider(&http_data); 1041 socket_factory_.AddSocketDataProvider(&http_data);
1041 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); 1042 socket_factory_.AddSSLSocketDataProvider(&ssl_data_);
1042 1043
1043 CreateSession(); 1044 CreateSession();
1044 1045
1045 // Send https request and set alternative services if response header 1046 // Send https request and set alternative services if response header
1046 // advertises alternative service for mail.example.org. 1047 // advertises alternative service for mail.example.org.
1047 SendRequestAndExpectHttpResponse("hello world"); 1048 SendRequestAndExpectHttpResponse("hello world");
1048 base::WeakPtr<HttpServerProperties> http_server_properties = 1049 HttpServerProperties* http_server_properties =
1049 session_->http_server_properties(); 1050 session_->http_server_properties();
1050 1051
1051 const url::SchemeHostPort https_server(request_.url); 1052 const url::SchemeHostPort https_server(request_.url);
1052 // Check alternative service is set. 1053 // Check alternative service is set.
1053 AlternativeServiceVector alternative_service_vector = 1054 AlternativeServiceVector alternative_service_vector =
1054 http_server_properties->GetAlternativeServices(https_server); 1055 http_server_properties->GetAlternativeServices(https_server);
1055 EXPECT_EQ(2u, alternative_service_vector.size()); 1056 EXPECT_EQ(2u, alternative_service_vector.size());
1056 1057
1057 // Send http request to the same origin but with diffrent scheme, should not 1058 // Send http request to the same origin but with diffrent scheme, should not
1058 // use QUIC. 1059 // use QUIC.
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 params.client_socket_factory = &socket_factory_; 2180 params.client_socket_factory = &socket_factory_;
2180 params.host_resolver = &host_resolver_; 2181 params.host_resolver = &host_resolver_;
2181 params.cert_verifier = &cert_verifier_; 2182 params.cert_verifier = &cert_verifier_;
2182 params.transport_security_state = &transport_security_state_; 2183 params.transport_security_state = &transport_security_state_;
2183 params.cert_transparency_verifier = cert_transparency_verifier_.get(); 2184 params.cert_transparency_verifier = cert_transparency_verifier_.get();
2184 params.socket_performance_watcher_factory = 2185 params.socket_performance_watcher_factory =
2185 &test_socket_performance_watcher_factory_; 2186 &test_socket_performance_watcher_factory_;
2186 params.ssl_config_service = ssl_config_service_.get(); 2187 params.ssl_config_service = ssl_config_service_.get();
2187 params.proxy_service = proxy_service_.get(); 2188 params.proxy_service = proxy_service_.get();
2188 params.http_auth_handler_factory = auth_handler_factory_.get(); 2189 params.http_auth_handler_factory = auth_handler_factory_.get();
2189 params.http_server_properties = http_server_properties_.GetWeakPtr(); 2190 params.http_server_properties = &http_server_properties_;
2190 params.quic_supported_versions = SupportedVersions(version_); 2191 params.quic_supported_versions = SupportedVersions(version_);
2191 params.quic_host_whitelist.insert("news.example.org"); 2192 params.quic_host_whitelist.insert("news.example.org");
2192 params.quic_host_whitelist.insert("mail.example.org"); 2193 params.quic_host_whitelist.insert("mail.example.org");
2193 params.quic_host_whitelist.insert("mail.example.com"); 2194 params.quic_host_whitelist.insert("mail.example.com");
2194 2195
2195 session_.reset(new HttpNetworkSession(params)); 2196 session_.reset(new HttpNetworkSession(params));
2196 session_->quic_stream_factory()->set_require_confirmation(true); 2197 session_->quic_stream_factory()->set_require_confirmation(true);
2197 ASSERT_EQ(params.quic_socket_receive_buffer_size, 2198 ASSERT_EQ(params.quic_socket_receive_buffer_size,
2198 session_->quic_stream_factory()->socket_receive_buffer_size()); 2199 session_->quic_stream_factory()->socket_receive_buffer_size());
2199 } 2200 }
2200 2201
2201 void TearDown() override { 2202 void TearDown() override {
2202 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 2203 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
2203 // Empty the current queue. 2204 // Empty the current queue.
2204 base::MessageLoop::current()->RunUntilIdle(); 2205 base::MessageLoop::current()->RunUntilIdle();
2205 PlatformTest::TearDown(); 2206 PlatformTest::TearDown();
2206 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); 2207 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
2207 base::MessageLoop::current()->RunUntilIdle(); 2208 base::MessageLoop::current()->RunUntilIdle();
2209 session_.reset();
2208 } 2210 }
2209 2211
2210 void SetAlternativeService(const std::string& origin) { 2212 void SetAlternativeService(const std::string& origin) {
2211 HostPortPair destination; 2213 HostPortPair destination;
2212 switch (destination_type_) { 2214 switch (destination_type_) {
2213 case SAME_AS_FIRST: 2215 case SAME_AS_FIRST:
2214 destination = HostPortPair(origin1_, 443); 2216 destination = HostPortPair(origin1_, 443);
2215 break; 2217 break;
2216 case SAME_AS_SECOND: 2218 case SAME_AS_SECOND:
2217 destination = HostPortPair(origin2_, 443); 2219 destination = HostPortPair(origin2_, 443);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 AddHangingSocketData(); 2559 AddHangingSocketData();
2558 2560
2559 SendRequestAndExpectQuicResponse(origin1_); 2561 SendRequestAndExpectQuicResponse(origin1_);
2560 SendRequestAndExpectQuicResponse(origin2_); 2562 SendRequestAndExpectQuicResponse(origin2_);
2561 2563
2562 EXPECT_TRUE(AllDataConsumed()); 2564 EXPECT_TRUE(AllDataConsumed());
2563 } 2565 }
2564 2566
2565 } // namespace test 2567 } // namespace test
2566 } // namespace net 2568 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698