| 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/string_split.h" | 14 #include "base/string_split.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 18 #include "net/base/mock_host_resolver.h" | 18 #include "net/base/mock_host_resolver.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/ssl_config_service.h" | 20 #include "net/base/ssl_config_service.h" |
| 21 #include "net/base/sys_addrinfo.h" | |
| 22 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
| 23 #include "net/base/transport_security_state.h" | 22 #include "net/base/transport_security_state.h" |
| 24 #include "net/cookies/cookie_store.h" | 23 #include "net/cookies/cookie_store.h" |
| 25 #include "net/cookies/cookie_store_test_helpers.h" | 24 #include "net/cookies/cookie_store_test_helpers.h" |
| 26 #include "net/http/http_transaction_factory.h" | 25 #include "net/http/http_transaction_factory.h" |
| 27 #include "net/proxy/proxy_service.h" | 26 #include "net/proxy/proxy_service.h" |
| 28 #include "net/socket/socket_test_util.h" | 27 #include "net/socket/socket_test_util.h" |
| 29 #include "net/socket_stream/socket_stream.h" | 28 #include "net/socket_stream/socket_stream.h" |
| 30 #include "net/spdy/spdy_session.h" | 29 #include "net/spdy/spdy_session.h" |
| 31 #include "net/spdy/spdy_test_util_spdy3.h" | 30 #include "net/spdy/spdy_test_util_spdy3.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 398 |
| 400 socket_ = new SocketStream(url, websocket_.get()); | 399 socket_ = new SocketStream(url, websocket_.get()); |
| 401 socket_factory_.reset(new MockClientSocketFactory); | 400 socket_factory_.reset(new MockClientSocketFactory); |
| 402 DCHECK(data_.get()); | 401 DCHECK(data_.get()); |
| 403 socket_factory_->AddSocketDataProvider(data_.get()); | 402 socket_factory_->AddSocketDataProvider(data_.get()); |
| 404 socket_->SetClientSocketFactory(socket_factory_.get()); | 403 socket_->SetClientSocketFactory(socket_factory_.get()); |
| 405 } | 404 } |
| 406 | 405 |
| 407 websocket_->InitSocketStream(socket_.get()); | 406 websocket_->InitSocketStream(socket_.get()); |
| 408 websocket_->set_context(context_.get()); | 407 websocket_->set_context(context_.get()); |
| 409 struct addrinfo addr; | 408 IPAddressNumber ip; |
| 410 memset(&addr, 0, sizeof(struct addrinfo)); | 409 ParseIPLiteralToNumber("127.0.0.1", &ip); |
| 411 addr.ai_family = AF_INET; | 410 websocket_->addresses_ = AddressList::CreateFromIPAddress(ip, 0); |
| 412 addr.ai_addrlen = sizeof(struct sockaddr_in); | |
| 413 struct sockaddr_in sa_in; | |
| 414 memset(&sa_in, 0, sizeof(struct sockaddr_in)); | |
| 415 memcpy(&sa_in.sin_addr, "\x7f\0\0\1", 4); | |
| 416 addr.ai_addr = reinterpret_cast<sockaddr*>(&sa_in); | |
| 417 addr.ai_next = NULL; | |
| 418 websocket_->addresses_ = AddressList::CreateByCopying(&addr); | |
| 419 } | 411 } |
| 420 void SkipToConnecting() { | 412 void SkipToConnecting() { |
| 421 websocket_->state_ = WebSocketJob::CONNECTING; | 413 websocket_->state_ = WebSocketJob::CONNECTING; |
| 422 WebSocketThrottle::GetInstance()->PutInQueue(websocket_); | 414 WebSocketThrottle::GetInstance()->PutInQueue(websocket_); |
| 423 } | 415 } |
| 424 WebSocketJob::State GetWebSocketJobState() { | 416 WebSocketJob::State GetWebSocketJobState() { |
| 425 return websocket_->state_; | 417 return websocket_->state_; |
| 426 } | 418 } |
| 427 void CloseWebSocketJob() { | 419 void CloseWebSocketJob() { |
| 428 if (websocket_->socket_) { | 420 if (websocket_->socket_) { |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 | 1101 |
| 1110 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdySpdyEnabled) { | 1102 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdySpdyEnabled) { |
| 1111 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1103 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1112 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1104 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
| 1113 } | 1105 } |
| 1114 | 1106 |
| 1115 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1107 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
| 1116 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1108 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
| 1117 | 1109 |
| 1118 } // namespace net | 1110 } // namespace net |
| OLD | NEW |