Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: chrome/test/chromedriver/net/websocket.cc

Issue 655063002: Use uint16 for port numbers more pervasively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert bad change Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/net/port_server_unittest.cc ('k') | chrome/test/chromedriver/server/chromedriver_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698