Make SocketPool constructor take a CommonConnectJobParams*

Previously, it took a bunch of individual parameters, which was getting
a bit excessive. Also, CommonConnectJobParams are now created by the
HttpNetworkSession.

This will hopefully make a couple refactors a bit simpler:

*  Switching over ProxyResolvingClientSocket to not need its own socket
pools (It will need its own CommonConnectJobParams).

*  Slimming down SocketParams classes by adding more stuff to
CommonConnectJobParams (Like the SpdySessionPool and QUIC globals).

* Separating the WebSocket and Transport SocketPools.

Bug: 921369
Change-Id: I23b9011a9c5b9dafa0eeb1e63f585417ffc0c355
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529697
Commit-Queue: Matt Menke <[email protected]>
Reviewed-by: David Benjamin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#642407}
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index 771dbf6..0ddc5c7 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -41,26 +41,13 @@
 
 namespace {
 
-std::unique_ptr<ClientSocketPoolManager> CreateSocketPoolManager(
-    HttpNetworkSession::SocketPoolType pool_type,
+SSLClientSocketContext CreateClientSocketContext(
     const HttpNetworkSession::Context& context,
-    SSLClientSessionCache* ssl_client_session_cache,
-    SSLClientSessionCache* ssl_client_session_cache_privacy_mode,
-    WebSocketEndpointLockManager* websocket_endpoint_lock_manager) {
-  // TODO(yutak): Differentiate WebSocket pool manager and allow more
-  // simultaneous connections for WebSockets.
-  return std::make_unique<ClientSocketPoolManagerImpl>(
-      context.net_log,
-      context.client_socket_factory ? context.client_socket_factory
-                                    : ClientSocketFactory::GetDefaultFactory(),
-      context.socket_performance_watcher_factory,
-      context.network_quality_estimator, context.host_resolver,
+    SSLClientSessionCache* ssl_client_session_cache) {
+  return SSLClientSocketContext(
       context.cert_verifier, context.channel_id_service,
       context.transport_security_state, context.cert_transparency_verifier,
-      context.ct_policy_enforcer, ssl_client_session_cache,
-      ssl_client_session_cache_privacy_mode, context.ssl_config_service,
-      websocket_endpoint_lock_manager, context.proxy_delegate,
-      context.http_user_agent_settings, pool_type);
+      context.ct_policy_enforcer, ssl_client_session_cache);
 }
 
 }  // unnamed namespace
@@ -267,18 +254,18 @@
   DCHECK(ssl_config_service_);
   CHECK(http_server_properties_);
 
-  normal_socket_pool_manager_ = CreateSocketPoolManager(
-      NORMAL_SOCKET_POOL, context, &ssl_client_session_cache_,
-      &ssl_client_session_cache_privacy_mode_,
-      &websocket_endpoint_lock_manager_);
-  websocket_socket_pool_manager_ = CreateSocketPoolManager(
-      WEBSOCKET_SOCKET_POOL, context, &ssl_client_session_cache_,
-      &ssl_client_session_cache_privacy_mode_,
-      &websocket_endpoint_lock_manager_);
+  normal_socket_pool_manager_ = std::make_unique<ClientSocketPoolManagerImpl>(
+      CreateCommonConnectJobParams(false /* for_websockets */),
+      CreateCommonConnectJobParams(true /* for_websockets */),
+      context_.ssl_config_service, NORMAL_SOCKET_POOL);
+  websocket_socket_pool_manager_ =
+      std::make_unique<ClientSocketPoolManagerImpl>(
+          CreateCommonConnectJobParams(false /* for_websockets */),
+          CreateCommonConnectJobParams(true /* for_websockets */),
+          context_.ssl_config_service, WEBSOCKET_SOCKET_POOL);
 
-  if (params_.enable_http2) {
+  if (params_.enable_http2)
     next_protos_.push_back(kProtoHTTP2);
-  }
 
   next_protos_.push_back(kProtoHTTP11);
 
@@ -498,6 +485,23 @@
   ssl_client_session_cache_privacy_mode_.Flush();
 }
 
+CommonConnectJobParams HttpNetworkSession::CreateCommonConnectJobParams(
+    bool for_websockets) {
+  // Use null websocket_endpoint_lock_manager, which is only set for WebSockets,
+  // and only when not using a proxy.
+  return CommonConnectJobParams(
+      context_.client_socket_factory ? context_.client_socket_factory
+                                     : ClientSocketFactory::GetDefaultFactory(),
+      context_.host_resolver, context_.proxy_delegate,
+      context_.http_user_agent_settings,
+      CreateClientSocketContext(context_, &ssl_client_session_cache_),
+      CreateClientSocketContext(context_,
+                                &ssl_client_session_cache_privacy_mode_),
+      context_.socket_performance_watcher_factory,
+      context_.network_quality_estimator, context_.net_log,
+      for_websockets ? &websocket_endpoint_lock_manager_ : nullptr);
+}
+
 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager(
     SocketPoolType pool_type) {
   switch (pool_type) {