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> |
| 8 #include <stdint.h> |
7 #include <string.h> | 9 #include <string.h> |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/base64.h" | 12 #include "base/base64.h" |
11 #include "base/bind.h" | 13 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
15 #include "base/sha1.h" | 17 #include "base/sha1.h" |
16 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "build/build_config.h" |
18 #include "net/base/address_list.h" | 21 #include "net/base/address_list.h" |
19 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
20 #include "net/base/ip_endpoint.h" | 23 #include "net/base/ip_endpoint.h" |
21 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
22 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
23 #include "net/base/sys_addrinfo.h" | 26 #include "net/base/sys_addrinfo.h" |
24 #include "net/http/http_response_headers.h" | 27 #include "net/http/http_response_headers.h" |
25 #include "net/http/http_util.h" | 28 #include "net/http/http_util.h" |
26 #include "net/websockets/websocket_frame.h" | 29 #include "net/websockets/websocket_frame.h" |
27 | 30 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 CHECK_EQ(INITIALIZED, state_); | 76 CHECK_EQ(INITIALIZED, state_); |
74 | 77 |
75 net::IPAddressNumber address; | 78 net::IPAddressNumber address; |
76 if (!net::ParseIPLiteralToNumber(url_.HostNoBrackets(), &address)) { | 79 if (!net::ParseIPLiteralToNumber(url_.HostNoBrackets(), &address)) { |
77 if (!ResolveHost(url_.HostNoBrackets(), &address)) { | 80 if (!ResolveHost(url_.HostNoBrackets(), &address)) { |
78 callback.Run(net::ERR_ADDRESS_UNREACHABLE); | 81 callback.Run(net::ERR_ADDRESS_UNREACHABLE); |
79 return; | 82 return; |
80 } | 83 } |
81 } | 84 } |
82 net::AddressList addresses( | 85 net::AddressList addresses( |
83 net::IPEndPoint(address, static_cast<uint16>(url_.EffectiveIntPort()))); | 86 net::IPEndPoint(address, static_cast<uint16_t>(url_.EffectiveIntPort()))); |
84 net::NetLog::Source source; | 87 net::NetLog::Source source; |
85 socket_.reset(new net::TCPClientSocket(addresses, NULL, source)); | 88 socket_.reset(new net::TCPClientSocket(addresses, NULL, source)); |
86 | 89 |
87 state_ = CONNECTING; | 90 state_ = CONNECTING; |
88 connect_callback_ = callback; | 91 connect_callback_ = callback; |
89 int code = socket_->Connect(base::Bind( | 92 int code = socket_->Connect(base::Bind( |
90 &WebSocket::OnSocketConnect, base::Unretained(this))); | 93 &WebSocket::OnSocketConnect, base::Unretained(this))); |
91 if (code != net::ERR_IO_PENDING) | 94 if (code != net::ERR_IO_PENDING) |
92 OnSocketConnect(code); | 95 OnSocketConnect(code); |
93 } | 96 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 258 |
256 void WebSocket::Close(int code) { | 259 void WebSocket::Close(int code) { |
257 socket_->Disconnect(); | 260 socket_->Disconnect(); |
258 if (!connect_callback_.is_null()) | 261 if (!connect_callback_.is_null()) |
259 InvokeConnectCallback(code); | 262 InvokeConnectCallback(code); |
260 if (state_ == OPEN) | 263 if (state_ == OPEN) |
261 listener_->OnClose(); | 264 listener_->OnClose(); |
262 | 265 |
263 state_ = CLOSED; | 266 state_ = CLOSED; |
264 } | 267 } |
OLD | NEW |