| 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/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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 399 |
| 400 socket_ = new SocketStream(url, websocket_.get()); | 400 socket_ = new SocketStream(url, websocket_.get()); |
| 401 socket_factory_.reset(new MockClientSocketFactory); | 401 socket_factory_.reset(new MockClientSocketFactory); |
| 402 DCHECK(data_.get()); | 402 DCHECK(data_.get()); |
| 403 socket_factory_->AddSocketDataProvider(data_.get()); | 403 socket_factory_->AddSocketDataProvider(data_.get()); |
| 404 socket_->SetClientSocketFactory(socket_factory_.get()); | 404 socket_->SetClientSocketFactory(socket_factory_.get()); |
| 405 } | 405 } |
| 406 | 406 |
| 407 websocket_->InitSocketStream(socket_.get()); | 407 websocket_->InitSocketStream(socket_.get()); |
| 408 websocket_->set_context(context_.get()); | 408 websocket_->set_context(context_.get()); |
| 409 // MockHostResolver resolves all hosts to 127.0.0.1; however, when we create |
| 410 // a WebSocketJob purely to block another one in a throttling test, we don't |
| 411 // perform a real connect. In that case, the following address is used |
| 412 // instead. |
| 409 IPAddressNumber ip; | 413 IPAddressNumber ip; |
| 410 ParseIPLiteralToNumber("127.0.0.1", &ip); | 414 ParseIPLiteralToNumber("127.0.0.1", &ip); |
| 411 websocket_->addresses_ = AddressList::CreateFromIPAddress(ip, 0); | 415 websocket_->addresses_ = AddressList::CreateFromIPAddress(ip, 80); |
| 412 } | 416 } |
| 413 void SkipToConnecting() { | 417 void SkipToConnecting() { |
| 414 websocket_->state_ = WebSocketJob::CONNECTING; | 418 websocket_->state_ = WebSocketJob::CONNECTING; |
| 415 WebSocketThrottle::GetInstance()->PutInQueue(websocket_); | 419 WebSocketThrottle::GetInstance()->PutInQueue(websocket_); |
| 416 } | 420 } |
| 417 WebSocketJob::State GetWebSocketJobState() { | 421 WebSocketJob::State GetWebSocketJobState() { |
| 418 return websocket_->state_; | 422 return websocket_->state_; |
| 419 } | 423 } |
| 420 void CloseWebSocketJob() { | 424 void CloseWebSocketJob() { |
| 421 if (websocket_->socket_) { | 425 if (websocket_->socket_) { |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 | 1092 |
| 1089 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { | 1093 TEST_F(WebSocketJobSpdy2Test, ThrottlingSpdySpdyEnabled) { |
| 1090 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1094 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1091 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1095 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
| 1092 } | 1096 } |
| 1093 | 1097 |
| 1094 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1098 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
| 1095 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1099 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
| 1096 | 1100 |
| 1097 } // namespace net | 1101 } // namespace net |
| OLD | NEW |