Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/websockets/websocket_job.h" | 5 #include "net/websockets/websocket_job.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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 } | 267 } |
| 268 | 268 |
| 269 virtual ~MockURLRequestContext() {} | 269 virtual ~MockURLRequestContext() {} |
| 270 | 270 |
| 271 private: | 271 private: |
| 272 TransportSecurityState transport_security_state_; | 272 TransportSecurityState transport_security_state_; |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 class MockHttpTransactionFactory : public HttpTransactionFactory { | 275 class MockHttpTransactionFactory : public HttpTransactionFactory { |
| 276 public: | 276 public: |
| 277 MockHttpTransactionFactory(NextProto next_proto, OrderedSocketData* data) { | 277 MockHttpTransactionFactory(NextProto next_proto, OrderedSocketData* data, |
|
Ryan Hamilton
2014/05/29 19:26:50
nit: 1 per line, since it no longer fits on one li
mmenke
2014/05/29 19:54:16
Did this one, too, just forgot to response.
| |
| 278 bool enable_websocket_over_spdy) { | |
| 278 data_ = data; | 279 data_ = data; |
| 279 MockConnect connect_data(SYNCHRONOUS, OK); | 280 MockConnect connect_data(SYNCHRONOUS, OK); |
| 280 data_->set_connect_data(connect_data); | 281 data_->set_connect_data(connect_data); |
| 281 session_deps_.reset(new SpdySessionDependencies(next_proto)); | 282 session_deps_.reset(new SpdySessionDependencies(next_proto)); |
| 283 session_deps_->enable_websocket_over_spdy = enable_websocket_over_spdy; | |
| 282 session_deps_->socket_factory->AddSocketDataProvider(data_); | 284 session_deps_->socket_factory->AddSocketDataProvider(data_); |
| 283 http_session_ = | 285 http_session_ = |
| 284 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); | 286 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); |
| 285 host_port_pair_.set_host("example.com"); | 287 host_port_pair_.set_host("example.com"); |
| 286 host_port_pair_.set_port(80); | 288 host_port_pair_.set_port(80); |
| 287 spdy_session_key_ = SpdySessionKey(host_port_pair_, | 289 spdy_session_key_ = SpdySessionKey(host_port_pair_, |
| 288 ProxyServer::Direct(), | 290 ProxyServer::Direct(), |
| 289 PRIVACY_MODE_DISABLED); | 291 PRIVACY_MODE_DISABLED); |
| 290 session_ = CreateInsecureSpdySession( | 292 session_ = CreateInsecureSpdySession( |
| 291 http_session_, spdy_session_key_, BoundNetLog()); | 293 http_session_, spdy_session_key_, BoundNetLog()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 private: | 384 private: |
| 383 scoped_refptr<WebSocketJob> job_; | 385 scoped_refptr<WebSocketJob> job_; |
| 384 bool delete_next_; | 386 bool delete_next_; |
| 385 }; | 387 }; |
| 386 | 388 |
| 387 } // namespace | 389 } // namespace |
| 388 | 390 |
| 389 class WebSocketJobTest : public PlatformTest, | 391 class WebSocketJobTest : public PlatformTest, |
| 390 public ::testing::WithParamInterface<NextProto> { | 392 public ::testing::WithParamInterface<NextProto> { |
| 391 public: | 393 public: |
| 392 WebSocketJobTest() : spdy_util_(GetParam()) {} | 394 WebSocketJobTest() : spdy_util_(GetParam()), |
|
Ryan Hamilton
2014/05/29 19:26:50
I think you need to start the initalizer list on a
mmenke
2014/05/29 19:53:13
Done. Looks like you're right. Rule is often vio
| |
| 395 enable_websocket_over_spdy_(false) {} | |
| 393 | 396 |
| 394 virtual void SetUp() OVERRIDE { | 397 virtual void SetUp() OVERRIDE { |
| 395 stream_type_ = STREAM_INVALID; | 398 stream_type_ = STREAM_INVALID; |
| 396 cookie_store_ = new MockCookieStore; | 399 cookie_store_ = new MockCookieStore; |
| 397 context_.reset(new MockURLRequestContext(cookie_store_.get())); | 400 context_.reset(new MockURLRequestContext(cookie_store_.get())); |
| 398 } | 401 } |
| 399 virtual void TearDown() OVERRIDE { | 402 virtual void TearDown() OVERRIDE { |
| 400 cookie_store_ = NULL; | 403 cookie_store_ = NULL; |
| 401 context_.reset(); | 404 context_.reset(); |
| 402 websocket_ = NULL; | 405 websocket_ = NULL; |
| 403 socket_ = NULL; | 406 socket_ = NULL; |
| 404 } | 407 } |
| 405 void DoSendRequest() { | 408 void DoSendRequest() { |
| 406 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie, | 409 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie, |
| 407 kHandshakeRequestWithoutCookieLength)); | 410 kHandshakeRequestWithoutCookieLength)); |
| 408 } | 411 } |
| 409 void DoSendData() { | 412 void DoSendData() { |
| 410 if (received_data().size() == kHandshakeResponseWithoutCookieLength) | 413 if (received_data().size() == kHandshakeResponseWithoutCookieLength) |
| 411 websocket_->SendData(kDataHello, kDataHelloLength); | 414 websocket_->SendData(kDataHello, kDataHelloLength); |
| 412 } | 415 } |
| 413 void DoSync() { | 416 void DoSync() { |
| 414 sync_test_callback_.callback().Run(OK); | 417 sync_test_callback_.callback().Run(OK); |
| 415 } | 418 } |
| 416 int WaitForResult() { | 419 int WaitForResult() { |
| 417 return sync_test_callback_.WaitForResult(); | 420 return sync_test_callback_.WaitForResult(); |
| 418 } | 421 } |
| 422 | |
| 419 protected: | 423 protected: |
| 420 enum StreamType { | 424 enum StreamType { |
| 421 STREAM_INVALID, | 425 STREAM_INVALID, |
| 422 STREAM_MOCK_SOCKET, | 426 STREAM_MOCK_SOCKET, |
| 423 STREAM_SOCKET, | 427 STREAM_SOCKET, |
| 424 STREAM_SPDY_WEBSOCKET, | 428 STREAM_SPDY_WEBSOCKET, |
| 425 }; | 429 }; |
| 426 enum ThrottlingOption { | 430 enum ThrottlingOption { |
| 427 THROTTLING_OFF, | 431 THROTTLING_OFF, |
| 428 THROTTLING_ON, | 432 THROTTLING_ON, |
| 429 }; | 433 }; |
| 430 enum SpdyOption { | 434 enum SpdyOption { |
| 431 SPDY_OFF, | 435 SPDY_OFF, |
| 432 SPDY_ON, | 436 SPDY_ON, |
| 433 }; | 437 }; |
| 434 void InitWebSocketJob(const GURL& url, | 438 void InitWebSocketJob(const GURL& url, |
| 435 MockSocketStreamDelegate* delegate, | 439 MockSocketStreamDelegate* delegate, |
| 436 StreamType stream_type) { | 440 StreamType stream_type) { |
| 437 DCHECK_NE(STREAM_INVALID, stream_type); | 441 DCHECK_NE(STREAM_INVALID, stream_type); |
| 438 stream_type_ = stream_type; | 442 stream_type_ = stream_type; |
| 439 websocket_ = new WebSocketJob(delegate); | 443 websocket_ = new WebSocketJob(delegate); |
| 440 | 444 |
| 441 if (stream_type == STREAM_MOCK_SOCKET) | 445 if (stream_type == STREAM_MOCK_SOCKET) |
| 442 socket_ = new MockSocketStream(url, websocket_.get(), context_.get(), | 446 socket_ = new MockSocketStream(url, websocket_.get(), context_.get(), |
| 443 NULL); | 447 NULL); |
| 444 | 448 |
| 445 if (stream_type == STREAM_SOCKET || stream_type == STREAM_SPDY_WEBSOCKET) { | 449 if (stream_type == STREAM_SOCKET || stream_type == STREAM_SPDY_WEBSOCKET) { |
| 446 if (stream_type == STREAM_SPDY_WEBSOCKET) { | 450 if (stream_type == STREAM_SPDY_WEBSOCKET) { |
| 447 http_factory_.reset( | 451 http_factory_.reset(new MockHttpTransactionFactory( |
| 448 new MockHttpTransactionFactory(GetParam(), data_.get())); | 452 GetParam(), data_.get(), enable_websocket_over_spdy_)); |
| 449 context_->set_http_transaction_factory(http_factory_.get()); | 453 context_->set_http_transaction_factory(http_factory_.get()); |
| 450 } | 454 } |
| 451 | 455 |
| 452 ssl_config_service_ = new MockSSLConfigService(); | 456 ssl_config_service_ = new MockSSLConfigService(); |
| 453 context_->set_ssl_config_service(ssl_config_service_.get()); | 457 context_->set_ssl_config_service(ssl_config_service_.get()); |
| 454 proxy_service_.reset(ProxyService::CreateDirect()); | 458 proxy_service_.reset(ProxyService::CreateDirect()); |
| 455 context_->set_proxy_service(proxy_service_.get()); | 459 context_->set_proxy_service(proxy_service_.get()); |
| 456 host_resolver_.reset(new MockHostResolver); | 460 host_resolver_.reset(new MockHostResolver); |
| 457 context_->set_host_resolver(host_resolver_.get()); | 461 context_->set_host_resolver(host_resolver_.get()); |
| 458 | 462 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 scoped_refptr<WebSocketJob> websocket_; | 527 scoped_refptr<WebSocketJob> websocket_; |
| 524 scoped_refptr<SocketStream> socket_; | 528 scoped_refptr<SocketStream> socket_; |
| 525 scoped_ptr<MockClientSocketFactory> socket_factory_; | 529 scoped_ptr<MockClientSocketFactory> socket_factory_; |
| 526 scoped_ptr<OrderedSocketData> data_; | 530 scoped_ptr<OrderedSocketData> data_; |
| 527 TestCompletionCallback sync_test_callback_; | 531 TestCompletionCallback sync_test_callback_; |
| 528 scoped_refptr<MockSSLConfigService> ssl_config_service_; | 532 scoped_refptr<MockSSLConfigService> ssl_config_service_; |
| 529 scoped_ptr<ProxyService> proxy_service_; | 533 scoped_ptr<ProxyService> proxy_service_; |
| 530 scoped_ptr<MockHostResolver> host_resolver_; | 534 scoped_ptr<MockHostResolver> host_resolver_; |
| 531 scoped_ptr<MockHttpTransactionFactory> http_factory_; | 535 scoped_ptr<MockHttpTransactionFactory> http_factory_; |
| 532 | 536 |
| 537 // Must be set before call to enable_websocket_over_spdy, defaults to false. | |
| 538 bool enable_websocket_over_spdy_; | |
| 539 | |
| 533 static const char kHandshakeRequestWithoutCookie[]; | 540 static const char kHandshakeRequestWithoutCookie[]; |
| 534 static const char kHandshakeRequestWithCookie[]; | 541 static const char kHandshakeRequestWithCookie[]; |
| 535 static const char kHandshakeRequestWithFilteredCookie[]; | 542 static const char kHandshakeRequestWithFilteredCookie[]; |
| 536 static const char kHandshakeResponseWithoutCookie[]; | 543 static const char kHandshakeResponseWithoutCookie[]; |
| 537 static const char kHandshakeResponseWithCookie[]; | 544 static const char kHandshakeResponseWithCookie[]; |
| 538 static const char kDataHello[]; | 545 static const char kDataHello[]; |
| 539 static const char kDataWorld[]; | 546 static const char kDataWorld[]; |
| 540 static const char* const kHandshakeRequestForSpdy[]; | 547 static const char* const kHandshakeRequestForSpdy[]; |
| 541 static const char* const kHandshakeResponseForSpdy[]; | 548 static const char* const kHandshakeResponseForSpdy[]; |
| 542 static const size_t kHandshakeRequestWithoutCookieLength; | 549 static const size_t kHandshakeRequestWithoutCookieLength; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 CloseWebSocketJob(); | 711 CloseWebSocketJob(); |
| 705 } | 712 } |
| 706 | 713 |
| 707 INSTANTIATE_TEST_CASE_P( | 714 INSTANTIATE_TEST_CASE_P( |
| 708 NextProto, | 715 NextProto, |
| 709 WebSocketJobTest, | 716 WebSocketJobTest, |
| 710 testing::Values(kProtoDeprecatedSPDY2, | 717 testing::Values(kProtoDeprecatedSPDY2, |
| 711 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); | 718 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); |
| 712 | 719 |
| 713 TEST_P(WebSocketJobTest, DelayedCookies) { | 720 TEST_P(WebSocketJobTest, DelayedCookies) { |
| 714 WebSocketJob::set_websocket_over_spdy_enabled(true); | 721 enable_websocket_over_spdy_ = true; |
| 715 GURL url("ws://example.com/demo"); | 722 GURL url("ws://example.com/demo"); |
| 716 GURL cookieUrl("http://example.com/demo"); | 723 GURL cookieUrl("http://example.com/demo"); |
| 717 CookieOptions cookie_options; | 724 CookieOptions cookie_options; |
| 718 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); | 725 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); |
| 719 context_->set_cookie_store(cookie_store.get()); | 726 context_->set_cookie_store(cookie_store.get()); |
| 720 cookie_store->SetCookieWithOptionsAsync(cookieUrl, | 727 cookie_store->SetCookieWithOptionsAsync(cookieUrl, |
| 721 "CR-test=1", | 728 "CR-test=1", |
| 722 cookie_options, | 729 cookie_options, |
| 723 CookieMonster::SetCookiesCallback()); | 730 CookieMonster::SetCookiesCallback()); |
| 724 cookie_options.set_include_httponly(); | 731 cookie_options.set_include_httponly(); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1107 iter != jobs.rend(); | 1114 iter != jobs.rend(); |
| 1108 ++iter) { | 1115 ++iter) { |
| 1109 WebSocketJob* job = (*iter).get(); | 1116 WebSocketJob* job = (*iter).get(); |
| 1110 job->state_ = WebSocketJob::CLOSED; | 1117 job->state_ = WebSocketJob::CLOSED; |
| 1111 WebSocketThrottle::GetInstance()->RemoveFromQueue(job); | 1118 WebSocketThrottle::GetInstance()->RemoveFromQueue(job); |
| 1112 } | 1119 } |
| 1113 } | 1120 } |
| 1114 | 1121 |
| 1115 // Execute tests in both spdy-disabled mode and spdy-enabled mode. | 1122 // Execute tests in both spdy-disabled mode and spdy-enabled mode. |
| 1116 TEST_P(WebSocketJobTest, SimpleHandshake) { | 1123 TEST_P(WebSocketJobTest, SimpleHandshake) { |
| 1117 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1118 TestSimpleHandshake(); | 1124 TestSimpleHandshake(); |
| 1119 } | 1125 } |
| 1120 | 1126 |
| 1121 TEST_P(WebSocketJobTest, SlowHandshake) { | 1127 TEST_P(WebSocketJobTest, SlowHandshake) { |
| 1122 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1123 TestSlowHandshake(); | 1128 TestSlowHandshake(); |
| 1124 } | 1129 } |
| 1125 | 1130 |
| 1126 TEST_P(WebSocketJobTest, HandshakeWithCookie) { | 1131 TEST_P(WebSocketJobTest, HandshakeWithCookie) { |
| 1127 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1128 TestHandshakeWithCookie(); | 1132 TestHandshakeWithCookie(); |
| 1129 } | 1133 } |
| 1130 | 1134 |
| 1131 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowed) { | 1135 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowed) { |
| 1132 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1133 TestHandshakeWithCookieButNotAllowed(); | 1136 TestHandshakeWithCookieButNotAllowed(); |
| 1134 } | 1137 } |
| 1135 | 1138 |
| 1136 TEST_P(WebSocketJobTest, HSTSUpgrade) { | 1139 TEST_P(WebSocketJobTest, HSTSUpgrade) { |
| 1137 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1138 TestHSTSUpgrade(); | 1140 TestHSTSUpgrade(); |
| 1139 } | 1141 } |
| 1140 | 1142 |
| 1141 TEST_P(WebSocketJobTest, InvalidSendData) { | 1143 TEST_P(WebSocketJobTest, InvalidSendData) { |
| 1142 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1143 TestInvalidSendData(); | 1144 TestInvalidSendData(); |
| 1144 } | 1145 } |
| 1145 | 1146 |
| 1146 TEST_P(WebSocketJobTest, SimpleHandshakeSpdyEnabled) { | 1147 TEST_P(WebSocketJobTest, SimpleHandshakeSpdyEnabled) { |
| 1147 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1148 enable_websocket_over_spdy_ = true; |
| 1148 TestSimpleHandshake(); | 1149 TestSimpleHandshake(); |
| 1149 } | 1150 } |
| 1150 | 1151 |
| 1151 TEST_P(WebSocketJobTest, SlowHandshakeSpdyEnabled) { | 1152 TEST_P(WebSocketJobTest, SlowHandshakeSpdyEnabled) { |
| 1152 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1153 enable_websocket_over_spdy_ = true; |
| 1153 TestSlowHandshake(); | 1154 TestSlowHandshake(); |
| 1154 } | 1155 } |
| 1155 | 1156 |
| 1156 TEST_P(WebSocketJobTest, HandshakeWithCookieSpdyEnabled) { | 1157 TEST_P(WebSocketJobTest, HandshakeWithCookieSpdyEnabled) { |
| 1157 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1158 enable_websocket_over_spdy_ = true; |
| 1158 TestHandshakeWithCookie(); | 1159 TestHandshakeWithCookie(); |
| 1159 } | 1160 } |
| 1160 | 1161 |
| 1161 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowedSpdyEnabled) { | 1162 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowedSpdyEnabled) { |
| 1162 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1163 enable_websocket_over_spdy_ = true; |
| 1163 TestHandshakeWithCookieButNotAllowed(); | 1164 TestHandshakeWithCookieButNotAllowed(); |
| 1164 } | 1165 } |
| 1165 | 1166 |
| 1166 TEST_P(WebSocketJobTest, HSTSUpgradeSpdyEnabled) { | 1167 TEST_P(WebSocketJobTest, HSTSUpgradeSpdyEnabled) { |
| 1167 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1168 enable_websocket_over_spdy_ = true; |
| 1168 TestHSTSUpgrade(); | 1169 TestHSTSUpgrade(); |
| 1169 } | 1170 } |
| 1170 | 1171 |
| 1171 TEST_P(WebSocketJobTest, InvalidSendDataSpdyEnabled) { | 1172 TEST_P(WebSocketJobTest, InvalidSendDataSpdyEnabled) { |
| 1172 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1173 enable_websocket_over_spdy_ = true; |
| 1173 TestInvalidSendData(); | 1174 TestInvalidSendData(); |
| 1174 } | 1175 } |
| 1175 | 1176 |
| 1176 TEST_P(WebSocketJobTest, ConnectByWebSocket) { | 1177 TEST_P(WebSocketJobTest, ConnectByWebSocket) { |
| 1177 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1178 enable_websocket_over_spdy_ = true; |
| 1178 TestConnectByWebSocket(THROTTLING_OFF); | 1179 TestConnectByWebSocket(THROTTLING_OFF); |
| 1179 } | 1180 } |
| 1180 | 1181 |
| 1181 TEST_P(WebSocketJobTest, ConnectByWebSocketSpdyEnabled) { | 1182 TEST_P(WebSocketJobTest, ConnectByWebSocketSpdyEnabled) { |
| 1182 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1183 enable_websocket_over_spdy_ = true; |
| 1183 TestConnectByWebSocket(THROTTLING_OFF); | 1184 TestConnectByWebSocket(THROTTLING_OFF); |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 TEST_P(WebSocketJobTest, ConnectBySpdy) { | 1187 TEST_P(WebSocketJobTest, ConnectBySpdy) { |
| 1187 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1188 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); | 1188 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); |
| 1189 } | 1189 } |
| 1190 | 1190 |
| 1191 TEST_P(WebSocketJobTest, ConnectBySpdySpdyEnabled) { | 1191 TEST_P(WebSocketJobTest, ConnectBySpdySpdyEnabled) { |
| 1192 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1192 enable_websocket_over_spdy_ = true; |
| 1193 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); | 1193 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 TEST_P(WebSocketJobTest, ThrottlingWebSocket) { | 1196 TEST_P(WebSocketJobTest, ThrottlingWebSocket) { |
| 1197 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1198 TestConnectByWebSocket(THROTTLING_ON); | 1197 TestConnectByWebSocket(THROTTLING_ON); |
| 1199 } | 1198 } |
| 1200 | 1199 |
| 1201 TEST_P(WebSocketJobTest, ThrottlingMaxNumberOfThrottledJobLimit) { | 1200 TEST_P(WebSocketJobTest, ThrottlingMaxNumberOfThrottledJobLimit) { |
| 1202 TestThrottlingLimit(); | 1201 TestThrottlingLimit(); |
| 1203 } | 1202 } |
| 1204 | 1203 |
| 1205 TEST_P(WebSocketJobTest, ThrottlingWebSocketSpdyEnabled) { | 1204 TEST_P(WebSocketJobTest, ThrottlingWebSocketSpdyEnabled) { |
| 1206 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1205 enable_websocket_over_spdy_ = true; |
| 1207 TestConnectByWebSocket(THROTTLING_ON); | 1206 TestConnectByWebSocket(THROTTLING_ON); |
| 1208 } | 1207 } |
| 1209 | 1208 |
| 1210 TEST_P(WebSocketJobTest, ThrottlingSpdy) { | 1209 TEST_P(WebSocketJobTest, ThrottlingSpdy) { |
| 1211 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1212 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); | 1210 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); |
| 1213 } | 1211 } |
| 1214 | 1212 |
| 1215 TEST_P(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { | 1213 TEST_P(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { |
| 1216 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1214 enable_websocket_over_spdy_ = true; |
| 1217 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1215 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
| 1218 } | 1216 } |
| 1219 | 1217 |
| 1220 TEST_F(WebSocketJobDeleteTest, OnClose) { | 1218 TEST_F(WebSocketJobDeleteTest, OnClose) { |
| 1221 SetDeleteNext(); | 1219 SetDeleteNext(); |
| 1222 job()->OnClose(socket_.get()); | 1220 job()->OnClose(socket_.get()); |
| 1223 // OnClose() sets WebSocketJob::_socket to NULL before we can detach it, so | 1221 // OnClose() sets WebSocketJob::_socket to NULL before we can detach it, so |
| 1224 // socket_->delegate is still set at this point. Clear it to avoid hitting | 1222 // socket_->delegate is still set at this point. Clear it to avoid hitting |
| 1225 // DCHECK(!delegate_) in the SocketStream destructor. SocketStream::Finish() | 1223 // DCHECK(!delegate_) in the SocketStream destructor. SocketStream::Finish() |
| 1226 // is the only caller of this method in real code, and it also sets delegate_ | 1224 // is the only caller of this method in real code, and it also sets delegate_ |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 job()->Connect(); | 1281 job()->Connect(); |
| 1284 SetDeleteNext(); | 1282 SetDeleteNext(); |
| 1285 job()->OnReceivedData( | 1283 job()->OnReceivedData( |
| 1286 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1); | 1284 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1); |
| 1287 EXPECT_FALSE(job()); | 1285 EXPECT_FALSE(job()); |
| 1288 } | 1286 } |
| 1289 | 1287 |
| 1290 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1288 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
| 1291 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1289 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
| 1292 } // namespace net | 1290 } // namespace net |
| OLD | NEW |