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" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); | 120 scoped_ptr<spdy::SpdyFrame> goaway(ConstructSpdyGoAway()); |
121 MockRead reads[] = { | 121 MockRead reads[] = { |
122 CreateMockRead(*goaway), | 122 CreateMockRead(*goaway), |
123 MockRead(SYNCHRONOUS, 0, 0) // EOF | 123 MockRead(SYNCHRONOUS, 0, 0) // EOF |
124 }; | 124 }; |
125 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); | 125 StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0); |
126 data.set_connect_data(connect_data); | 126 data.set_connect_data(connect_data); |
127 session_deps.socket_factory->AddSocketDataProvider(&data); | 127 session_deps.socket_factory->AddSocketDataProvider(&data); |
128 | 128 |
129 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); | 129 SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
130 ssl.SetNextProto(SSLClientSocket::kProtoSPDY21); | |
ramant (doing other things)
2012/03/15 05:41:34
kProtoSPDY21 is this intentional? Could we use kPr
Ryan Hamilton
2012/03/15 16:38:06
Done.
| |
130 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); | 131 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
131 | 132 |
132 scoped_refptr<HttpNetworkSession> http_session( | 133 scoped_refptr<HttpNetworkSession> http_session( |
133 SpdySessionDependencies::SpdyCreateSession(&session_deps)); | 134 SpdySessionDependencies::SpdyCreateSession(&session_deps)); |
134 | 135 |
135 const std::string kTestHost("www.foo.com"); | 136 const std::string kTestHost("www.foo.com"); |
136 const int kTestPort = 80; | 137 const int kTestPort = 80; |
137 HostPortPair test_host_port_pair(kTestHost, kTestPort); | 138 HostPortPair test_host_port_pair(kTestHost, kTestPort); |
138 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); | 139 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); |
139 | 140 |
140 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); | 141 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); |
141 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 142 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
142 scoped_refptr<SpdySession> session = | 143 scoped_refptr<SpdySession> session = |
143 spdy_session_pool->Get(pair, BoundNetLog()); | 144 spdy_session_pool->Get(pair, BoundNetLog()); |
144 EXPECT_TRUE(spdy_session_pool->HasSession(pair)); | 145 EXPECT_TRUE(spdy_session_pool->HasSession(pair)); |
145 | 146 |
146 scoped_refptr<TransportSocketParams> transport_params( | 147 scoped_refptr<TransportSocketParams> transport_params( |
147 new TransportSocketParams(test_host_port_pair, | 148 new TransportSocketParams(test_host_port_pair, |
148 MEDIUM, | 149 MEDIUM, |
149 false, | 150 false, |
150 false)); | 151 false)); |
151 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 152 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
152 EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(), | 153 EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(), |
153 transport_params, MEDIUM, CompletionCallback(), | 154 transport_params, MEDIUM, CompletionCallback(), |
154 http_session->GetTransportSocketPool(), | 155 http_session->GetTransportSocketPool(), |
155 BoundNetLog())); | 156 BoundNetLog())); |
156 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); | 157 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); |
158 EXPECT_EQ(2, session->GetProtocolVersion()); | |
157 | 159 |
158 // Flush the SpdySession::OnReadComplete() task. | 160 // Flush the SpdySession::OnReadComplete() task. |
159 MessageLoop::current()->RunAllPending(); | 161 MessageLoop::current()->RunAllPending(); |
160 | 162 |
161 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); | 163 EXPECT_FALSE(spdy_session_pool->HasSession(pair)); |
162 | 164 |
163 scoped_refptr<SpdySession> session2 = | 165 scoped_refptr<SpdySession> session2 = |
164 spdy_session_pool->Get(pair, BoundNetLog()); | 166 spdy_session_pool->Get(pair, BoundNetLog()); |
165 | 167 |
166 // Delete the first session. | 168 // Delete the first session. |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1134 net::NetLog::PHASE_NONE); | 1136 net::NetLog::PHASE_NONE); |
1135 | 1137 |
1136 CapturingNetLog::Entry entry = entries[pos]; | 1138 CapturingNetLog::Entry entry = entries[pos]; |
1137 NetLogSpdySessionCloseParameter* request_params = | 1139 NetLogSpdySessionCloseParameter* request_params = |
1138 static_cast<NetLogSpdySessionCloseParameter*>( | 1140 static_cast<NetLogSpdySessionCloseParameter*>( |
1139 entry.extra_parameters.get()); | 1141 entry.extra_parameters.get()); |
1140 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status()); | 1142 EXPECT_EQ(ERR_CONNECTION_CLOSED, request_params->status()); |
1141 } | 1143 } |
1142 | 1144 |
1143 } // namespace net | 1145 } // namespace net |
OLD | NEW |