Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / net / socket / client_socket_pool_manager_impl.h
blob8f6e618d2e1b157a22361999b0da2146f74af29c
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_histograms.h"
19 #include "net/socket/client_socket_pool_manager.h"
21 namespace net {
23 class CertVerifier;
24 class ClientSocketFactory;
25 class ClientSocketPoolHistograms;
26 class HttpProxyClientSocketPool;
27 class HostResolver;
28 class NetLog;
29 class ServerBoundCertService;
30 class ProxyService;
31 class SOCKSClientSocketPool;
32 class SSLClientSocketPool;
33 class SSLConfigService;
34 class TransportClientSocketPool;
35 class TransportSecurityState;
37 namespace internal {
39 // A helper class for auto-deleting Values in the destructor.
40 template <typename Key, typename Value>
41 class OwnedPoolMap : public std::map<Key, Value> {
42 public:
43 OwnedPoolMap() {
44 COMPILE_ASSERT(base::is_pointer<Value>::value,
45 value_must_be_a_pointer);
48 ~OwnedPoolMap() {
49 STLDeleteValues(this);
53 } // namespace internal
55 class ClientSocketPoolManagerImpl : public base::NonThreadSafe,
56 public ClientSocketPoolManager,
57 public CertDatabase::Observer {
58 public:
59 ClientSocketPoolManagerImpl(NetLog* net_log,
60 ClientSocketFactory* socket_factory,
61 HostResolver* host_resolver,
62 CertVerifier* cert_verifier,
63 ServerBoundCertService* server_bound_cert_service,
64 TransportSecurityState* transport_security_state,
65 const std::string& ssl_session_cache_shard,
66 ProxyService* proxy_service,
67 SSLConfigService* ssl_config_service,
68 HttpNetworkSession::SocketPoolType pool_type);
69 virtual ~ClientSocketPoolManagerImpl();
71 virtual void FlushSocketPoolsWithError(int error) OVERRIDE;
72 virtual void CloseIdleSockets() OVERRIDE;
74 virtual TransportClientSocketPool* GetTransportSocketPool() OVERRIDE;
76 virtual SSLClientSocketPool* GetSSLSocketPool() OVERRIDE;
78 virtual SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy(
79 const HostPortPair& socks_proxy) OVERRIDE;
81 virtual HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy(
82 const HostPortPair& http_proxy) OVERRIDE;
84 virtual SSLClientSocketPool* GetSocketPoolForSSLWithProxy(
85 const HostPortPair& proxy_server) OVERRIDE;
87 // Creates a Value summary of the state of the socket pools. The caller is
88 // responsible for deleting the returned value.
89 virtual base::Value* SocketPoolInfoToValue() const OVERRIDE;
91 // CertDatabase::Observer methods:
92 virtual void OnCertAdded(const X509Certificate* cert) OVERRIDE;
93 virtual void OnCertTrustChanged(const X509Certificate* cert) OVERRIDE;
95 private:
96 typedef internal::OwnedPoolMap<HostPortPair, TransportClientSocketPool*>
97 TransportSocketPoolMap;
98 typedef internal::OwnedPoolMap<HostPortPair, SOCKSClientSocketPool*>
99 SOCKSSocketPoolMap;
100 typedef internal::OwnedPoolMap<HostPortPair, HttpProxyClientSocketPool*>
101 HTTPProxySocketPoolMap;
102 typedef internal::OwnedPoolMap<HostPortPair, SSLClientSocketPool*>
103 SSLSocketPoolMap;
105 NetLog* const net_log_;
106 ClientSocketFactory* const socket_factory_;
107 HostResolver* const host_resolver_;
108 CertVerifier* const cert_verifier_;
109 ServerBoundCertService* const server_bound_cert_service_;
110 TransportSecurityState* const transport_security_state_;
111 const std::string ssl_session_cache_shard_;
112 ProxyService* const proxy_service_;
113 const scoped_refptr<SSLConfigService> ssl_config_service_;
114 const HttpNetworkSession::SocketPoolType pool_type_;
116 // Note: this ordering is important.
118 ClientSocketPoolHistograms transport_pool_histograms_;
119 scoped_ptr<TransportClientSocketPool> transport_socket_pool_;
121 ClientSocketPoolHistograms ssl_pool_histograms_;
122 scoped_ptr<SSLClientSocketPool> ssl_socket_pool_;
124 ClientSocketPoolHistograms transport_for_socks_pool_histograms_;
125 TransportSocketPoolMap transport_socket_pools_for_socks_proxies_;
127 ClientSocketPoolHistograms socks_pool_histograms_;
128 SOCKSSocketPoolMap socks_socket_pools_;
130 ClientSocketPoolHistograms transport_for_http_proxy_pool_histograms_;
131 TransportSocketPoolMap transport_socket_pools_for_http_proxies_;
133 ClientSocketPoolHistograms transport_for_https_proxy_pool_histograms_;
134 TransportSocketPoolMap transport_socket_pools_for_https_proxies_;
136 ClientSocketPoolHistograms ssl_for_https_proxy_pool_histograms_;
137 SSLSocketPoolMap ssl_socket_pools_for_https_proxies_;
139 ClientSocketPoolHistograms http_proxy_pool_histograms_;
140 HTTPProxySocketPoolMap http_proxy_socket_pools_;
142 ClientSocketPoolHistograms ssl_socket_pool_for_proxies_histograms_;
143 SSLSocketPoolMap ssl_socket_pools_for_proxies_;
145 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolManagerImpl);
148 } // namespace net
150 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_