blob: bae3308784a306037a85226f81f7becb80e30f4c [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2011 The Chromium Authors
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
[email protected]f7984fc62009-06-22 23:26:445#ifndef NET_SOCKET_CLIENT_SOCKET_FACTORY_H_
6#define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_
initial.commit586acc5fe2008-07-26 22:42:527
danakj655b66c2016-04-16 00:51:388#include <memory>
initial.commit586acc5fe2008-07-26 22:42:529#include <string>
10
[email protected]172da1b2011-08-12 15:52:2611#include "net/base/net_export.h"
Helen Liac3c51e2018-04-24 00:02:1312#include "net/http/proxy_client_socket.h"
tfarina5dd13c22016-11-16 12:08:2613#include "net/socket/datagram_socket.h"
tbansalca83c002016-04-28 20:56:2814#include "net/socket/socket_performance_watcher.h"
Helen Lid5bb9222018-04-12 15:33:0915#include "net/socket/transport_client_socket.h"
Helen Liac3c51e2018-04-24 00:02:1316#include "net/traffic_annotation/network_traffic_annotation.h"
[email protected]0a0b7682010-08-25 17:08:0717
initial.commit586acc5fe2008-07-26 22:42:5218namespace net {
19
20class AddressList;
[email protected]98b0e582011-06-22 14:31:4121class DatagramClientSocket;
[email protected]4f4de7e62010-11-12 19:55:2722class HostPortPair;
mikecironef22f9812016-10-04 03:40:1923class NetLog;
24struct NetLogSource;
David Benjamin24725be2019-07-24 20:57:1825class SSLClientContext;
[email protected]aaead502008-10-15 00:20:1126class SSLClientSocket;
27struct SSLConfig;
Eric Roman2bc77162020-09-16 18:30:4528class NetworkQualityEstimator;
initial.commit586acc5fe2008-07-26 22:42:5229
[email protected]3268023f2011-05-05 00:08:1030// An interface used to instantiate StreamSocket objects. Used to facilitate
initial.commit586acc5fe2008-07-26 22:42:5231// testing code with mock socket implementations.
[email protected]172da1b2011-08-12 15:52:2632class NET_EXPORT ClientSocketFactory {
initial.commit586acc5fe2008-07-26 22:42:5233 public:
Tsuyoshi Horo07c3f0e2022-06-16 07:30:4734 virtual ~ClientSocketFactory() = default;
[email protected]836dff32008-08-05 23:15:3635
mikecironef22f9812016-10-04 03:40:1936 // |source| is the NetLogSource for the entity trying to create the socket,
[email protected]0a0b7682010-08-25 17:08:0737 // if it has one.
danakj655b66c2016-04-16 00:51:3838 virtual std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket(
[email protected]5370c012011-06-29 03:47:0439 DatagramSocket::BindType bind_type,
[email protected]98b0e582011-06-22 14:31:4140 NetLog* net_log,
mikecironef22f9812016-10-04 03:40:1941 const NetLogSource& source) = 0;
[email protected]98b0e582011-06-22 14:31:4142
Eric Roman2bc77162020-09-16 18:30:4543 // |network_quality_estimator| is optional. If not specified, the network
44 // quality will not be considered when determining TCP connect handshake
45 // timeouts, or when histogramming the handshake duration.
Helen Lid5bb9222018-04-12 15:33:0946 virtual std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
[email protected]0a0b7682010-08-25 17:08:0747 const AddressList& addresses,
danakj655b66c2016-04-16 00:51:3848 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
Eric Roman2bc77162020-09-16 18:30:4549 NetworkQualityEstimator* network_quality_estimator,
[email protected]0a0b7682010-08-25 17:08:0750 NetLog* net_log,
mikecironef22f9812016-10-04 03:40:1951 const NetLogSource& source) = 0;
initial.commit586acc5fe2008-07-26 22:42:5252
Matt Menke841fc412019-03-05 23:20:1253 // It is allowed to pass in a StreamSocket that is not obtained from a
54 // socket pool. The caller could create a StreamSocket directly.
danakj655b66c2016-04-16 00:51:3855 virtual std::unique_ptr<SSLClientSocket> CreateSSLClientSocket(
David Benjamin24725be2019-07-24 20:57:1856 SSLClientContext* context,
Matt Menke841fc412019-03-05 23:20:1257 std::unique_ptr<StreamSocket> stream_socket,
Matt Menkefd956922019-02-04 23:44:0358 const HostPortPair& host_and_port,
David Benjamin24725be2019-07-24 20:57:1859 const SSLConfig& ssl_config) = 0;
[email protected]e60e47a2010-07-14 03:37:1860
initial.commit586acc5fe2008-07-26 22:42:5261 // Returns the default ClientSocketFactory.
62 static ClientSocketFactory* GetDefaultFactory();
63};
64
65} // namespace net
66
[email protected]f7984fc62009-06-22 23:26:4467#endif // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_