| 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/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
| 6 | 6 |
| 7 #include "net/base/host_cache.h" | 7 #include "net/base/host_cache.h" |
| 8 #include "net/base/ip_endpoint.h" | 8 #include "net/base/ip_endpoint.h" |
| 9 #include "net/base/net_log_unittest.h" | 9 #include "net/base/net_log_unittest.h" |
| 10 #include "net/spdy/spdy_io_buffer.h" | 10 #include "net/spdy/spdy_io_buffer.h" |
| 11 #include "net/spdy/spdy_session_pool.h" | 11 #include "net/spdy/spdy_session_pool.h" |
| 12 #include "net/spdy/spdy_stream.h" | 12 #include "net/spdy/spdy_stream.h" |
| 13 #include "net/spdy/spdy_test_util_spdy3.h" | 13 #include "net/spdy/spdy_test_util_spdy3.h" |
| 14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 15 | 15 |
| 16 using namespace net::test_spdy3; | 16 using namespace net::test_spdy3; |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 // TODO(cbentzel): Expose compression setter/getter in public SpdySession | 20 // TODO(cbentzel): Expose compression setter/getter in public SpdySession |
| 21 // interface rather than going through all these contortions. | 21 // interface rather than going through all these contortions. |
| 22 class SpdySessionSpdy3Test : public PlatformTest { | 22 class SpdySessionSpdy3Test : public PlatformTest { |
| 23 protected: | 23 protected: |
| 24 virtual void SetUp() { | 24 virtual void SetUp() { |
| 25 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); | 25 SpdySession::set_default_protocol(kProtoSPDY3); |
| 26 } | 26 } |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 SpdyTestStateHelper spdy_state_; | 29 SpdyTestStateHelper spdy_state_; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class TestSpdyStreamDelegate : public net::SpdyStream::Delegate { | 32 class TestSpdyStreamDelegate : public net::SpdyStream::Delegate { |
| 33 public: | 33 public: |
| 34 explicit TestSpdyStreamDelegate(const CompletionCallback& callback) | 34 explicit TestSpdyStreamDelegate(const CompletionCallback& callback) |
| 35 : callback_(callback) {} | 35 : callback_(callback) {} |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); | 114 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); |
| 115 MockRead reads[] = { | 115 MockRead reads[] = { |
| 116 CreateMockRead(*goaway), | 116 CreateMockRead(*goaway), |
| 117 MockRead(SYNCHRONOUS, 0, 0) // EOF | 117 MockRead(SYNCHRONOUS, 0, 0) // EOF |
| 118 }; | 118 }; |
| 119 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 119 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| 120 data.set_connect_data(connect_data); | 120 data.set_connect_data(connect_data); |
| 121 session_deps.socket_factory->AddSocketDataProvider(&data); | 121 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 122 | 122 |
| 123 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | 123 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 124 ssl.SetNextProto(SSLClientSocket::kProtoSPDY3); | 124 ssl.SetNextProto(kProtoSPDY3); |
| 125 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 125 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 126 | 126 |
| 127 scoped_refptr<HttpNetworkSession> http_session( | 127 scoped_refptr<HttpNetworkSession> http_session( |
| 128 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 128 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 129 | 129 |
| 130 const std::string kTestHost("www.foo.com"); | 130 const std::string kTestHost("www.foo.com"); |
| 131 const int kTestPort = 80; | 131 const int kTestPort = 80; |
| 132 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 132 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
| 133 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 133 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
| 134 | 134 |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 MockConnect connect_data(SYNCHRONOUS, OK); | 934 MockConnect connect_data(SYNCHRONOUS, OK); |
| 935 MockRead reads[] = { | 935 MockRead reads[] = { |
| 936 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. | 936 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
| 937 }; | 937 }; |
| 938 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 938 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
| 939 data.set_connect_data(connect_data); | 939 data.set_connect_data(connect_data); |
| 940 session_deps.socket_factory->AddSocketDataProvider(&data); | 940 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 941 | 941 |
| 942 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | 942 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 943 ssl.domain_bound_cert_type = CLIENT_CERT_ECDSA_SIGN; | 943 ssl.domain_bound_cert_type = CLIENT_CERT_ECDSA_SIGN; |
| 944 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY3; | 944 ssl.protocol_negotiated = kProtoSPDY3; |
| 945 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 945 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 946 | 946 |
| 947 scoped_refptr<HttpNetworkSession> http_session( | 947 scoped_refptr<HttpNetworkSession> http_session( |
| 948 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 948 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 949 | 949 |
| 950 const GURL url("https:/www.foo.com"); | 950 const GURL url("https:/www.foo.com"); |
| 951 HostPortPair test_host_port_pair(url.host(), 443); | 951 HostPortPair test_host_port_pair(url.host(), 443); |
| 952 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 952 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
| 953 | 953 |
| 954 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 954 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 MockWrite writes[] = { | 1004 MockWrite writes[] = { |
| 1005 CreateMockWrite(*settings_frame), | 1005 CreateMockWrite(*settings_frame), |
| 1006 }; | 1006 }; |
| 1007 StaticSocketDataProvider data(reads, arraysize(reads), | 1007 StaticSocketDataProvider data(reads, arraysize(reads), |
| 1008 writes, arraysize(writes)); | 1008 writes, arraysize(writes)); |
| 1009 data.set_connect_data(connect_data); | 1009 data.set_connect_data(connect_data); |
| 1010 session_deps.socket_factory->AddSocketDataProvider(&data); | 1010 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 1011 | 1011 |
| 1012 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | 1012 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| 1013 ssl.domain_bound_cert_type = CLIENT_CERT_ECDSA_SIGN; | 1013 ssl.domain_bound_cert_type = CLIENT_CERT_ECDSA_SIGN; |
| 1014 ssl.protocol_negotiated = SSLClientSocket::kProtoSPDY3; | 1014 ssl.protocol_negotiated = kProtoSPDY3; |
| 1015 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 1015 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 1016 | 1016 |
| 1017 scoped_refptr<HttpNetworkSession> http_session( | 1017 scoped_refptr<HttpNetworkSession> http_session( |
| 1018 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 1018 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
| 1019 | 1019 |
| 1020 const GURL kTestUrl("https://www.foo.com"); | 1020 const GURL kTestUrl("https://www.foo.com"); |
| 1021 HostPortPair test_host_port_pair(kTestUrl.host(), 443); | 1021 HostPortPair test_host_port_pair(kTestUrl.host(), 443); |
| 1022 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 1022 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
| 1023 | 1023 |
| 1024 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 1024 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 net::NetLog::PHASE_NONE); | 1126 net::NetLog::PHASE_NONE); |
| 1127 | 1127 |
| 1128 CapturingNetLog::Entry entry = entries[pos]; | 1128 CapturingNetLog::Entry entry = entries[pos]; |
| 1129 NetLogSpdySessionCloseParameter* request_params = | 1129 NetLogSpdySessionCloseParameter* request_params = |
| 1130 static_cast<NetLogSpdySessionCloseParameter*>( | 1130 static_cast<NetLogSpdySessionCloseParameter*>( |
| 1131 entry.extra_parameters.get()); | 1131 entry.extra_parameters.get()); |
| 1132 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status()); | 1132 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status()); |
| 1133 } | 1133 } |
| 1134 | 1134 |
| 1135 } // namespace net | 1135 } // namespace net |
| OLD | NEW |