#include "net/socket/websocket_transport_client_socket_pool.h"
#include <algorithm>
#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "net/base/net_errors.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source.h"
#include "net/log/net_log_source_type.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/connect_job.h"
#include "net/socket/connect_job_factory.h"
#include "net/socket/stream_socket_handle.h"
#include "net/socket/websocket_endpoint_lock_manager.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
namespace net {
WebSocketTransportClientSocketPool::WebSocketTransportClientSocketPool(
int max_sockets,
int max_sockets_per_group,
const ProxyChain& proxy_chain,
const CommonConnectJobParams* common_connect_job_params)
: … { … }
WebSocketTransportClientSocketPool::~WebSocketTransportClientSocketPool() { … }
void WebSocketTransportClientSocketPool::UnlockEndpoint(
StreamSocketHandle* handle,
WebSocketEndpointLockManager* websocket_endpoint_lock_manager) { … }
int WebSocketTransportClientSocketPool::RequestSocket(
const GroupId& group_id,
scoped_refptr<SocketParams> params,
const std::optional<NetworkTrafficAnnotationTag>& proxy_annotation_tag,
RequestPriority priority,
const SocketTag& socket_tag,
RespectLimits respect_limits,
ClientSocketHandle* handle,
CompletionOnceCallback callback,
const ProxyAuthCallback& proxy_auth_callback,
const NetLogWithSource& request_net_log) { … }
int WebSocketTransportClientSocketPool::RequestSockets(
const GroupId& group_id,
scoped_refptr<SocketParams> params,
const std::optional<NetworkTrafficAnnotationTag>& proxy_annotation_tag,
int num_sockets,
CompletionOnceCallback callback,
const NetLogWithSource& net_log) { … }
void WebSocketTransportClientSocketPool::SetPriority(const GroupId& group_id,
ClientSocketHandle* handle,
RequestPriority priority) { … }
void WebSocketTransportClientSocketPool::CancelRequest(
const GroupId& group_id,
ClientSocketHandle* handle,
bool cancel_connect_job) { … }
void WebSocketTransportClientSocketPool::ReleaseSocket(
const GroupId& group_id,
std::unique_ptr<StreamSocket> socket,
int64_t generation) { … }
void WebSocketTransportClientSocketPool::FlushWithError(
int error,
const char* net_log_reason_utf8) { … }
void WebSocketTransportClientSocketPool::CloseIdleSockets(
const char* net_log_reason_utf8) { … }
void WebSocketTransportClientSocketPool::CloseIdleSocketsInGroup(
const GroupId& group_id,
const char* net_log_reason_utf8) { … }
int WebSocketTransportClientSocketPool::IdleSocketCount() const { … }
size_t WebSocketTransportClientSocketPool::IdleSocketCountInGroup(
const GroupId& group_id) const { … }
LoadState WebSocketTransportClientSocketPool::GetLoadState(
const GroupId& group_id,
const ClientSocketHandle* handle) const { … }
base::Value WebSocketTransportClientSocketPool::GetInfoAsValue(
const std::string& name,
const std::string& type) const { … }
bool WebSocketTransportClientSocketPool::HasActiveSocket(
const GroupId& group_id) const { … }
bool WebSocketTransportClientSocketPool::IsStalled() const { … }
void WebSocketTransportClientSocketPool::AddHigherLayeredPool(
HigherLayeredPool* higher_pool) { … }
void WebSocketTransportClientSocketPool::RemoveHigherLayeredPool(
HigherLayeredPool* higher_pool) { … }
bool WebSocketTransportClientSocketPool::TryHandOutSocket(
int result,
ConnectJobDelegate* connect_job_delegate) { … }
void WebSocketTransportClientSocketPool::OnConnectJobComplete(
int result,
ConnectJobDelegate* connect_job_delegate) { … }
void WebSocketTransportClientSocketPool::InvokeUserCallbackLater(
ClientSocketHandle* handle,
CompletionOnceCallback callback,
int rv) { … }
void WebSocketTransportClientSocketPool::InvokeUserCallback(
ClientSocketHandleID handle_id,
base::WeakPtr<ClientSocketHandle> weak_handle,
CompletionOnceCallback callback,
int rv) { … }
bool WebSocketTransportClientSocketPool::ReachedMaxSocketsLimit() const { … }
void WebSocketTransportClientSocketPool::HandOutSocket(
std::unique_ptr<StreamSocket> socket,
const LoadTimingInfo::ConnectTiming& connect_timing,
ClientSocketHandle* handle,
const NetLogWithSource& net_log) { … }
void WebSocketTransportClientSocketPool::AddJob(
ClientSocketHandle* handle,
std::unique_ptr<ConnectJobDelegate> delegate) { … }
bool WebSocketTransportClientSocketPool::DeleteJob(ClientSocketHandle* handle) { … }
const ConnectJob* WebSocketTransportClientSocketPool::LookupConnectJob(
const ClientSocketHandle* handle) const { … }
void WebSocketTransportClientSocketPool::ActivateStalledRequest() { … }
bool WebSocketTransportClientSocketPool::DeleteStalledRequest(
ClientSocketHandle* handle) { … }
WebSocketTransportClientSocketPool::ConnectJobDelegate::ConnectJobDelegate(
WebSocketTransportClientSocketPool* owner,
CompletionOnceCallback callback,
ClientSocketHandle* socket_handle,
const NetLogWithSource& request_net_log)
: … { … }
WebSocketTransportClientSocketPool::ConnectJobDelegate::~ConnectJobDelegate() =
default;
void
WebSocketTransportClientSocketPool::ConnectJobDelegate::OnConnectJobComplete(
int result,
ConnectJob* job) { … }
void WebSocketTransportClientSocketPool::ConnectJobDelegate::OnNeedsProxyAuth(
const HttpResponseInfo& response,
HttpAuthController* auth_controller,
base::OnceClosure restart_with_auth_callback,
ConnectJob* job) { … }
int WebSocketTransportClientSocketPool::ConnectJobDelegate::Connect(
std::unique_ptr<ConnectJob> connect_job) { … }
const NetLogWithSource&
WebSocketTransportClientSocketPool::ConnectJobDelegate::connect_job_net_log() { … }
WebSocketTransportClientSocketPool::StalledRequest::StalledRequest(
const GroupId& group_id,
const scoped_refptr<SocketParams>& params,
const std::optional<NetworkTrafficAnnotationTag>& proxy_annotation_tag,
RequestPriority priority,
ClientSocketHandle* handle,
CompletionOnceCallback callback,
const ProxyAuthCallback& proxy_auth_callback,
const NetLogWithSource& net_log)
: … { … }
WebSocketTransportClientSocketPool::StalledRequest::StalledRequest(
StalledRequest&& other) = default;
WebSocketTransportClientSocketPool::StalledRequest::~StalledRequest() = default;
}