| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 StreamEventCallback on_sent_data_; | 152 StreamEventCallback on_sent_data_; |
| 153 StreamEventCallback on_received_data_; | 153 StreamEventCallback on_received_data_; |
| 154 StreamEventCallback on_close_; | 154 StreamEventCallback on_close_; |
| 155 CompletionCallback callback_; | 155 CompletionCallback callback_; |
| 156 | 156 |
| 157 DISALLOW_COPY_AND_ASSIGN(SpdyWebSocketStreamEventRecorder); | 157 DISALLOW_COPY_AND_ASSIGN(SpdyWebSocketStreamEventRecorder); |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 class SpdyWebSocketStreamTest : public testing::Test { | 160 class SpdyWebSocketStreamTest : public testing::Test { |
| 161 public: | 161 public: |
| 162 OrderedSocketData* data() { return data_; } | 162 OrderedSocketData* data() { return data_.get(); } |
| 163 | 163 |
| 164 void DoSendHelloFrame(SpdyWebSocketStreamEvent* event) { | 164 void DoSendHelloFrame(SpdyWebSocketStreamEvent* event) { |
| 165 websocket_stream_->SendData(kMessageFrame, kMessageFrameLength); | 165 websocket_stream_->SendData(kMessageFrame, kMessageFrameLength); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void DoSendClosingFrame(SpdyWebSocketStreamEvent* event) { | 168 void DoSendClosingFrame(SpdyWebSocketStreamEvent* event) { |
| 169 websocket_stream_->SendData(kClosingFrame, kClosingFrameLength); | 169 websocket_stream_->SendData(kClosingFrame, kClosingFrameLength); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void DoClose(SpdyWebSocketStreamEvent* event) { | 172 void DoClose(SpdyWebSocketStreamEvent* event) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 closing_frame_.reset(ConstructSpdyWebSocketDataFrame( | 246 closing_frame_.reset(ConstructSpdyWebSocketDataFrame( |
| 247 kClosingFrame, | 247 kClosingFrame, |
| 248 kClosingFrameLength, | 248 kClosingFrameLength, |
| 249 stream_id_, | 249 stream_id_, |
| 250 false)); | 250 false)); |
| 251 } | 251 } |
| 252 int InitSession(MockRead* reads, size_t reads_count, | 252 int InitSession(MockRead* reads, size_t reads_count, |
| 253 MockWrite* writes, size_t writes_count, | 253 MockWrite* writes, size_t writes_count, |
| 254 bool throttling) { | 254 bool throttling) { |
| 255 data_ = new OrderedSocketData(reads, reads_count, writes, writes_count); | 255 data_.reset(new OrderedSocketData(reads, reads_count, |
| 256 writes, writes_count)); |
| 256 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); | 257 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); |
| 257 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 258 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 258 SpdySessionPool* spdy_session_pool(http_session_->spdy_session_pool()); | 259 SpdySessionPool* spdy_session_pool(http_session_->spdy_session_pool()); |
| 259 | 260 |
| 260 if (throttling) { | 261 if (throttling) { |
| 261 // Set max concurrent streams to 1. | 262 // Set max concurrent streams to 1. |
| 262 spdy_session_pool->http_server_properties()->SetSpdySettings( | 263 spdy_session_pool->http_server_properties()->SetSpdySettings( |
| 263 host_port_pair_, spdy_settings_to_set_); | 264 host_port_pair_, spdy_settings_to_set_); |
| 264 } | 265 } |
| 265 | 266 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 282 linked_ptr<spdy::SpdyHeaderBlock> headers(new spdy::SpdyHeaderBlock); | 283 linked_ptr<spdy::SpdyHeaderBlock> headers(new spdy::SpdyHeaderBlock); |
| 283 (*headers)["url"] = "ws://example.com/echo"; | 284 (*headers)["url"] = "ws://example.com/echo"; |
| 284 (*headers)["origin"] = "http://example.com/wsdemo"; | 285 (*headers)["origin"] = "http://example.com/wsdemo"; |
| 285 | 286 |
| 286 websocket_stream_->SendRequest(headers); | 287 websocket_stream_->SendRequest(headers); |
| 287 } | 288 } |
| 288 | 289 |
| 289 spdy::SpdySettings spdy_settings_to_set_; | 290 spdy::SpdySettings spdy_settings_to_set_; |
| 290 spdy::SpdySettings spdy_settings_to_send_; | 291 spdy::SpdySettings spdy_settings_to_send_; |
| 291 SpdySessionDependencies session_deps_; | 292 SpdySessionDependencies session_deps_; |
| 292 scoped_refptr<OrderedSocketData> data_; | 293 scoped_ptr<OrderedSocketData> data_; |
| 293 scoped_refptr<HttpNetworkSession> http_session_; | 294 scoped_refptr<HttpNetworkSession> http_session_; |
| 294 scoped_refptr<SpdySession> session_; | 295 scoped_refptr<SpdySession> session_; |
| 295 scoped_refptr<TransportSocketParams> transport_params_; | 296 scoped_refptr<TransportSocketParams> transport_params_; |
| 296 scoped_ptr<SpdyWebSocketStream> websocket_stream_; | 297 scoped_ptr<SpdyWebSocketStream> websocket_stream_; |
| 297 spdy::SpdyStreamId stream_id_; | 298 spdy::SpdyStreamId stream_id_; |
| 298 scoped_ptr<spdy::SpdyFrame> request_frame_; | 299 scoped_ptr<spdy::SpdyFrame> request_frame_; |
| 299 scoped_ptr<spdy::SpdyFrame> response_frame_; | 300 scoped_ptr<spdy::SpdyFrame> response_frame_; |
| 300 scoped_ptr<spdy::SpdyFrame> message_frame_; | 301 scoped_ptr<spdy::SpdyFrame> message_frame_; |
| 301 scoped_ptr<spdy::SpdyFrame> closing_frame_; | 302 scoped_ptr<spdy::SpdyFrame> closing_frame_; |
| 302 HostPortPair host_port_pair_; | 303 HostPortPair host_port_pair_; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 EXPECT_EQ(OK, events[7].result); | 610 EXPECT_EQ(OK, events[7].result); |
| 610 | 611 |
| 611 // EOF close SPDY session. | 612 // EOF close SPDY session. |
| 612 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession( | 613 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession( |
| 613 host_port_proxy_pair_)); | 614 host_port_proxy_pair_)); |
| 614 EXPECT_TRUE(data()->at_read_eof()); | 615 EXPECT_TRUE(data()->at_read_eof()); |
| 615 EXPECT_TRUE(data()->at_write_eof()); | 616 EXPECT_TRUE(data()->at_write_eof()); |
| 616 } | 617 } |
| 617 | 618 |
| 618 } // namespace net | 619 } // namespace net |
| OLD | NEW |