Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(881)

Side by Side Diff: net/spdy/spdy_websocket_stream_spdy3_unittest.cc

Issue 9802003: SPDY - persist SPDY settings. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 virtual void SetUp() { 191 virtual void SetUp() {
192 EnableCompression(false); 192 EnableCompression(false);
193 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3); 193 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY3);
194 194
195 host_port_pair_.set_host("example.com"); 195 host_port_pair_.set_host("example.com");
196 host_port_pair_.set_port(80); 196 host_port_pair_.set_port(80);
197 host_port_proxy_pair_.first = host_port_pair_; 197 host_port_proxy_pair_.first = host_port_pair_;
198 host_port_proxy_pair_.second = ProxyServer::Direct(); 198 host_port_proxy_pair_.second = ProxyServer::Direct();
199 199
200 const size_t max_concurrent_streams = 1; 200 const size_t max_concurrent_streams = 1;
201 spdy::SettingsFlagsAndId id(spdy::SETTINGS_FLAG_PLEASE_PERSIST, 201 spdy_settings_id_to_set_ = spdy::SETTINGS_MAX_CONCURRENT_STREAMS;
202 spdy::SETTINGS_MAX_CONCURRENT_STREAMS); 202 spdy_settings_flags_and_value_to_set_ = std::make_pair(
203 spdy_settings_to_set_.push_back( 203 spdy::SETTINGS_FLAG_PLEASE_PERSIST, max_concurrent_streams);
204 spdy::SpdySetting(id, max_concurrent_streams));
205 204
206 spdy::SettingsFlagsAndId id1(spdy::SETTINGS_FLAG_PERSISTED, 205 spdy::SettingsFlagsAndId id1(spdy::SETTINGS_FLAG_PERSISTED,
207 spdy::SETTINGS_MAX_CONCURRENT_STREAMS); 206 spdy::SETTINGS_MAX_CONCURRENT_STREAMS);
208 spdy_settings_to_send_.push_back( 207 spdy_settings_to_send_.push_back(
209 spdy::SpdySetting(id1, max_concurrent_streams)); 208 spdy::SpdySetting(id1, max_concurrent_streams));
210 } 209 }
211 210
212 virtual void TearDown() { 211 virtual void TearDown() {
213 MessageLoop::current()->RunAllPending(); 212 MessageLoop::current()->RunAllPending();
214 } 213 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 MockWrite* writes, size_t writes_count, 259 MockWrite* writes, size_t writes_count,
261 bool throttling) { 260 bool throttling) {
262 data_.reset(new OrderedSocketData(reads, reads_count, 261 data_.reset(new OrderedSocketData(reads, reads_count,
263 writes, writes_count)); 262 writes, writes_count));
264 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); 263 session_deps_.socket_factory->AddSocketDataProvider(data_.get());
265 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 264 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
266 SpdySessionPool* spdy_session_pool(http_session_->spdy_session_pool()); 265 SpdySessionPool* spdy_session_pool(http_session_->spdy_session_pool());
267 266
268 if (throttling) { 267 if (throttling) {
269 // Set max concurrent streams to 1. 268 // Set max concurrent streams to 1.
270 spdy_session_pool->http_server_properties()->SetSpdySettings( 269 spdy_session_pool->http_server_properties()->SetSpdySetting(
271 host_port_pair_, spdy_settings_to_set_); 270 host_port_pair_,
271 spdy_settings_id_to_set_,
272 spdy_settings_flags_and_value_to_set_);
272 } 273 }
273 274
274 EXPECT_FALSE(spdy_session_pool->HasSession(host_port_proxy_pair_)); 275 EXPECT_FALSE(spdy_session_pool->HasSession(host_port_proxy_pair_));
275 session_ = spdy_session_pool->Get(host_port_proxy_pair_, BoundNetLog()); 276 session_ = spdy_session_pool->Get(host_port_proxy_pair_, BoundNetLog());
276 EXPECT_TRUE(spdy_session_pool->HasSession(host_port_proxy_pair_)); 277 EXPECT_TRUE(spdy_session_pool->HasSession(host_port_proxy_pair_));
277 transport_params_ = new TransportSocketParams(host_port_pair_, MEDIUM, 278 transport_params_ = new TransportSocketParams(host_port_pair_, MEDIUM,
278 false, false); 279 false, false);
279 TestCompletionCallback callback; 280 TestCompletionCallback callback;
280 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 281 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
281 EXPECT_EQ(ERR_IO_PENDING, 282 EXPECT_EQ(ERR_IO_PENDING,
282 connection->Init(host_port_pair_.ToString(), transport_params_, 283 connection->Init(host_port_pair_.ToString(), transport_params_,
283 MEDIUM, callback.callback(), 284 MEDIUM, callback.callback(),
284 http_session_->GetTransportSocketPool( 285 http_session_->GetTransportSocketPool(
285 HttpNetworkSession::NORMAL_SOCKET_POOL), 286 HttpNetworkSession::NORMAL_SOCKET_POOL),
286 BoundNetLog())); 287 BoundNetLog()));
287 EXPECT_EQ(OK, callback.WaitForResult()); 288 EXPECT_EQ(OK, callback.WaitForResult());
288 return session_->InitializeWithSocket(connection.release(), false, OK); 289 return session_->InitializeWithSocket(connection.release(), false, OK);
289 } 290 }
290 void SendRequest() { 291 void SendRequest() {
291 linked_ptr<spdy::SpdyHeaderBlock> headers(new spdy::SpdyHeaderBlock); 292 linked_ptr<spdy::SpdyHeaderBlock> headers(new spdy::SpdyHeaderBlock);
292 (*headers)["url"] = "ws://example.com/echo"; 293 (*headers)["url"] = "ws://example.com/echo";
293 (*headers)["origin"] = "http://example.com/wsdemo"; 294 (*headers)["origin"] = "http://example.com/wsdemo";
294 295
295 websocket_stream_->SendRequest(headers); 296 websocket_stream_->SendRequest(headers);
296 } 297 }
297 298
298 spdy::SpdySettings spdy_settings_to_set_; 299 uint32 spdy_settings_id_to_set_;
300 spdy::SettingsFlagsAndValue spdy_settings_flags_and_value_to_set_;
299 spdy::SpdySettings spdy_settings_to_send_; 301 spdy::SpdySettings spdy_settings_to_send_;
300 SpdySessionDependencies session_deps_; 302 SpdySessionDependencies session_deps_;
301 scoped_ptr<OrderedSocketData> data_; 303 scoped_ptr<OrderedSocketData> data_;
302 scoped_refptr<HttpNetworkSession> http_session_; 304 scoped_refptr<HttpNetworkSession> http_session_;
303 scoped_refptr<SpdySession> session_; 305 scoped_refptr<SpdySession> session_;
304 scoped_refptr<TransportSocketParams> transport_params_; 306 scoped_refptr<TransportSocketParams> transport_params_;
305 scoped_ptr<SpdyWebSocketStream> websocket_stream_; 307 scoped_ptr<SpdyWebSocketStream> websocket_stream_;
306 spdy::SpdyStreamId stream_id_; 308 spdy::SpdyStreamId stream_id_;
307 scoped_ptr<spdy::SpdyFrame> request_frame_; 309 scoped_ptr<spdy::SpdyFrame> request_frame_;
308 scoped_ptr<spdy::SpdyFrame> response_frame_; 310 scoped_ptr<spdy::SpdyFrame> response_frame_;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 EXPECT_EQ(OK, events[7].result); 623 EXPECT_EQ(OK, events[7].result);
622 624
623 // EOF close SPDY session. 625 // EOF close SPDY session.
624 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession( 626 EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession(
625 host_port_proxy_pair_)); 627 host_port_proxy_pair_));
626 EXPECT_TRUE(data()->at_read_eof()); 628 EXPECT_TRUE(data()->at_read_eof());
627 EXPECT_TRUE(data()->at_write_eof()); 629 EXPECT_TRUE(data()->at_write_eof());
628 } 630 }
629 631
630 } // namespace net 632 } // namespace net
OLDNEW
« net/spdy/spdy_session.cc ('K') | « net/spdy/spdy_websocket_stream_spdy2_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698