proxy_resolving_client_socket_factory.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_NETWORK_PROXY_RESOLVING_CLIENT_SOCKET_FACTORY_H_
  5. #define SERVICES_NETWORK_PROXY_RESOLVING_CLIENT_SOCKET_FACTORY_H_
  6. #include <memory>
  7. #include "base/component_export.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "base/memory/ref_counted.h"
  10. #include "net/socket/connect_job_factory.h"
  11. #include "net/ssl/ssl_config.h"
  12. #include "url/gurl.h"
  13. namespace net {
  14. struct CommonConnectJobParams;
  15. class HttpNetworkSession;
  16. class NetworkIsolationKey;
  17. class URLRequestContext;
  18. } // namespace net
  19. namespace network {
  20. class ProxyResolvingClientSocket;
  21. class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolvingClientSocketFactory {
  22. public:
  23. // Constructs a ProxyResolvingClientSocketFactory. This factory shares
  24. // network session params with |request_context|, but keeps separate socket
  25. // pools by instantiating and owning a separate |network_session_|.
  26. explicit ProxyResolvingClientSocketFactory(
  27. net::URLRequestContext* request_context);
  28. ProxyResolvingClientSocketFactory(const ProxyResolvingClientSocketFactory&) =
  29. delete;
  30. ProxyResolvingClientSocketFactory& operator=(
  31. const ProxyResolvingClientSocketFactory&) = delete;
  32. ~ProxyResolvingClientSocketFactory();
  33. // Creates a socket. |url|'s host and port specify where a connection will be
  34. // established to. The full URL will be only used for proxy resolution. Caller
  35. // doesn't need to explicitly sanitize the url, any sensitive data (like
  36. // embedded usernames and passwords), and local data (i.e. reference fragment)
  37. // will be sanitized by net::ProxyResolutionService before the url is
  38. // disclosed to the PAC script.
  39. //
  40. // |network_isolation_key| indicates the network shard to use for storing
  41. // shared network state (DNS cache entries, shared H2/QUIC proxy connections,
  42. // etc). Proxy connections will only be shared with other
  43. // ProxyResolvingClientSockets, not with standards HTTP/HTTPS requests.
  44. //
  45. // If |use_tls| is true, TLS connect will be used in addition to TCP connect.
  46. // The URLRequestContext's SSL configurations will be respected when
  47. // establishing a TLS connection.
  48. std::unique_ptr<ProxyResolvingClientSocket> CreateSocket(
  49. const GURL& url,
  50. const net::NetworkIsolationKey& network_isolation_key,
  51. bool use_tls);
  52. private:
  53. std::unique_ptr<net::HttpNetworkSession> network_session_;
  54. std::unique_ptr<net::CommonConnectJobParams> common_connect_job_params_;
  55. raw_ptr<net::URLRequestContext> request_context_;
  56. std::unique_ptr<net::ConnectJobFactory> connect_job_factory_ =
  57. std::make_unique<net::ConnectJobFactory>();
  58. };
  59. } // namespace network
  60. #endif // SERVICES_NETWORK_PROXY_RESOLVING_CLIENT_SOCKET_FACTORY_H_