| 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_websocket_stream.h" | 5 #include "net/spdy/spdy_websocket_stream.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 virtual ~SpdyWebSocketStreamSpdy2Test() {} | 185 virtual ~SpdyWebSocketStreamSpdy2Test() {} |
| 186 | 186 |
| 187 virtual void SetUp() { | 187 virtual void SetUp() { |
| 188 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); | 188 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); |
| 189 | 189 |
| 190 host_port_pair_.set_host("example.com"); | 190 host_port_pair_.set_host("example.com"); |
| 191 host_port_pair_.set_port(80); | 191 host_port_pair_.set_port(80); |
| 192 host_port_proxy_pair_.first = host_port_pair_; | 192 host_port_proxy_pair_.first = host_port_pair_; |
| 193 host_port_proxy_pair_.second = ProxyServer::Direct(); | 193 host_port_proxy_pair_.second = ProxyServer::Direct(); |
| 194 | 194 |
| 195 const size_t max_concurrent_streams = 1; | 195 spdy_settings_id_to_set_ = SETTINGS_MAX_CONCURRENT_STREAMS; |
| 196 SettingsFlagsAndId id(SETTINGS_FLAG_PLEASE_PERSIST, | 196 spdy_settings_flags_to_set_ = SETTINGS_FLAG_PLEASE_PERSIST; |
| 197 SETTINGS_MAX_CONCURRENT_STREAMS); | 197 spdy_settings_value_to_set_ = 1; |
| 198 spdy_settings_to_set_.push_back( | |
| 199 SpdySetting(id, max_concurrent_streams)); | |
| 200 | 198 |
| 201 SettingsFlagsAndId id1(SETTINGS_FLAG_PERSISTED, | 199 SettingsFlagsAndId id1(SETTINGS_FLAG_PERSISTED, spdy_settings_id_to_set_); |
| 202 SETTINGS_MAX_CONCURRENT_STREAMS); | |
| 203 spdy_settings_to_send_.push_back( | 200 spdy_settings_to_send_.push_back( |
| 204 SpdySetting(id1, max_concurrent_streams)); | 201 SpdySetting(id1, spdy_settings_value_to_set_)); |
| 205 } | 202 } |
| 206 | 203 |
| 207 virtual void TearDown() { | 204 virtual void TearDown() { |
| 208 MessageLoop::current()->RunAllPending(); | 205 MessageLoop::current()->RunAllPending(); |
| 209 } | 206 } |
| 210 | 207 |
| 211 void Prepare(SpdyStreamId stream_id) { | 208 void Prepare(SpdyStreamId stream_id) { |
| 212 stream_id_ = stream_id; | 209 stream_id_ = stream_id; |
| 213 | 210 |
| 214 const char* const request_headers[] = { | 211 const char* const request_headers[] = { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 MockWrite* writes, size_t writes_count, | 249 MockWrite* writes, size_t writes_count, |
| 253 bool throttling) { | 250 bool throttling) { |
| 254 data_.reset(new OrderedSocketData(reads, reads_count, | 251 data_.reset(new OrderedSocketData(reads, reads_count, |
| 255 writes, writes_count)); | 252 writes, writes_count)); |
| 256 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); | 253 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); |
| 257 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 254 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 258 SpdySessionPool* spdy_session_pool(http_session_->spdy_session_pool()); | 255 SpdySessionPool* spdy_session_pool(http_session_->spdy_session_pool()); |
| 259 | 256 |
| 260 if (throttling) { | 257 if (throttling) { |
| 261 // Set max concurrent streams to 1. | 258 // Set max concurrent streams to 1. |
| 262 spdy_session_pool->http_server_properties()->SetSpdySettings( | 259 spdy_session_pool->http_server_properties()->SetSpdySetting( |
| 263 host_port_pair_, spdy_settings_to_set_); | 260 host_port_pair_, |
| 261 spdy_settings_id_to_set_, |
| 262 spdy_settings_flags_to_set_, |
| 263 spdy_settings_value_to_set_); |
| 264 } | 264 } |
| 265 | 265 |
| 266 EXPECT_FALSE(spdy_session_pool->HasSession(host_port_proxy_pair_)); | 266 EXPECT_FALSE(spdy_session_pool->HasSession(host_port_proxy_pair_)); |
| 267 session_ = spdy_session_pool->Get(host_port_proxy_pair_, BoundNetLog()); | 267 session_ = spdy_session_pool->Get(host_port_proxy_pair_, BoundNetLog()); |
| 268 EXPECT_TRUE(spdy_session_pool->HasSession(host_port_proxy_pair_)); | 268 EXPECT_TRUE(spdy_session_pool->HasSession(host_port_proxy_pair_)); |
| 269 transport_params_ = new TransportSocketParams(host_port_pair_, MEDIUM, | 269 transport_params_ = new TransportSocketParams(host_port_pair_, MEDIUM, |
| 270 false, false); | 270 false, false); |
| 271 TestCompletionCallback callback; | 271 TestCompletionCallback callback; |
| 272 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 272 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
| 273 EXPECT_EQ(ERR_IO_PENDING, | 273 EXPECT_EQ(ERR_IO_PENDING, |
| 274 connection->Init(host_port_pair_.ToString(), transport_params_, | 274 connection->Init(host_port_pair_.ToString(), transport_params_, |
| 275 MEDIUM, callback.callback(), | 275 MEDIUM, callback.callback(), |
| 276 http_session_->GetTransportSocketPool( | 276 http_session_->GetTransportSocketPool( |
| 277 HttpNetworkSession::NORMAL_SOCKET_POOL), | 277 HttpNetworkSession::NORMAL_SOCKET_POOL), |
| 278 BoundNetLog())); | 278 BoundNetLog())); |
| 279 EXPECT_EQ(OK, callback.WaitForResult()); | 279 EXPECT_EQ(OK, callback.WaitForResult()); |
| 280 return session_->InitializeWithSocket(connection.release(), false, OK); | 280 return session_->InitializeWithSocket(connection.release(), false, OK); |
| 281 } | 281 } |
| 282 void SendRequest() { | 282 void SendRequest() { |
| 283 linked_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | 283 linked_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); |
| 284 (*headers)["url"] = "ws://example.com/echo"; | 284 (*headers)["url"] = "ws://example.com/echo"; |
| 285 (*headers)["origin"] = "http://example.com/wsdemo"; | 285 (*headers)["origin"] = "http://example.com/wsdemo"; |
| 286 | 286 |
| 287 websocket_stream_->SendRequest(headers); | 287 websocket_stream_->SendRequest(headers); |
| 288 } | 288 } |
| 289 | 289 |
| 290 SpdySettings spdy_settings_to_set_; | 290 SpdySettingsIds spdy_settings_id_to_set_; |
| 291 SpdySettingsFlags spdy_settings_flags_to_set_; |
| 292 uint32 spdy_settings_value_to_set_; |
| 291 SpdySettings spdy_settings_to_send_; | 293 SpdySettings spdy_settings_to_send_; |
| 292 SpdySessionDependencies session_deps_; | 294 SpdySessionDependencies session_deps_; |
| 293 scoped_ptr<OrderedSocketData> data_; | 295 scoped_ptr<OrderedSocketData> data_; |
| 294 scoped_refptr<HttpNetworkSession> http_session_; | 296 scoped_refptr<HttpNetworkSession> http_session_; |
| 295 scoped_refptr<SpdySession> session_; | 297 scoped_refptr<SpdySession> session_; |
| 296 scoped_refptr<TransportSocketParams> transport_params_; | 298 scoped_refptr<TransportSocketParams> transport_params_; |
| 297 scoped_ptr<SpdyWebSocketStream> websocket_stream_; | 299 scoped_ptr<SpdyWebSocketStream> websocket_stream_; |
| 298 SpdyStreamId stream_id_; | 300 SpdyStreamId stream_id_; |
| 299 scoped_ptr<SpdyFrame> request_frame_; | 301 scoped_ptr<SpdyFrame> request_frame_; |
| 300 scoped_ptr<SpdyFrame> response_frame_; | 302 scoped_ptr<SpdyFrame> response_frame_; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 EXPECT_EQ(OK, events[7].result); | 618 EXPECT_EQ(OK, events[7].result); |
| 617 | 619 |
| 618 // EOF close SPDY session. | 620 // EOF close SPDY session. |
| 619 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession( | 621 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession( |
| 620 host_port_proxy_pair_)); | 622 host_port_proxy_pair_)); |
| 621 EXPECT_TRUE(data()->at_read_eof()); | 623 EXPECT_TRUE(data()->at_read_eof()); |
| 622 EXPECT_TRUE(data()->at_write_eof()); | 624 EXPECT_TRUE(data()->at_write_eof()); |
| 623 } | 625 } |
| 624 | 626 |
| 625 } // namespace net | 627 } // namespace net |
| OLD | NEW |