| 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 "chrome/test/chromedriver/net/websocket.h" | 5 #include "chrome/test/chromedriver/net/websocket.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 CHECK(thread_checker_.CalledOnValidThread()); | 71 CHECK(thread_checker_.CalledOnValidThread()); |
| 72 CHECK_EQ(INITIALIZED, state_); | 72 CHECK_EQ(INITIALIZED, state_); |
| 73 | 73 |
| 74 net::IPAddressNumber address; | 74 net::IPAddressNumber address; |
| 75 if (!net::ParseIPLiteralToNumber(url_.HostNoBrackets(), &address)) { | 75 if (!net::ParseIPLiteralToNumber(url_.HostNoBrackets(), &address)) { |
| 76 if (!ResolveHost(url_.HostNoBrackets(), &address)) { | 76 if (!ResolveHost(url_.HostNoBrackets(), &address)) { |
| 77 callback.Run(net::ERR_ADDRESS_UNREACHABLE); | 77 callback.Run(net::ERR_ADDRESS_UNREACHABLE); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 int port = 80; | 81 net::AddressList addresses( |
| 82 base::StringToInt(url_.port(), &port); | 82 net::IPEndPoint(address, static_cast<uint16>(url_.EffectiveIntPort()))); |
| 83 net::AddressList addresses(net::IPEndPoint(address, port)); | |
| 84 net::NetLog::Source source; | 83 net::NetLog::Source source; |
| 85 socket_.reset(new net::TCPClientSocket(addresses, NULL, source)); | 84 socket_.reset(new net::TCPClientSocket(addresses, NULL, source)); |
| 86 | 85 |
| 87 state_ = CONNECTING; | 86 state_ = CONNECTING; |
| 88 connect_callback_ = callback; | 87 connect_callback_ = callback; |
| 89 int code = socket_->Connect(base::Bind( | 88 int code = socket_->Connect(base::Bind( |
| 90 &WebSocket::OnSocketConnect, base::Unretained(this))); | 89 &WebSocket::OnSocketConnect, base::Unretained(this))); |
| 91 if (code != net::ERR_IO_PENDING) | 90 if (code != net::ERR_IO_PENDING) |
| 92 OnSocketConnect(code); | 91 OnSocketConnect(code); |
| 93 } | 92 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 254 |
| 256 void WebSocket::Close(int code) { | 255 void WebSocket::Close(int code) { |
| 257 socket_->Disconnect(); | 256 socket_->Disconnect(); |
| 258 if (!connect_callback_.is_null()) | 257 if (!connect_callback_.is_null()) |
| 259 InvokeConnectCallback(code); | 258 InvokeConnectCallback(code); |
| 260 if (state_ == OPEN) | 259 if (state_ == OPEN) |
| 261 listener_->OnClose(); | 260 listener_->OnClose(); |
| 262 | 261 |
| 263 state_ = CLOSED; | 262 state_ = CLOSED; |
| 264 } | 263 } |
| OLD | NEW |