#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/devtools/device/adb/adb_client_socket.h"
#include <stddef.h>
#include <memory>
#include <utility>
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
#include "net/log/net_log_source.h"
#include "net/socket/tcp_client_socket.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
namespace {
const int kBufferSize = …;
const char kOkayResponse[] = …;
const char kHostTransportCommand[] = …;
const char kLocalhost[] = …;
std::string EncodeMessage(const std::string& message) { … }
class AdbTransportSocket : public AdbClientSocket { … };
class AdbQuerySocket : AdbClientSocket { … };
}
void AdbClientSocket::AdbQuery(int port,
const std::string& query,
CommandCallback callback) { … }
void AdbClientSocket::TransportQuery(int port,
const std::string& serial,
const std::string& socket_name,
SocketCallback callback) { … }
AdbClientSocket::AdbClientSocket(int port)
: … { … }
AdbClientSocket::~AdbClientSocket() { … }
void AdbClientSocket::RunConnectCallback(int result) { … }
void AdbClientSocket::Connect(net::CompletionOnceCallback callback) { … }
void AdbClientSocket::SendCommand(const std::string& command,
bool is_void,
CommandCallback callback) { … }
void AdbClientSocket::ReadResponse(CommandCallback callback,
bool is_void,
int result) { … }
void AdbClientSocket::OnResponseHeader(
CommandCallback callback,
bool is_void,
scoped_refptr<net::IOBuffer> response_buffer,
int result) { … }
void AdbClientSocket::OnResponseData(
CommandCallback callback,
const std::string& response,
scoped_refptr<net::IOBuffer> response_buffer,
int bytes_left,
int result) { … }