Delete unused downloads page asset.
[chromium-blink-merge.git] / net / socket / client_socket_pool_manager_impl.h
blob2038220a3e2081d13f3975fa8d5f8f96c166afaa
1 // Copyright (c) 2012 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.
5 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_
6 #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_
8 #include <map>
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/stl_util.h"
14 #include "base/template_util.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "net/cert/cert_database.h"
17 #include "net/http/http_network_session.h"
18 #include "net/socket/client_socket_pool_manager.h"
20 namespace net {
22 class CertVerifier;
23 class ChannelIDService;
24 class ClientSocketFactory;
25 class CTVerifier;
26 class HttpProxyClientSocketPool;
27 class HostResolver;
28 class NetLog;
29 class SOCKSClientSocketPool;
30 class SSLClientSocketPool;
31 class SSLConfigService;
32 class TransportClientSocketPool;
33 class TransportSecurityState;
35 namespace internal {
37 // A helper class for auto-deleting Values in the destructor.
38 template <typename Key, typename Value>
39 class OwnedPoolMap : public std::map<Key, Value> {
40 public:
41 OwnedPoolMap() {
42 static_assert(base::is_pointer<Value>::value, "value must be a pointer");
45 ~OwnedPoolMap() {
46 STLDeleteValues(this);
50 } // namespace internal
52 class ClientSocketPoolManagerImpl : public base::NonThreadSafe,
53 public ClientSocketPoolManager,
54 public CertDatabase::Observer {
55 public:
56 ClientSocketPoolManagerImpl(NetLog* net_log,
57 ClientSocketFactory* socket_factory,
58 HostResolver* host_resolver,
59 CertVerifier* cert_verifier,
60 ChannelIDService* channel_id_service,
61 TransportSecurityState* transport_security_state,
62 CTVerifier* cert_transparency_verifier,
63 CertPolicyEnforcer* cert_policy_enforcer,
64 const std::string& ssl_session_cache_shard,
65 SSLConfigService* ssl_config_service,
66 HttpNetworkSession::SocketPoolType pool_type);
67 ~ClientSocketPoolManagerImpl() override;
69 void FlushSocketPoolsWithError(int error) override;
70 void CloseIdleSockets() override;
72 TransportClientSocketPool* GetTransportSocketPool() override;
74 SSLClientSocketPool* GetSSLSocketPool() override;
76 SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy(
77 const HostPortPair& socks_proxy) override;
79 HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy(
80 const HostPortPair& http_proxy) override;
82 SSLClientSocketPool* GetSocketPoolForSSLWithProxy(
83 const HostPortPair& proxy_server) override;
85 // Creates a Value summary of the state of the socket pools.
86 scoped_ptr<base::Value> SocketPoolInfoToValue() const override;
88 // CertDatabase::Observer methods:
89 void OnCertAdded(const X509Certificate* cert) override;
90 void OnCACertChanged(const X509Certificate* cert) override;
92 private:
93 typedef internal::OwnedPoolMap<HostPortPair, TransportClientSocketPool*>
94 TransportSocketPoolMap;
95 typedef internal::OwnedPoolMap<HostPortPair, SOCKSClientSocketPool*>
96 SOCKSSocketPoolMap;
97 typedef internal::OwnedPoolMap<HostPortPair, HttpProxyClientSocketPool*>
98 HTTPProxySocketPoolMap;
99 typedef internal::OwnedPoolMap<HostPortPair, SSLClientSocketPool*>
100 SSLSocketPoolMap;
102 NetLog* const net_log_;
103 ClientSocketFactory* const socket_factory_;
104 HostResolver* const host_resolver_;
105 CertVerifier* const cert_verifier_;
106 ChannelIDService* const channel_id_service_;
107 TransportSecurityState* const transport_security_state_;
108 CTVerifier* const cert_transparency_verifier_;
109 CertPolicyEnforcer* const cert_policy_enforcer_;
110 const std::string ssl_session_cache_shard_;
111 const scoped_refptr<SSLConfigService> ssl_config_service_;
112 const HttpNetworkSession::SocketPoolType pool_type_;
114 // Note: this ordering is important.
116 scoped_ptr<TransportClientSocketPool> transport_socket_pool_;
117 scoped_ptr<SSLClientSocketPool> ssl_socket_pool_;
118 TransportSocketPoolMap transport_socket_pools_for_socks_proxies_;
119 SOCKSSocketPoolMap socks_socket_pools_;
120 TransportSocketPoolMap transport_socket_pools_for_http_proxies_;
121 TransportSocketPoolMap transport_socket_pools_for_https_proxies_;
122 SSLSocketPoolMap ssl_socket_pools_for_https_proxies_;
123 HTTPProxySocketPoolMap http_proxy_socket_pools_;
124 SSLSocketPoolMap ssl_socket_pools_for_proxies_;
126 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolManagerImpl);
129 } // namespace net
131 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_