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 #include <vector> | 10 #include <vector> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 net::IPAddressNumber address; | 78 net::IPAddressNumber address; |
79 if (!net::ParseIPLiteralToNumber(url_.HostNoBrackets(), &address)) { | 79 if (!net::ParseIPLiteralToNumber(url_.HostNoBrackets(), &address)) { |
80 if (!ResolveHost(url_.HostNoBrackets(), &address)) { | 80 if (!ResolveHost(url_.HostNoBrackets(), &address)) { |
81 callback.Run(net::ERR_ADDRESS_UNREACHABLE); | 81 callback.Run(net::ERR_ADDRESS_UNREACHABLE); |
82 return; | 82 return; |
83 } | 83 } |
84 } | 84 } |
85 net::AddressList addresses( | 85 net::AddressList addresses( |
86 net::IPEndPoint(address, static_cast<uint16_t>(url_.EffectiveIntPort()))); | 86 net::IPEndPoint(address, static_cast<uint16_t>(url_.EffectiveIntPort()))); |
87 net::NetLog::Source source; | 87 net::NetLog::Source source; |
88 socket_.reset(new net::TCPClientSocket(addresses, NULL, source)); | 88 socket_.reset(new net::TCPClientSocket(addresses, NULL, NULL, source)); |
89 | 89 |
90 state_ = CONNECTING; | 90 state_ = CONNECTING; |
91 connect_callback_ = callback; | 91 connect_callback_ = callback; |
92 int code = socket_->Connect(base::Bind( | 92 int code = socket_->Connect(base::Bind( |
93 &WebSocket::OnSocketConnect, base::Unretained(this))); | 93 &WebSocket::OnSocketConnect, base::Unretained(this))); |
94 if (code != net::ERR_IO_PENDING) | 94 if (code != net::ERR_IO_PENDING) |
95 OnSocketConnect(code); | 95 OnSocketConnect(code); |
96 } | 96 } |
97 | 97 |
98 bool WebSocket::Send(const std::string& message) { | 98 bool WebSocket::Send(const std::string& message) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 void WebSocket::Close(int code) { | 259 void WebSocket::Close(int code) { |
260 socket_->Disconnect(); | 260 socket_->Disconnect(); |
261 if (!connect_callback_.is_null()) | 261 if (!connect_callback_.is_null()) |
262 InvokeConnectCallback(code); | 262 InvokeConnectCallback(code); |
263 if (state_ == OPEN) | 263 if (state_ == OPEN) |
264 listener_->OnClose(); | 264 listener_->OnClose(); |
265 | 265 |
266 state_ = CLOSED; | 266 state_ = CLOSED; |
267 } | 267 } |
OLD | NEW |