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

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

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 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
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"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "net/base/address_list.h" 15 #include "net/base/address_list.h"
16 #include "net/base/completion_callback.h" 16 #include "net/base/completion_callback.h"
17 #include "net/base/ip_address.h" 17 #include "net/base/ip_address.h"
18 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 #include "net/log/net_log_source.h"
19 #include "net/socket/tcp_client_socket.h" 20 #include "net/socket/tcp_client_socket.h"
20 21
21 namespace { 22 namespace {
22 23
23 const int kBufferSize = 16 * 1024; 24 const int kBufferSize = 16 * 1024;
24 const char kOkayResponse[] = "OKAY"; 25 const char kOkayResponse[] = "OKAY";
25 const char kHostTransportCommand[] = "host:transport:%s"; 26 const char kHostTransportCommand[] = "host:transport:%s";
26 const char kLocalAbstractCommand[] = "localabstract:%s"; 27 const char kLocalAbstractCommand[] = "localabstract:%s";
27 28
28 typedef base::Callback<void(int, const std::string&)> CommandCallback; 29 typedef base::Callback<void(int, const std::string&)> CommandCallback;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 #if defined(DEBUG_DEVTOOLS) 325 #if defined(DEBUG_DEVTOOLS)
325 if (serial.empty()) { 326 if (serial.empty()) {
326 // Use plain socket for remote debugging on Desktop (debugging purposes). 327 // Use plain socket for remote debugging on Desktop (debugging purposes).
327 int tcp_port = 0; 328 int tcp_port = 0;
328 if (!base::StringToInt(socket_name, &tcp_port)) 329 if (!base::StringToInt(socket_name, &tcp_port))
329 tcp_port = 9222; 330 tcp_port = 9222;
330 331
331 net::AddressList address_list = net::AddressList::CreateFromIPAddress( 332 net::AddressList address_list = net::AddressList::CreateFromIPAddress(
332 net::IPAddress::IPv4Localhost(), tcp_port); 333 net::IPAddress::IPv4Localhost(), tcp_port);
333 net::TCPClientSocket* socket = new net::TCPClientSocket( 334 net::TCPClientSocket* socket = new net::TCPClientSocket(
334 address_list, NULL, net::NetLog::Source()); 335 address_list, NULL, net::NetLogSource());
335 socket->Connect(base::Bind(&UseTransportQueryForDesktop, callback, socket)); 336 socket->Connect(base::Bind(&UseTransportQueryForDesktop, callback, socket));
336 return; 337 return;
337 } 338 }
338 #endif // defined(DEBUG_DEVTOOLS) 339 #endif // defined(DEBUG_DEVTOOLS)
339 new AdbTransportSocket(port, serial, socket_name, callback); 340 new AdbTransportSocket(port, serial, socket_name, callback);
340 } 341 }
341 342
342 // static 343 // static
343 void AdbClientSocket::HttpQuery(int port, 344 void AdbClientSocket::HttpQuery(int port,
344 const std::string& serial, 345 const std::string& serial,
(...skipping 24 matching lines...) Expand all
369 // only return IPv6 address while current adb (1.0.36) will always listen 370 // only return IPv6 address while current adb (1.0.36) will always listen
370 // on IPv4. So just try IPv4 first, then fall back to IPv6. 371 // on IPv4. So just try IPv4 first, then fall back to IPv6.
371 net::IPAddressList list = {net::IPAddress::IPv4Localhost(), 372 net::IPAddressList list = {net::IPAddress::IPv4Localhost(),
372 net::IPAddress::IPv6Localhost()}; 373 net::IPAddress::IPv6Localhost()};
373 net::AddressList ip_list = net::AddressList::CreateFromIPAddressList( 374 net::AddressList ip_list = net::AddressList::CreateFromIPAddressList(
374 list, "localhost"); 375 list, "localhost");
375 net::AddressList address_list = net::AddressList::CopyWithPort( 376 net::AddressList address_list = net::AddressList::CopyWithPort(
376 ip_list, port_); 377 ip_list, port_);
377 378
378 socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL, 379 socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL,
379 net::NetLog::Source())); 380 net::NetLogSource()));
380 int result = socket_->Connect(callback); 381 int result = socket_->Connect(callback);
381 if (result != net::ERR_IO_PENDING) 382 if (result != net::ERR_IO_PENDING)
382 callback.Run(result); 383 callback.Run(result);
383 } 384 }
384 385
385 void AdbClientSocket::SendCommand(const std::string& command, 386 void AdbClientSocket::SendCommand(const std::string& command,
386 bool is_void, 387 bool is_void,
387 bool has_length, 388 bool has_length,
388 const CommandCallback& callback) { 389 const CommandCallback& callback) {
389 scoped_refptr<net::StringIOBuffer> request_buffer = 390 scoped_refptr<net::StringIOBuffer> request_buffer =
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 base::Unretained(this), 535 base::Unretained(this),
535 callback, 536 callback,
536 new_response, 537 new_response,
537 response_buffer, 538 response_buffer,
538 bytes_left)); 539 bytes_left));
539 if (result > 0) 540 if (result > 0)
540 OnResponseData(callback, new_response, response_buffer, bytes_left, result); 541 OnResponseData(callback, new_response, response_buffer, bytes_left, result);
541 else if (result != net::ERR_IO_PENDING) 542 else if (result != net::ERR_IO_PENDING)
542 callback.Run(net::OK, new_response); 543 callback.Run(net::OK, new_response);
543 } 544 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698