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

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

Issue 2349423003: Fallback to IPv6 if IPv4 adb port not available. (Closed)
Patch Set: Fallback to IPv6 if IPv4 adb port not available. Created 4 years, 3 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698