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