Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / net / socket / client_socket_pool_manager_impl.h
bloba38cae1a4767bd62523392c4ac6b92631825fdfa
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. The caller is
86 // responsible for deleting the returned value.
87 base::Value* SocketPoolInfoToValue() const override;
89 // CertDatabase::Observer methods:
90 void OnCertAdded(const X509Certificate* cert) override;
91 void OnCACertChanged(const X509Certificate* cert) override;
93 private:
94 typedef internal::OwnedPoolMap<HostPortPair, TransportClientSocketPool*>
95 TransportSocketPoolMap;
96 typedef internal::OwnedPoolMap<HostPortPair, SOCKSClientSocketPool*>
97 SOCKSSocketPoolMap;
98 typedef internal::OwnedPoolMap<HostPortPair, HttpProxyClientSocketPool*>
99 HTTPProxySocketPoolMap;
100 typedef internal::OwnedPoolMap<HostPortPair, SSLClientSocketPool*>
101 SSLSocketPoolMap;
103 NetLog* const net_log_;
104 ClientSocketFactory* const socket_factory_;
105 HostResolver* const host_resolver_;
106 CertVerifier* const cert_verifier_;
107 ChannelIDService* const channel_id_service_;
108 TransportSecurityState* const transport_security_state_;
109 CTVerifier* const cert_transparency_verifier_;
110 CertPolicyEnforcer* const cert_policy_enforcer_;
111 const std::string ssl_session_cache_shard_;
112 const scoped_refptr<SSLConfigService> ssl_config_service_;
113 const HttpNetworkSession::SocketPoolType pool_type_;
115 // Note: this ordering is important.
117 scoped_ptr<TransportClientSocketPool> transport_socket_pool_;
118 scoped_ptr<SSLClientSocketPool> ssl_socket_pool_;
119 TransportSocketPoolMap transport_socket_pools_for_socks_proxies_;
120 SOCKSSocketPoolMap socks_socket_pools_;
121 TransportSocketPoolMap transport_socket_pools_for_http_proxies_;
122 TransportSocketPoolMap transport_socket_pools_for_https_proxies_;
123 SSLSocketPoolMap ssl_socket_pools_for_https_proxies_;
124 HTTPProxySocketPoolMap http_proxy_socket_pools_;
125 SSLSocketPoolMap ssl_socket_pools_for_proxies_;
127 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolManagerImpl);
130 } // namespace net
132 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_