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

Side by Side Diff: net/http/http_stream_factory_impl_unittest.cc

Issue 1824903002: Change the AlternativeServiceMap with SchemeOriginPair key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unittests Created 4 years, 9 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 "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 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 882
883 // Set up QUIC as alternative_service. 883 // Set up QUIC as alternative_service.
884 HttpServerPropertiesImpl http_server_properties; 884 HttpServerPropertiesImpl http_server_properties;
885 const AlternativeService alternative_service(QUIC, url.host().c_str(), 885 const AlternativeService alternative_service(QUIC, url.host().c_str(),
886 url.IntPort()); 886 url.IntPort());
887 AlternativeServiceInfoVector alternative_service_info_vector; 887 AlternativeServiceInfoVector alternative_service_info_vector;
888 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 888 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
889 alternative_service_info_vector.push_back( 889 alternative_service_info_vector.push_back(
890 AlternativeServiceInfo(alternative_service, 1.0, expiration)); 890 AlternativeServiceInfo(alternative_service, 1.0, expiration));
891 HostPortPair host_port_pair(alternative_service.host_port_pair()); 891 HostPortPair host_port_pair(alternative_service.host_port_pair());
892 SchemeOriginPair scheme_origin_pair("https", host_port_pair);
893
892 http_server_properties.SetAlternativeServices( 894 http_server_properties.SetAlternativeServices(
893 host_port_pair, alternative_service_info_vector); 895 scheme_origin_pair, alternative_service_info_vector);
894 896
895 SpdySessionDependencies session_deps( 897 SpdySessionDependencies session_deps(
896 GetParam(), ProxyService::CreateFixed("http_proxy")); 898 GetParam(), ProxyService::CreateFixed("http_proxy"));
897 899
898 // Setup params to disable preconnect, but QUIC doesn't 0RTT. 900 // Setup params to disable preconnect, but QUIC doesn't 0RTT.
899 HttpNetworkSession::Params params = 901 HttpNetworkSession::Params params =
900 SpdySessionDependencies::CreateSessionParams(&session_deps); 902 SpdySessionDependencies::CreateSessionParams(&session_deps);
901 params.enable_quic = true; 903 params.enable_quic = true;
902 params.quic_disable_preconnect_if_0rtt = true; 904 params.quic_disable_preconnect_if_0rtt = true;
903 params.http_server_properties = http_server_properties.GetWeakPtr(); 905 params.http_server_properties = http_server_properties.GetWeakPtr();
(...skipping 22 matching lines...) Expand all
926 GURL url = GURL("https://www.google.com"); 928 GURL url = GURL("https://www.google.com");
927 929
928 // Set up QUIC as alternative_service. 930 // Set up QUIC as alternative_service.
929 HttpServerPropertiesImpl http_server_properties; 931 HttpServerPropertiesImpl http_server_properties;
930 const AlternativeService alternative_service(QUIC, "www.google.com", 443); 932 const AlternativeService alternative_service(QUIC, "www.google.com", 443);
931 AlternativeServiceInfoVector alternative_service_info_vector; 933 AlternativeServiceInfoVector alternative_service_info_vector;
932 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 934 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
933 alternative_service_info_vector.push_back( 935 alternative_service_info_vector.push_back(
934 AlternativeServiceInfo(alternative_service, 1.0, expiration)); 936 AlternativeServiceInfo(alternative_service, 1.0, expiration));
935 HostPortPair host_port_pair(alternative_service.host_port_pair()); 937 HostPortPair host_port_pair(alternative_service.host_port_pair());
938 SchemeOriginPair scheme_origin_pair("https", host_port_pair);
939
936 http_server_properties.SetAlternativeServices( 940 http_server_properties.SetAlternativeServices(
937 host_port_pair, alternative_service_info_vector); 941 scheme_origin_pair, alternative_service_info_vector);
938 942
939 SpdySessionDependencies session_deps(GetParam()); 943 SpdySessionDependencies session_deps(GetParam());
940 944
941 // Setup params to disable preconnect, but QUIC does 0RTT. 945 // Setup params to disable preconnect, but QUIC does 0RTT.
942 HttpNetworkSession::Params params = 946 HttpNetworkSession::Params params =
943 SpdySessionDependencies::CreateSessionParams(&session_deps); 947 SpdySessionDependencies::CreateSessionParams(&session_deps);
944 params.enable_quic = true; 948 params.enable_quic = true;
945 params.quic_disable_preconnect_if_0rtt = true; 949 params.quic_disable_preconnect_if_0rtt = true;
946 params.http_server_properties = http_server_properties.GetWeakPtr(); 950 params.http_server_properties = http_server_properties.GetWeakPtr();
947 951
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 session_->quic_stream_factory()->set_require_confirmation(false); 1563 session_->quic_stream_factory()->set_require_confirmation(false);
1560 } 1564 }
1561 1565
1562 void AddQuicAlternativeService() { 1566 void AddQuicAlternativeService() {
1563 const AlternativeService alternative_service(QUIC, "www.example.org", 443); 1567 const AlternativeService alternative_service(QUIC, "www.example.org", 443);
1564 AlternativeServiceInfoVector alternative_service_info_vector; 1568 AlternativeServiceInfoVector alternative_service_info_vector;
1565 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 1569 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
1566 alternative_service_info_vector.push_back( 1570 alternative_service_info_vector.push_back(
1567 AlternativeServiceInfo(alternative_service, 1.0, expiration)); 1571 AlternativeServiceInfo(alternative_service, 1.0, expiration));
1568 HostPortPair host_port_pair(alternative_service.host_port_pair()); 1572 HostPortPair host_port_pair(alternative_service.host_port_pair());
1573 SchemeOriginPair scheme_origin_pair("https", host_port_pair);
1569 http_server_properties_.SetAlternativeServices( 1574 http_server_properties_.SetAlternativeServices(
1570 host_port_pair, alternative_service_info_vector); 1575 scheme_origin_pair, alternative_service_info_vector);
1571 }; 1576 };
1572 1577
1573 test::QuicTestPacketMaker& packet_maker() { return packet_maker_; } 1578 test::QuicTestPacketMaker& packet_maker() { return packet_maker_; }
1574 1579
1575 MockClientSocketFactory& socket_factory() { return socket_factory_; } 1580 MockClientSocketFactory& socket_factory() { return socket_factory_; }
1576 1581
1577 HttpNetworkSession* session() { return session_.get(); } 1582 HttpNetworkSession* session() { return session_.get(); }
1578 1583
1579 private: 1584 private:
1580 MockClock* clock_; // Owned by QuicStreamFactory 1585 MockClock* clock_; // Owned by QuicStreamFactory
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 SpdySessionDependencies::SpdyCreateSession(&session_deps)); 1885 SpdySessionDependencies::SpdyCreateSession(&session_deps));
1881 1886
1882 // Now request a stream. 1887 // Now request a stream.
1883 HttpRequestInfo request_info; 1888 HttpRequestInfo request_info;
1884 request_info.method = "GET"; 1889 request_info.method = "GET";
1885 request_info.url = GURL("ws://www.google.com:8888"); 1890 request_info.url = GURL("ws://www.google.com:8888");
1886 request_info.load_flags = 0; 1891 request_info.load_flags = 0;
1887 1892
1888 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 1893 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
1889 session->http_server_properties()->SetAlternativeService( 1894 session->http_server_properties()->SetAlternativeService(
1890 HostPortPair("www.google.com", 8888), 1895 SchemeOriginPair(request_info.url.scheme(),
1896 HostPortPair("www.google.com", 8888)),
1891 AlternativeService(NPN_HTTP_2, "www.google.com", 9999), 1.0, expiration); 1897 AlternativeService(NPN_HTTP_2, "www.google.com", 9999), 1.0, expiration);
1892 1898
1893 SSLConfig ssl_config; 1899 SSLConfig ssl_config;
1894 StreamRequestWaiter waiter; 1900 StreamRequestWaiter waiter;
1895 WebSocketStreamCreateHelper create_helper; 1901 WebSocketStreamCreateHelper create_helper;
1896 scoped_ptr<HttpStreamRequest> request( 1902 scoped_ptr<HttpStreamRequest> request(
1897 session->http_stream_factory_for_websocket() 1903 session->http_stream_factory_for_websocket()
1898 ->RequestWebSocketHandshakeStream(request_info, 1904 ->RequestWebSocketHandshakeStream(request_info,
1899 DEFAULT_PRIORITY, 1905 DEFAULT_PRIORITY,
1900 ssl_config, 1906 ssl_config,
(...skipping 22 matching lines...) Expand all
1923 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); 1929 EXPECT_TRUE(waiter.used_proxy_info().is_direct());
1924 1930
1925 // Make sure there is no orphaned job. it is already canceled. 1931 // Make sure there is no orphaned job. it is already canceled.
1926 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( 1932 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>(
1927 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); 1933 session->http_stream_factory_for_websocket())->num_orphaned_jobs());
1928 } 1934 }
1929 1935
1930 } // namespace 1936 } // namespace
1931 1937
1932 } // namespace net 1938 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698