1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_ 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_ 7 8 #include <map> 9 #include <memory> 10 #include <string> 11 #include <type_traits> 12 13 #include "base/compiler_specific.h" 14 #include "base/threading/thread_checker.h" 15 #include "base/values.h" 16 #include "net/base/net_export.h" 17 #include "net/http/http_network_session.h" 18 #include "net/socket/client_socket_pool_manager.h" 19 #include "net/socket/connect_job.h" 20 21 namespace net { 22 23 class ProxyServer; 24 class ClientSocketPool; 25 26 class NET_EXPORT_PRIVATE ClientSocketPoolManagerImpl 27 : public ClientSocketPoolManager { 28 public: 29 // |websocket_common_connect_job_params| is only used for direct WebSocket 30 // connections (No proxy in use). It's never used if |pool_type| is not 31 // HttpNetworkSession::SocketPoolType::WEBSOCKET_SOCKET_POOL. 32 ClientSocketPoolManagerImpl( 33 const CommonConnectJobParams& common_connect_job_params, 34 const CommonConnectJobParams& websocket_common_connect_job_params, 35 HttpNetworkSession::SocketPoolType pool_type, 36 bool cleanup_on_ip_address_change = true); 37 38 ClientSocketPoolManagerImpl(const ClientSocketPoolManagerImpl&) = delete; 39 ClientSocketPoolManagerImpl& operator=(const ClientSocketPoolManagerImpl&) = 40 delete; 41 42 ~ClientSocketPoolManagerImpl() override; 43 44 void FlushSocketPoolsWithError(int net_error, 45 const char* net_log_reason_utf8) override; 46 void CloseIdleSockets(const char* net_log_reason_utf8) override; 47 48 ClientSocketPool* GetSocketPool(const ProxyServer& proxy_server) override; 49 50 // Creates a Value summary of the state of the socket pools. 51 base::Value SocketPoolInfoToValue() const override; 52 53 private: 54 using SocketPoolMap = 55 std::map<ProxyServer, std::unique_ptr<ClientSocketPool>>; 56 57 const CommonConnectJobParams common_connect_job_params_; 58 // Used only for direct WebSocket connections (i.e., no proxy in use). 59 const CommonConnectJobParams websocket_common_connect_job_params_; 60 61 const HttpNetworkSession::SocketPoolType pool_type_; 62 63 const bool cleanup_on_ip_address_change_; 64 65 SocketPoolMap socket_pools_; 66 67 THREAD_CHECKER(thread_checker_); 68 }; 69 70 } // namespace net 71 72 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_ 73