| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 397 |
| 399 socket_ = new SocketStream(url, websocket_.get()); | 398 socket_ = new SocketStream(url, websocket_.get()); |
| 400 socket_factory_.reset(new MockClientSocketFactory); | 399 socket_factory_.reset(new MockClientSocketFactory); |
| 401 DCHECK(data_.get()); | 400 DCHECK(data_.get()); |
| 402 socket_factory_->AddSocketDataProvider(data_.get()); | 401 socket_factory_->AddSocketDataProvider(data_.get()); |
| 403 socket_->SetClientSocketFactory(socket_factory_.get()); | 402 socket_->SetClientSocketFactory(socket_factory_.get()); |
| 404 } | 403 } |
| 405 | 404 |
| 406 websocket_->InitSocketStream(socket_.get()); | 405 websocket_->InitSocketStream(socket_.get()); |
| 407 websocket_->set_context(context_.get()); | 406 websocket_->set_context(context_.get()); |
| 408 struct addrinfo addr; | 407 IPAddressNumber ip; |
| 409 memset(&addr, 0, sizeof(struct addrinfo)); | 408 ParseIPLiteralToNumber("127.0.0.1", &ip); |
| 410 addr.ai_family = AF_INET; | 409 websocket_->addresses_ = AddressList::CreateFromIPAddress(ip, 0); |
| 411 addr.ai_addrlen = sizeof(struct sockaddr_in); | |
| 412 struct sockaddr_in sa_in; | |
| 413 memset(&sa_in, 0, sizeof(struct sockaddr_in)); | |
| 414 memcpy(&sa_in.sin_addr, "\x7f\0\0\1", 4); | |
| 415 addr.ai_addr = reinterpret_cast<sockaddr*>(&sa_in); | |
| 416 addr.ai_next = NULL; | |
| 417 websocket_->addresses_ = AddressList::CreateByCopying(&addr); | |
| 418 } | 410 } |
| 419 void SkipToConnecting() { | 411 void SkipToConnecting() { |
| 420 websocket_->state_ = WebSocketJob::CONNECTING; | 412 websocket_->state_ = WebSocketJob::CONNECTING; |
| 421 WebSocketThrottle::GetInstance()->PutInQueue(websocket_); | 413 WebSocketThrottle::GetInstance()->PutInQueue(websocket_); |
| 422 } | 414 } |
| 423 WebSocketJob::State GetWebSocketJobState() { | 415 WebSocketJob::State GetWebSocketJobState() { |
| 424 return websocket_->state_; | 416 return websocket_->state_; |
| 425 } | 417 } |
| 426 void CloseWebSocketJob() { | 418 void CloseWebSocketJob() { |
| 427 if (websocket_->socket_) { | 419 if (websocket_->socket_) { |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 | 1100 |
| 1109 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdySpdyEnabled) { | 1101 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdySpdyEnabled) { |
| 1110 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1102 WebSocketJob::set_websocket_over_spdy_enabled(true); |
| 1111 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1103 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
| 1112 } | 1104 } |
| 1113 | 1105 |
| 1114 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1106 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
| 1115 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1107 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
| 1116 | 1108 |
| 1117 } // namespace net | 1109 } // namespace net |
| OLD | NEW |