Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.h" |
| 11 #include "net/base/test_completion_callback.h" | 11 #include "net/base/test_completion_callback.h" |
| 12 #include "net/cert/mock_cert_verifier.h" | 12 #include "net/cert/mock_cert_verifier.h" |
| 13 #include "net/dns/mock_host_resolver.h" | 13 #include "net/dns/mock_host_resolver.h" |
| 14 #include "net/http/http_auth_handler_factory.h" | 14 #include "net/http/http_auth_handler_factory.h" |
| 15 #include "net/http/http_network_session.h" | 15 #include "net/http/http_network_session.h" |
| 16 #include "net/http/http_network_session_peer.h" | 16 #include "net/http/http_network_session_peer.h" |
| 17 #include "net/http/http_network_transaction.h" | 17 #include "net/http/http_network_transaction.h" |
| 18 #include "net/http/http_request_info.h" | 18 #include "net/http/http_request_info.h" |
| 19 #include "net/http/http_server_properties_impl.h" | 19 #include "net/http/http_server_properties_impl.h" |
| 20 #include "net/http/http_stream.h" | 20 #include "net/http/http_stream.h" |
| 21 #include "net/http/websocket_stream_base.h" | |
| 21 #include "net/proxy/proxy_info.h" | 22 #include "net/proxy/proxy_info.h" |
| 22 #include "net/proxy/proxy_service.h" | 23 #include "net/proxy/proxy_service.h" |
| 24 #include "net/socket/client_socket_handle.h" | |
| 23 #include "net/socket/mock_client_socket_pool_manager.h" | 25 #include "net/socket/mock_client_socket_pool_manager.h" |
| 26 #include "net/socket/next_proto.h" | |
| 24 #include "net/socket/socket_test_util.h" | 27 #include "net/socket/socket_test_util.h" |
| 25 #include "net/spdy/spdy_session.h" | 28 #include "net/spdy/spdy_session.h" |
| 26 #include "net/spdy/spdy_session_pool.h" | 29 #include "net/spdy/spdy_session_pool.h" |
| 30 #include "net/spdy/spdy_test_util_common.h" | |
| 31 #include "net/ssl/ssl_config_service.h" | |
| 27 #include "net/ssl/ssl_config_service_defaults.h" | 32 #include "net/ssl/ssl_config_service_defaults.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 34 |
| 30 namespace net { | 35 namespace net { |
| 31 | 36 |
| 32 namespace { | 37 namespace { |
| 33 | 38 |
| 39 class ScopedForceSpdySsl { | |
| 40 public: | |
| 41 ScopedForceSpdySsl(): | |
| 42 orig_force_spdy_over_ssl_(HttpStreamFactory::force_spdy_over_ssl()), | |
| 43 orig_force_spdy_always_(HttpStreamFactory::force_spdy_always()) { | |
| 44 HttpStreamFactory::set_force_spdy_over_ssl(true); | |
| 45 HttpStreamFactory::set_force_spdy_always(true); | |
| 46 } | |
| 47 ~ScopedForceSpdySsl() { | |
| 48 HttpStreamFactory::set_force_spdy_over_ssl(orig_force_spdy_over_ssl_); | |
| 49 HttpStreamFactory::set_force_spdy_always(orig_force_spdy_always_); | |
| 50 } | |
| 51 | |
| 52 private: | |
| 53 const bool orig_force_spdy_over_ssl_; | |
| 54 const bool orig_force_spdy_always_; | |
| 55 }; | |
| 56 | |
| 34 class MockHttpStreamFactoryImpl : public HttpStreamFactoryImpl { | 57 class MockHttpStreamFactoryImpl : public HttpStreamFactoryImpl { |
| 35 public: | 58 public: |
| 36 MockHttpStreamFactoryImpl(HttpNetworkSession* session) | 59 MockHttpStreamFactoryImpl(HttpNetworkSession* session, |
| 37 : HttpStreamFactoryImpl(session), | 60 bool for_websocket) |
| 61 : HttpStreamFactoryImpl(session, for_websocket), | |
| 38 preconnect_done_(false), | 62 preconnect_done_(false), |
| 39 waiting_for_preconnect_(false) {} | 63 waiting_for_preconnect_(false) {} |
| 40 | 64 |
| 41 | 65 |
| 42 void WaitForPreconnects() { | 66 void WaitForPreconnects() { |
| 43 while (!preconnect_done_) { | 67 while (!preconnect_done_) { |
| 44 waiting_for_preconnect_ = true; | 68 waiting_for_preconnect_ = true; |
| 45 base::MessageLoop::current()->Run(); | 69 base::MessageLoop::current()->Run(); |
| 46 waiting_for_preconnect_ = false; | 70 waiting_for_preconnect_ = false; |
| 47 } | 71 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 71 const SSLConfig& used_ssl_config, | 95 const SSLConfig& used_ssl_config, |
| 72 const ProxyInfo& used_proxy_info, | 96 const ProxyInfo& used_proxy_info, |
| 73 HttpStreamBase* stream) OVERRIDE { | 97 HttpStreamBase* stream) OVERRIDE { |
| 74 stream_done_ = true; | 98 stream_done_ = true; |
| 75 if (waiting_for_stream_) | 99 if (waiting_for_stream_) |
| 76 base::MessageLoop::current()->Quit(); | 100 base::MessageLoop::current()->Quit(); |
| 77 stream_.reset(stream); | 101 stream_.reset(stream); |
| 78 used_ssl_config_ = used_ssl_config; | 102 used_ssl_config_ = used_ssl_config; |
| 79 } | 103 } |
| 80 | 104 |
| 105 virtual void OnWebSocketStreamReady( | |
| 106 const SSLConfig& used_ssl_config, | |
| 107 const ProxyInfo& used_proxy_info, | |
| 108 WebSocketStreamBase* stream) OVERRIDE { | |
| 109 stream_done_ = true; | |
| 110 if (waiting_for_stream_) | |
| 111 MessageLoop::current()->Quit(); | |
| 112 websocket_stream_.reset(stream); | |
| 113 } | |
| 114 | |
| 81 virtual void OnStreamFailed( | 115 virtual void OnStreamFailed( |
| 82 int status, | 116 int status, |
| 83 const SSLConfig& used_ssl_config) OVERRIDE {} | 117 const SSLConfig& used_ssl_config) OVERRIDE {} |
| 84 | 118 |
| 85 virtual void OnCertificateError( | 119 virtual void OnCertificateError( |
| 86 int status, | 120 int status, |
| 87 const SSLConfig& used_ssl_config, | 121 const SSLConfig& used_ssl_config, |
| 88 const SSLInfo& ssl_info) OVERRIDE {} | 122 const SSLInfo& ssl_info) OVERRIDE {} |
| 89 | 123 |
| 90 virtual void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response, | 124 virtual void OnNeedsProxyAuth(const HttpResponseInfo& proxy_response, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 109 } | 143 } |
| 110 | 144 |
| 111 const SSLConfig& used_ssl_config() const { | 145 const SSLConfig& used_ssl_config() const { |
| 112 return used_ssl_config_; | 146 return used_ssl_config_; |
| 113 } | 147 } |
| 114 | 148 |
| 115 HttpStreamBase* stream() { | 149 HttpStreamBase* stream() { |
| 116 return stream_.get(); | 150 return stream_.get(); |
| 117 } | 151 } |
| 118 | 152 |
| 153 WebSocketStreamBase* websocket_stream() { | |
| 154 return websocket_stream_.get(); | |
| 155 } | |
| 156 | |
| 157 bool stream_done() const { return stream_done_; } | |
| 158 SpdySession* spdy_session() {return spdy_session_.get(); } | |
| 159 ClientSocketHandle* connection() { return connection_.get(); } | |
| 119 | 160 |
| 120 private: | 161 private: |
| 121 bool waiting_for_stream_; | 162 bool waiting_for_stream_; |
| 122 bool stream_done_; | 163 bool stream_done_; |
| 123 scoped_ptr<HttpStreamBase> stream_; | 164 scoped_ptr<HttpStreamBase> stream_; |
| 165 scoped_ptr<WebSocketStreamBase> websocket_stream_; | |
| 124 SSLConfig used_ssl_config_; | 166 SSLConfig used_ssl_config_; |
| 167 scoped_ptr<ClientSocketHandle> connection_; | |
| 168 scoped_refptr<SpdySession> spdy_session_; | |
| 125 | 169 |
| 126 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter); | 170 DISALLOW_COPY_AND_ASSIGN(StreamRequestWaiter); |
| 127 }; | 171 }; |
| 128 | 172 |
| 173 class WebSocketSpdyStream : public WebSocketStreamBase { | |
| 174 public: | |
| 175 explicit WebSocketSpdyStream(SpdySession* spdy_session): | |
| 176 WebSocketStreamBase(kStreamTypeSpdy), spdy_session_(spdy_session) {} | |
| 177 SpdySession* spdy_session() {return spdy_session_.get();} | |
| 178 | |
| 179 private: | |
| 180 scoped_refptr<SpdySession> spdy_session_; | |
| 181 }; | |
| 182 | |
| 183 class WebSocketBasicStream : public WebSocketStreamBase { | |
| 184 public: | |
| 185 explicit WebSocketBasicStream(ClientSocketHandle* connection): | |
| 186 WebSocketStreamBase(kStreamTypeBasic), connection_(connection) {} | |
| 187 ClientSocketHandle* connection() {return connection_.get();} | |
| 188 | |
| 189 private: | |
| 190 scoped_ptr<ClientSocketHandle> connection_; | |
| 191 }; | |
| 192 | |
| 193 class WebSocketStreamFactory : public WebSocketStreamBase::Factory { | |
| 194 public: | |
| 195 virtual WebSocketStreamBase* CreateBasicStream(ClientSocketHandle* connection, | |
| 196 bool using_proxy) OVERRIDE { | |
| 197 return new WebSocketBasicStream(connection); | |
| 198 } | |
| 199 virtual WebSocketStreamBase* CreateSpdyStream( | |
| 200 SpdySession* spdy_session, | |
| 201 bool use_relative_url) OVERRIDE { | |
| 202 return new WebSocketSpdyStream(spdy_session); | |
| 203 } | |
| 204 }; | |
| 205 | |
| 129 struct SessionDependencies { | 206 struct SessionDependencies { |
| 130 // Custom proxy service dependency. | 207 // Custom proxy service dependency. |
| 131 explicit SessionDependencies(ProxyService* proxy_service) | 208 explicit SessionDependencies(ProxyService* proxy_service) |
| 132 : host_resolver(new MockHostResolver), | 209 : host_resolver(new MockHostResolver), |
| 133 cert_verifier(new MockCertVerifier), | 210 cert_verifier(new MockCertVerifier), |
| 134 proxy_service(proxy_service), | 211 proxy_service(proxy_service), |
| 135 ssl_config_service(new SSLConfigServiceDefaults), | 212 ssl_config_service(new SSLConfigServiceDefaults), |
| 136 http_auth_handler_factory( | 213 http_auth_handler_factory( |
| 137 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | 214 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), |
| 138 net_log(NULL) {} | 215 net_log(NULL) {} |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 { 2, false }, | 248 { 2, false }, |
| 172 { 1, true}, | 249 { 1, true}, |
| 173 { 2, true}, | 250 { 2, true}, |
| 174 }; | 251 }; |
| 175 | 252 |
| 176 void PreconnectHelperForURL(int num_streams, | 253 void PreconnectHelperForURL(int num_streams, |
| 177 const GURL& url, | 254 const GURL& url, |
| 178 HttpNetworkSession* session) { | 255 HttpNetworkSession* session) { |
| 179 HttpNetworkSessionPeer peer(session); | 256 HttpNetworkSessionPeer peer(session); |
| 180 MockHttpStreamFactoryImpl* mock_factory = | 257 MockHttpStreamFactoryImpl* mock_factory = |
| 181 new MockHttpStreamFactoryImpl(session); | 258 new MockHttpStreamFactoryImpl(session, false); |
| 182 peer.SetHttpStreamFactory(mock_factory); | 259 peer.SetHttpStreamFactory(mock_factory); |
| 183 SSLConfig ssl_config; | 260 SSLConfig ssl_config; |
| 184 session->ssl_config_service()->GetSSLConfig(&ssl_config); | 261 session->ssl_config_service()->GetSSLConfig(&ssl_config); |
| 185 | 262 |
| 186 HttpRequestInfo request; | 263 HttpRequestInfo request; |
| 187 request.method = "GET"; | 264 request.method = "GET"; |
| 188 request.url = url; | 265 request.url = url; |
| 189 request.load_flags = 0; | 266 request.load_flags = 0; |
| 190 | 267 |
| 191 session->http_stream_factory()->PreconnectStreams( | 268 session->http_stream_factory()->PreconnectStreams( |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 socket_data1.set_connect_data(MockConnect(ASYNC, ERR_ADDRESS_UNREACHABLE)); | 530 socket_data1.set_connect_data(MockConnect(ASYNC, ERR_ADDRESS_UNREACHABLE)); |
| 454 session_deps.socket_factory.AddSocketDataProvider(&socket_data1); | 531 session_deps.socket_factory.AddSocketDataProvider(&socket_data1); |
| 455 | 532 |
| 456 // Second connection attempt succeeds | 533 // Second connection attempt succeeds |
| 457 StaticSocketDataProvider socket_data2; | 534 StaticSocketDataProvider socket_data2; |
| 458 socket_data2.set_connect_data(MockConnect(ASYNC, OK)); | 535 socket_data2.set_connect_data(MockConnect(ASYNC, OK)); |
| 459 session_deps.socket_factory.AddSocketDataProvider(&socket_data2); | 536 session_deps.socket_factory.AddSocketDataProvider(&socket_data2); |
| 460 | 537 |
| 461 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 538 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 462 | 539 |
| 463 // Now request a stream. It should succeed using the second proxy in the | 540 // Now request a stream. |
| 464 // list. | |
| 465 HttpRequestInfo request_info; | 541 HttpRequestInfo request_info; |
| 466 request_info.method = "GET"; | 542 request_info.method = "GET"; |
| 467 request_info.url = GURL("http://www.google.com"); | 543 request_info.url = GURL("http://www.google.com"); |
| 468 | 544 |
| 469 SSLConfig ssl_config; | 545 SSLConfig ssl_config; |
| 470 StreamRequestWaiter waiter; | 546 StreamRequestWaiter waiter; |
| 471 scoped_ptr<HttpStreamRequest> request( | 547 scoped_ptr<HttpStreamRequest> request( |
| 472 session->http_stream_factory()->RequestStream( | 548 session->http_stream_factory()->RequestStream( |
| 473 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, | 549 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, |
| 474 &waiter, BoundNetLog())); | 550 &waiter, BoundNetLog())); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 scoped_ptr<HttpStreamRequest> request( | 679 scoped_ptr<HttpStreamRequest> request( |
| 604 session->http_stream_factory()->RequestStream( | 680 session->http_stream_factory()->RequestStream( |
| 605 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, | 681 request_info, DEFAULT_PRIORITY, ssl_config, ssl_config, |
| 606 &waiter, BoundNetLog())); | 682 &waiter, BoundNetLog())); |
| 607 | 683 |
| 608 EXPECT_EQ(LOAD_STATE_RESOLVING_HOST, request->GetLoadState()); | 684 EXPECT_EQ(LOAD_STATE_RESOLVING_HOST, request->GetLoadState()); |
| 609 | 685 |
| 610 waiter.WaitForStream(); | 686 waiter.WaitForStream(); |
| 611 } | 687 } |
| 612 | 688 |
| 689 TEST(HttpStreamFactoryTest, RequestStream) { | |
| 690 SessionDependencies session_deps(ProxyService::CreateDirect()); | |
| 691 | |
| 692 StaticSocketDataProvider socket_data; | |
| 693 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | |
| 694 session_deps.socket_factory.AddSocketDataProvider(&socket_data); | |
| 695 | |
| 696 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | |
| 697 | |
| 698 // Now request a stream. It should succeed using the second proxy in the | |
| 699 // list. | |
| 700 HttpRequestInfo request_info; | |
| 701 request_info.method = "GET"; | |
| 702 request_info.url = GURL("http://www.google.com"); | |
| 703 request_info.load_flags = 0; | |
| 704 | |
| 705 SSLConfig ssl_config; | |
| 706 StreamRequestWaiter waiter; | |
| 707 scoped_ptr<HttpStreamRequest> request( | |
| 708 session->http_stream_factory()->RequestStream( | |
| 709 request_info, | |
| 710 DEFAULT_PRIORITY, | |
| 711 ssl_config, | |
| 712 ssl_config, | |
| 713 &waiter, | |
| 714 BoundNetLog())); | |
| 715 waiter.WaitForStream(); | |
| 716 EXPECT_TRUE(waiter.stream_done()); | |
| 717 EXPECT_TRUE(NULL == waiter.spdy_session()); | |
| 718 EXPECT_TRUE(NULL == waiter.connection()); | |
| 719 EXPECT_TRUE(NULL != waiter.stream()); | |
| 720 } | |
| 721 | |
| 722 TEST(HttpStreamFactoryTest, RequestWebSocketBasicStream) { | |
|
mmenke
2013/05/24 14:53:22
These tests should make sure the socket was create
yhirano
2013/05/27 09:21:32
Done.
Since net::InitSocketHandleForHttp is respon
| |
| 723 SessionDependencies session_deps(ProxyService::CreateDirect()); | |
| 724 | |
| 725 StaticSocketDataProvider socket_data; | |
| 726 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | |
| 727 session_deps.socket_factory.AddSocketDataProvider(&socket_data); | |
| 728 | |
| 729 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | |
| 730 | |
| 731 // Now request a stream. | |
| 732 HttpRequestInfo request_info; | |
| 733 request_info.method = "GET"; | |
| 734 request_info.url = GURL("ws://www.google.com"); | |
| 735 request_info.load_flags = 0; | |
| 736 | |
| 737 SSLConfig ssl_config; | |
| 738 StreamRequestWaiter waiter; | |
| 739 WebSocketStreamFactory factory; | |
| 740 scoped_ptr<HttpStreamRequest> request( | |
| 741 session->websocket_stream_factory()->RequestWebSocketStream( | |
| 742 request_info, | |
| 743 DEFAULT_PRIORITY, | |
| 744 ssl_config, | |
| 745 ssl_config, | |
| 746 &waiter, | |
| 747 &factory, | |
| 748 BoundNetLog())); | |
| 749 waiter.WaitForStream(); | |
| 750 EXPECT_TRUE(waiter.stream_done()); | |
| 751 EXPECT_TRUE(NULL == waiter.stream()); | |
| 752 EXPECT_TRUE(NULL != waiter.websocket_stream()); | |
| 753 EXPECT_EQ(WebSocketStreamBase::kStreamTypeBasic, | |
| 754 waiter.websocket_stream()->type()); | |
| 755 } | |
| 756 | |
| 757 TEST(HttpStreamFactoryTest, RequestSpdyHttpStream) { | |
| 758 ScopedForceSpdySsl use_spdy; | |
| 759 SpdySessionDependencies session_deps(kProtoSPDY3, | |
| 760 ProxyService::CreateDirect()); | |
| 761 | |
| 762 MockRead mock_read(ASYNC, OK); | |
| 763 StaticSocketDataProvider socket_data(&mock_read, 1, NULL, 0); | |
| 764 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | |
| 765 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | |
| 766 | |
| 767 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); | |
| 768 ssl_socket_data.protocol_negotiated = kProtoSPDY3; | |
| 769 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); | |
| 770 | |
| 771 HostPortPair host_port_pair("www.google.com", 80); | |
| 772 scoped_refptr<HttpNetworkSession> | |
| 773 session(SpdySessionDependencies::SpdyCreateSession(&session_deps)); | |
| 774 | |
| 775 // Now request a stream. | |
| 776 HttpRequestInfo request_info; | |
| 777 request_info.method = "GET"; | |
| 778 request_info.url = GURL("http://www.google.com"); | |
| 779 request_info.load_flags = 0; | |
| 780 | |
| 781 SSLConfig ssl_config; | |
| 782 StreamRequestWaiter waiter; | |
| 783 scoped_ptr<HttpStreamRequest> request( | |
| 784 session->http_stream_factory()->RequestStream( | |
| 785 request_info, | |
| 786 DEFAULT_PRIORITY, | |
| 787 ssl_config, | |
| 788 ssl_config, | |
| 789 &waiter, | |
| 790 BoundNetLog())); | |
| 791 waiter.WaitForStream(); | |
| 792 EXPECT_TRUE(waiter.stream_done()); | |
| 793 EXPECT_TRUE(NULL == waiter.websocket_stream()); | |
| 794 EXPECT_TRUE(NULL != waiter.stream()); | |
| 795 EXPECT_TRUE(waiter.stream()->IsSpdyHttpStream()); | |
| 796 } | |
| 797 | |
| 798 TEST(HttpStreamFactoryTest, RequestWebSocketSpdyStream) { | |
| 799 ScopedForceSpdySsl use_spdy; | |
| 800 SpdySessionDependencies session_deps(kProtoSPDY3, | |
| 801 ProxyService::CreateDirect()); | |
| 802 | |
| 803 MockRead mock_read(ASYNC, ERR_IO_PENDING); | |
| 804 StaticSocketDataProvider socket_data(&mock_read, 1, NULL, 0); | |
| 805 socket_data.set_connect_data(MockConnect(ASYNC, OK)); | |
| 806 session_deps.socket_factory->AddSocketDataProvider(&socket_data); | |
| 807 | |
| 808 SSLSocketDataProvider ssl_socket_data(ASYNC, OK); | |
| 809 ssl_socket_data.protocol_negotiated = kProtoSPDY3; | |
| 810 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data); | |
| 811 | |
| 812 SSLSocketDataProvider ssl_socket_data2(ASYNC, OK); | |
| 813 ssl_socket_data2.protocol_negotiated = kProtoSPDY3; | |
| 814 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_socket_data2); | |
| 815 | |
| 816 HostPortPair host_port_pair("www.google.com", 80); | |
| 817 scoped_refptr<HttpNetworkSession> | |
| 818 session(SpdySessionDependencies::SpdyCreateSession(&session_deps)); | |
| 819 | |
| 820 // Now request a stream. | |
| 821 HttpRequestInfo request_info; | |
| 822 request_info.method = "GET"; | |
| 823 request_info.url = GURL("wss://www.google.com"); | |
| 824 request_info.load_flags = 0; | |
| 825 | |
| 826 SSLConfig ssl_config; | |
| 827 StreamRequestWaiter waiter1; | |
| 828 WebSocketStreamFactory factory; | |
| 829 scoped_ptr<HttpStreamRequest> request1( | |
| 830 session->websocket_stream_factory()->RequestWebSocketStream( | |
| 831 request_info, | |
| 832 DEFAULT_PRIORITY, | |
| 833 ssl_config, | |
| 834 ssl_config, | |
| 835 &waiter1, | |
| 836 &factory, | |
| 837 BoundNetLog())); | |
| 838 waiter1.WaitForStream(); | |
| 839 EXPECT_TRUE(waiter1.stream_done()); | |
| 840 EXPECT_TRUE(NULL != waiter1.websocket_stream()); | |
| 841 EXPECT_EQ(WebSocketStreamBase::kStreamTypeSpdy, | |
| 842 waiter1.websocket_stream()->type()); | |
| 843 EXPECT_TRUE(NULL == waiter1.connection()); | |
| 844 EXPECT_TRUE(NULL == waiter1.stream()); | |
| 845 | |
| 846 StreamRequestWaiter waiter2; | |
| 847 scoped_ptr<HttpStreamRequest> request2( | |
| 848 session->websocket_stream_factory()->RequestWebSocketStream( | |
| 849 request_info, | |
| 850 DEFAULT_PRIORITY, | |
| 851 ssl_config, | |
| 852 ssl_config, | |
| 853 &waiter2, | |
| 854 &factory, | |
| 855 BoundNetLog())); | |
| 856 waiter2.WaitForStream(); | |
| 857 EXPECT_TRUE(waiter2.stream_done()); | |
| 858 EXPECT_TRUE(NULL != waiter2.websocket_stream()); | |
| 859 EXPECT_EQ(WebSocketStreamBase::kStreamTypeSpdy, | |
| 860 waiter2.websocket_stream()->type()); | |
| 861 EXPECT_TRUE(NULL == waiter2.connection()); | |
| 862 EXPECT_TRUE(NULL == waiter2.stream()); | |
| 863 EXPECT_NE(waiter2.websocket_stream(), waiter1.websocket_stream()); | |
| 864 EXPECT_EQ(static_cast<WebSocketSpdyStream*>(waiter2.websocket_stream())-> | |
| 865 spdy_session(), | |
| 866 static_cast<WebSocketSpdyStream*>(waiter1.websocket_stream())-> | |
| 867 spdy_session()); | |
| 868 } | |
| 869 | |
| 613 } // namespace | 870 } // namespace |
| 614 | 871 |
| 615 } // namespace net | 872 } // namespace net |
| OLD | NEW |