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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 net::AddressList addresses; | 74 net::AddressList addresses; |
75 uint16_t port = static_cast<uint16_t>(url_.EffectiveIntPort()); | 75 uint16_t port = static_cast<uint16_t>(url_.EffectiveIntPort()); |
76 if (ParseURLHostnameToAddress(url_.host(), &address)) { | 76 if (ParseURLHostnameToAddress(url_.host(), &address)) { |
77 addresses = net::AddressList::CreateFromIPAddress(address, port); | 77 addresses = net::AddressList::CreateFromIPAddress(address, port); |
78 } else if (!ResolveHost(url_.HostNoBrackets(), port, &addresses)) { | 78 } else if (!ResolveHost(url_.HostNoBrackets(), port, &addresses)) { |
79 callback.Run(net::ERR_ADDRESS_UNREACHABLE); | 79 callback.Run(net::ERR_ADDRESS_UNREACHABLE); |
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 net::NetLog::Source source; | 83 net::NetLog::Source source; |
84 socket_.reset(new net::TCPClientSocket(addresses, NULL, source)); | 84 socket_.reset(new net::TCPClientSocket(addresses, NULL, NULL, source)); |
85 | 85 |
86 state_ = CONNECTING; | 86 state_ = CONNECTING; |
87 connect_callback_ = callback; | 87 connect_callback_ = callback; |
88 int code = socket_->Connect(base::Bind( | 88 int code = socket_->Connect(base::Bind( |
89 &WebSocket::OnSocketConnect, base::Unretained(this))); | 89 &WebSocket::OnSocketConnect, base::Unretained(this))); |
90 if (code != net::ERR_IO_PENDING) | 90 if (code != net::ERR_IO_PENDING) |
91 OnSocketConnect(code); | 91 OnSocketConnect(code); |
92 } | 92 } |
93 | 93 |
94 bool WebSocket::Send(const std::string& message) { | 94 bool WebSocket::Send(const std::string& message) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 void WebSocket::Close(int code) { | 255 void WebSocket::Close(int code) { |
256 socket_->Disconnect(); | 256 socket_->Disconnect(); |
257 if (!connect_callback_.is_null()) | 257 if (!connect_callback_.is_null()) |
258 InvokeConnectCallback(code); | 258 InvokeConnectCallback(code); |
259 if (state_ == OPEN) | 259 if (state_ == OPEN) |
260 listener_->OnClose(); | 260 listener_->OnClose(); |
261 | 261 |
262 state_ = CLOSED; | 262 state_ = CLOSED; |
263 } | 263 } |
OLD | NEW |