Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/adb_client_socket.h" | 5 #include "chrome/test/chromedriver/net/adb_client_socket.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 new HttpOverAdbSocket(port, serial, socket_name, request_path, | 358 new HttpOverAdbSocket(port, serial, socket_name, request_path, |
| 359 callback); | 359 callback); |
| 360 } | 360 } |
| 361 | 361 |
| 362 AdbClientSocket::AdbClientSocket(int port) : port_(port) {} | 362 AdbClientSocket::AdbClientSocket(int port) : port_(port) {} |
| 363 | 363 |
| 364 AdbClientSocket::~AdbClientSocket() { | 364 AdbClientSocket::~AdbClientSocket() { |
| 365 } | 365 } |
| 366 | 366 |
| 367 void AdbClientSocket::Connect(const net::CompletionCallback& callback) { | 367 void AdbClientSocket::Connect(const net::CompletionCallback& callback) { |
| 368 net::AddressList address_list = net::AddressList::CreateFromIPAddress( | 368 net::IPAddressList list = {net::IPAddress::IPv4Localhost(), |
| 369 net::IPAddress::IPv4Localhost(), port_); | 369 net::IPAddress::IPv6Localhost()}; |
|
samuong
2016/09/21 15:07:34
Would it be better to resolve "localhost"? On IPv4
| |
| 370 net::AddressList ip_list = net::AddressList::CreateFromIPAddressList( | |
| 371 list, "localhost"); | |
| 372 net::AddressList address_list = net::AddressList::CopyWithPort( | |
| 373 ip_list, port_); | |
| 374 | |
| 370 socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL, | 375 socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL, |
| 371 net::NetLog::Source())); | 376 net::NetLog::Source())); |
| 372 int result = socket_->Connect(callback); | 377 int result = socket_->Connect(callback); |
| 373 if (result != net::ERR_IO_PENDING) | 378 if (result != net::ERR_IO_PENDING) |
| 374 callback.Run(result); | 379 callback.Run(result); |
| 375 } | 380 } |
| 376 | 381 |
| 377 void AdbClientSocket::SendCommand(const std::string& command, | 382 void AdbClientSocket::SendCommand(const std::string& command, |
| 378 bool is_void, | 383 bool is_void, |
| 379 bool has_length, | 384 bool has_length, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 base::Unretained(this), | 531 base::Unretained(this), |
| 527 callback, | 532 callback, |
| 528 new_response, | 533 new_response, |
| 529 response_buffer, | 534 response_buffer, |
| 530 bytes_left)); | 535 bytes_left)); |
| 531 if (result > 0) | 536 if (result > 0) |
| 532 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 537 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
| 533 else if (result != net::ERR_IO_PENDING) | 538 else if (result != net::ERR_IO_PENDING) |
| 534 callback.Run(net::OK, new_response); | 539 callback.Run(net::OK, new_response); |
| 535 } | 540 } |
| OLD | NEW |