#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/socket/websocket_transport_client_socket_pool.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "net/base/features.h"
#include "net/base/ip_endpoint.h"
#include "net/base/load_timing_info.h"
#include "net/base/load_timing_info_test_util.h"
#include "net/base/net_errors.h"
#include "net/base/privacy_mode.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_server.h"
#include "net/base/schemeful_site.h"
#include "net/base/test_completion_callback.h"
#include "net/dns/mock_host_resolver.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/log/net_log.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/connect_job.h"
#include "net/socket/connect_job_test_util.h"
#include "net/socket/socket_tag.h"
#include "net/socket/socket_test_util.h"
#include "net/socket/ssl_client_socket.h"
#include "net/socket/stream_socket.h"
#include "net/socket/transport_client_socket_pool_test_util.h"
#include "net/socket/transport_connect_job.h"
#include "net/socket/websocket_endpoint_lock_manager.h"
#include "net/test/gtest_util.h"
#include "net/test/test_with_task_environment.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
#include "url/url_constants.h"
IsError;
IsOk;
namespace net {
namespace {
const int kMaxSockets = …;
const int kMaxSocketsPerGroup = …;
const RequestPriority kDefaultPriority = …;
IPAddress ParseIP(const std::string& ip) { … }
void RunLoopForTimePeriod(base::TimeDelta period) { … }
class WebSocketTransportClientSocketPoolTest : public TestWithTaskEnvironment { … };
TEST_F(WebSocketTransportClientSocketPoolTest, Basic) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, SetResolvePriorityOnInit) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, InitHostResolutionFailure) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, InitConnectionFailure) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, PendingRequestsFinishFifo) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, PendingRequests_NoKeepAlive) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, CancelRequestClearGroup) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, TwoRequestsCancelOne) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, ConnectCancelConnect) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, CancelRequest) { … }
void RequestSocketOnComplete(const ClientSocketPool::GroupId& group_id,
ClientSocketHandle* handle,
WebSocketTransportClientSocketPool* pool,
TestCompletionCallback* nested_callback,
int first_request_result) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, RequestTwice) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
CancelActiveRequestWithPendingRequests) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
FailingActiveRequestWithPendingRequests) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, LockReleasedOnHandleReset) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, LockReleasedOnHandleDelete) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
ConnectionProceedsOnExplicitRelease) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
CancelDuringConnectionReleasesLock) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
IPv6FallbackSocketIPv4FinishesFirst) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
IPv6FallbackSocketIPv6FinishesFirst) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
IPv6NoIPv4AddressesToFallbackTo) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, IPv4HasNoFallback) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, IPv6InstantFail) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, IPv6RapidFail) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, FirstSuccessWins) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, LastFailureWins) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, Suspend) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, SuspendAsync) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, DISABLED_OverallTimeoutApplies) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, MaxSocketsEnforced) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, MaxSocketsEnforcedWhenPending) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, StalledSocketReleased) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, IsStalledTrueWhenStalled) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
CancellingPendingSocketUnstallsStalledSocket) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
LoadStateOfStalledSocketIsWaitingForAvailableSocket) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
CancellingStalledSocketUnstallsPool) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
FlushWithErrorFlushesPendingConnections) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
FlushWithErrorFlushesStalledConnections) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
AfterFlushWithErrorCanMakeNewConnections) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
FlushWithErrorDoesNotCauseSuccessfulConnections) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
FlushWithErrorDoesNotCauseSuccessfulConnectionsMultipleAddressTypes) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
FlushWithErrorDoesNotAffectHandedOutSockets) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, CancelRequestReclaimsSockets) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, EndpointLockIsOnlyReleasedOnce) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, NetworkAnonymizationKey) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
TransportConnectJobWithDnsAliases) { … }
TEST_F(WebSocketTransportClientSocketPoolTest,
TransportConnectJobWithNoAdditionalDnsAliases) { … }
TEST_F(WebSocketTransportClientSocketPoolTest, LoadState) { … }
}
}