#include "net/socket/tcp_client_socket.h"
#include <memory>
#include <utility>
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "net/base/features.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/nqe/network_quality_estimator.h"
#include "net/socket/socket_performance_watcher.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#if defined(TCP_CLIENT_SOCKET_OBSERVES_SUSPEND)
#include "base/power_monitor/power_monitor.h"
#endif
namespace net {
class NetLogWithSource;
TCPClientSocket::TCPClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
net::NetLog* net_log,
const net::NetLogSource& source,
handles::NetworkHandle network)
: … { … }
TCPClientSocket::TCPClientSocket(std::unique_ptr<TCPSocket> connected_socket,
const IPEndPoint& peer_address)
: … { … }
TCPClientSocket::TCPClientSocket(
std::unique_ptr<TCPSocket> unconnected_socket,
const AddressList& addresses,
std::unique_ptr<IPEndPoint> bound_address,
NetworkQualityEstimator* network_quality_estimator)
: … { … }
TCPClientSocket::~TCPClientSocket() { … }
std::unique_ptr<TCPClientSocket> TCPClientSocket::CreateFromBoundSocket(
std::unique_ptr<TCPSocket> bound_socket,
const AddressList& addresses,
const IPEndPoint& bound_address,
NetworkQualityEstimator* network_quality_estimator) { … }
int TCPClientSocket::Bind(const IPEndPoint& address) { … }
bool TCPClientSocket::SetKeepAlive(bool enable, int delay) { … }
bool TCPClientSocket::SetNoDelay(bool no_delay) { … }
void TCPClientSocket::SetBeforeConnectCallback(
const BeforeConnectCallback& before_connect_callback) { … }
int TCPClientSocket::Connect(CompletionOnceCallback callback) { … }
TCPClientSocket::TCPClientSocket(
std::unique_ptr<TCPSocket> socket,
const AddressList& addresses,
int current_address_index,
std::unique_ptr<IPEndPoint> bind_address,
NetworkQualityEstimator* network_quality_estimator,
handles::NetworkHandle network)
: … { … }
int TCPClientSocket::ReadCommon(IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
bool read_if_ready) { … }
int TCPClientSocket::DoConnectLoop(int result) { … }
int TCPClientSocket::DoConnect() { … }
int TCPClientSocket::DoConnectComplete(int result) { … }
void TCPClientSocket::OnConnectAttemptTimeout() { … }
int TCPClientSocket::ConnectInternal(const IPEndPoint& endpoint) { … }
void TCPClientSocket::Disconnect() { … }
void TCPClientSocket::DoDisconnect() { … }
bool TCPClientSocket::IsConnected() const { … }
bool TCPClientSocket::IsConnectedAndIdle() const { … }
int TCPClientSocket::GetPeerAddress(IPEndPoint* address) const { … }
int TCPClientSocket::GetLocalAddress(IPEndPoint* address) const { … }
const NetLogWithSource& TCPClientSocket::NetLog() const { … }
bool TCPClientSocket::WasEverUsed() const { … }
NextProto TCPClientSocket::GetNegotiatedProtocol() const { … }
bool TCPClientSocket::GetSSLInfo(SSLInfo* ssl_info) { … }
int TCPClientSocket::Read(IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int TCPClientSocket::ReadIfReady(IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int TCPClientSocket::CancelReadIfReady() { … }
int TCPClientSocket::Write(
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
const NetworkTrafficAnnotationTag& traffic_annotation) { … }
int TCPClientSocket::SetReceiveBufferSize(int32_t size) { … }
int TCPClientSocket::SetSendBufferSize(int32_t size) { … }
SocketDescriptor TCPClientSocket::SocketDescriptorForTesting() const { … }
int64_t TCPClientSocket::GetTotalReceivedBytes() const { … }
void TCPClientSocket::ApplySocketTag(const SocketTag& tag) { … }
void TCPClientSocket::OnSuspend() { … }
void TCPClientSocket::DidCompleteConnect(int result) { … }
void TCPClientSocket::DidCompleteRead(int result) { … }
void TCPClientSocket::DidCompleteWrite(int result) { … }
void TCPClientSocket::DidCompleteReadWrite(CompletionOnceCallback callback,
int result) { … }
int TCPClientSocket::OpenSocket(AddressFamily family) { … }
void TCPClientSocket::EmitConnectAttemptHistograms(int result) { … }
base::TimeDelta TCPClientSocket::GetConnectAttemptTimeout() { … }
}