Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // ClientSocketPoolManager manages access to all ClientSocketPools. It's a | 5 // ClientSocketPoolManager manages access to all ClientSocketPools. It's a |
| 6 // simple container for all of them. Most importantly, it handles the lifetime | 6 // simple container for all of them. Most importantly, it handles the lifetime |
| 7 // and destruction order properly. | 7 // and destruction order properly. |
| 8 | 8 |
| 9 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ | 9 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ |
| 10 #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ | 10 #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 class SSLClientSocketPool; | 37 class SSLClientSocketPool; |
| 38 | 38 |
| 39 struct SSLConfig; | 39 struct SSLConfig; |
| 40 | 40 |
| 41 // This should rather be a simple constant but Windows shared libs doesn't | 41 // This should rather be a simple constant but Windows shared libs doesn't |
| 42 // really offer much flexiblity in exporting contants. | 42 // really offer much flexiblity in exporting contants. |
| 43 enum DefaultMaxValues { kDefaultMaxSocketsPerProxyServer = 32 }; | 43 enum DefaultMaxValues { kDefaultMaxSocketsPerProxyServer = 32 }; |
| 44 | 44 |
| 45 class NET_EXPORT_PRIVATE ClientSocketPoolManager { | 45 class NET_EXPORT_PRIVATE ClientSocketPoolManager { |
| 46 public: | 46 public: |
| 47 enum SocketGroupType { | |
| 48 SSL_GROUP, // For all TLS sockets. | |
| 49 NORMAL_GROUP, // For normal HTTP sockets. | |
| 50 FTP_GROUP // For FTP sockets. | |
|
mmenke
2015/04/07 19:24:16
optional: Maybe "For FTP sockets" -> "For FTP soc
Ryan Hamilton
2015/04/08 03:44:46
Done.
| |
| 51 }; | |
| 52 | |
| 53 // Returns the correct socket group type for |scheme|. | |
| 54 static SocketGroupType GroupTypeFromScheme(const std::string& scheme); | |
| 55 | |
| 47 ClientSocketPoolManager(); | 56 ClientSocketPoolManager(); |
| 48 virtual ~ClientSocketPoolManager(); | 57 virtual ~ClientSocketPoolManager(); |
| 49 | 58 |
| 50 // The setter methods below affect only newly created socket pools after the | 59 // The setter methods below affect only newly created socket pools after the |
| 51 // methods are called. Normally they should be called at program startup | 60 // methods are called. Normally they should be called at program startup |
| 52 // before any ClientSocketPoolManagerImpl is created. | 61 // before any ClientSocketPoolManagerImpl is created. |
| 53 static int max_sockets_per_pool(HttpNetworkSession::SocketPoolType pool_type); | 62 static int max_sockets_per_pool(HttpNetworkSession::SocketPoolType pool_type); |
| 54 static void set_max_sockets_per_pool( | 63 static void set_max_sockets_per_pool( |
| 55 HttpNetworkSession::SocketPoolType pool_type, | 64 HttpNetworkSession::SocketPoolType pool_type, |
| 56 int socket_count); | 65 int socket_count); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 82 virtual base::Value* SocketPoolInfoToValue() const = 0; | 91 virtual base::Value* SocketPoolInfoToValue() const = 0; |
| 83 }; | 92 }; |
| 84 | 93 |
| 85 // A helper method that uses the passed in proxy information to initialize a | 94 // A helper method that uses the passed in proxy information to initialize a |
| 86 // ClientSocketHandle with the relevant socket pool. Use this method for | 95 // ClientSocketHandle with the relevant socket pool. Use this method for |
| 87 // HTTP/HTTPS requests. |ssl_config_for_origin| is only used if the request | 96 // HTTP/HTTPS requests. |ssl_config_for_origin| is only used if the request |
| 88 // uses SSL and |ssl_config_for_proxy| is used if the proxy server is HTTPS. | 97 // uses SSL and |ssl_config_for_proxy| is used if the proxy server is HTTPS. |
| 89 // |resolution_callback| will be invoked after the the hostname is | 98 // |resolution_callback| will be invoked after the the hostname is |
| 90 // resolved. If |resolution_callback| does not return OK, then the | 99 // resolved. If |resolution_callback| does not return OK, then the |
| 91 // connection will be aborted with that value. | 100 // connection will be aborted with that value. |
| 101 // If |want_spdy_over_ssl| is true, then after the SSL handshake is complete, | |
| 102 // SPDY must have been negotiationed or else it will be considered an error. | |
|
mmenke
2015/04/07 19:24:16
negotiationed -> negotiated
Ryan Hamilton
2015/04/08 03:44:46
Done.
| |
| 103 // If |force_spdy_over_ssl| is true, then SPDY will be assumed to be supported | |
| 104 // for all SSL connections. | |
| 105 // TODO(rch): remove force_spdy_over_ssl. | |
| 92 int InitSocketHandleForHttpRequest( | 106 int InitSocketHandleForHttpRequest( |
| 93 const GURL& request_url, | 107 ClientSocketPoolManager::SocketGroupType group_type, |
| 108 const HostPortPair& endpoint, | |
| 94 const HttpRequestHeaders& request_extra_headers, | 109 const HttpRequestHeaders& request_extra_headers, |
| 95 int request_load_flags, | 110 int request_load_flags, |
| 96 RequestPriority request_priority, | 111 RequestPriority request_priority, |
| 97 HttpNetworkSession* session, | 112 HttpNetworkSession* session, |
| 98 const ProxyInfo& proxy_info, | 113 const ProxyInfo& proxy_info, |
| 99 bool force_spdy_over_ssl, | 114 bool force_spdy_over_ssl, |
| 100 bool want_spdy_over_npn, | 115 bool want_spdy_over_npn, |
| 101 const SSLConfig& ssl_config_for_origin, | 116 const SSLConfig& ssl_config_for_origin, |
| 102 const SSLConfig& ssl_config_for_proxy, | 117 const SSLConfig& ssl_config_for_proxy, |
| 103 PrivacyMode privacy_mode, | 118 PrivacyMode privacy_mode, |
| 104 const BoundNetLog& net_log, | 119 const BoundNetLog& net_log, |
| 105 ClientSocketHandle* socket_handle, | 120 ClientSocketHandle* socket_handle, |
| 106 const OnHostResolutionCallback& resolution_callback, | 121 const OnHostResolutionCallback& resolution_callback, |
| 107 const CompletionCallback& callback); | 122 const CompletionCallback& callback); |
| 108 | 123 |
| 109 // A helper method that uses the passed in proxy information to initialize a | 124 // A helper method that uses the passed in proxy information to initialize a |
| 110 // ClientSocketHandle with the relevant socket pool. Use this method for | 125 // ClientSocketHandle with the relevant socket pool. Use this method for |
| 111 // HTTP/HTTPS requests for WebSocket handshake. | 126 // HTTP/HTTPS requests for WebSocket handshake. |
| 112 // |ssl_config_for_origin| is only used if the request | 127 // |ssl_config_for_origin| is only used if the request |
| 113 // uses SSL and |ssl_config_for_proxy| is used if the proxy server is HTTPS. | 128 // uses SSL and |ssl_config_for_proxy| is used if the proxy server is HTTPS. |
| 114 // |resolution_callback| will be invoked after the the hostname is | 129 // |resolution_callback| will be invoked after the the hostname is |
| 115 // resolved. If |resolution_callback| does not return OK, then the | 130 // resolved. If |resolution_callback| does not return OK, then the |
| 116 // connection will be aborted with that value. | 131 // connection will be aborted with that value. |
| 117 // This function uses WEBSOCKET_SOCKET_POOL socket pools. | 132 // This function uses WEBSOCKET_SOCKET_POOL socket pools. |
| 118 int InitSocketHandleForWebSocketRequest( | 133 int InitSocketHandleForWebSocketRequest( |
| 119 const GURL& request_url, | 134 ClientSocketPoolManager::SocketGroupType group_type, |
| 135 const HostPortPair& endpoint, | |
| 120 const HttpRequestHeaders& request_extra_headers, | 136 const HttpRequestHeaders& request_extra_headers, |
| 121 int request_load_flags, | 137 int request_load_flags, |
| 122 RequestPriority request_priority, | 138 RequestPriority request_priority, |
| 123 HttpNetworkSession* session, | 139 HttpNetworkSession* session, |
| 124 const ProxyInfo& proxy_info, | 140 const ProxyInfo& proxy_info, |
| 125 bool force_spdy_over_ssl, | 141 bool force_spdy_over_ssl, |
| 126 bool want_spdy_over_npn, | 142 bool want_spdy_over_npn, |
| 127 const SSLConfig& ssl_config_for_origin, | 143 const SSLConfig& ssl_config_for_origin, |
| 128 const SSLConfig& ssl_config_for_proxy, | 144 const SSLConfig& ssl_config_for_proxy, |
| 129 PrivacyMode privacy_mode, | 145 PrivacyMode privacy_mode, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 158 const SSLConfig& ssl_config_for_origin, | 174 const SSLConfig& ssl_config_for_origin, |
| 159 const SSLConfig& ssl_config_for_proxy, | 175 const SSLConfig& ssl_config_for_proxy, |
| 160 PrivacyMode privacy_mode, | 176 PrivacyMode privacy_mode, |
| 161 const BoundNetLog& net_log, | 177 const BoundNetLog& net_log, |
| 162 ClientSocketHandle* socket_handle, | 178 ClientSocketHandle* socket_handle, |
| 163 const CompletionCallback& callback); | 179 const CompletionCallback& callback); |
| 164 | 180 |
| 165 // Similar to InitSocketHandleForHttpRequest except that it initiates the | 181 // Similar to InitSocketHandleForHttpRequest except that it initiates the |
| 166 // desired number of preconnect streams from the relevant socket pool. | 182 // desired number of preconnect streams from the relevant socket pool. |
| 167 int PreconnectSocketsForHttpRequest( | 183 int PreconnectSocketsForHttpRequest( |
| 168 const GURL& request_url, | 184 ClientSocketPoolManager::SocketGroupType group_type, |
| 185 const HostPortPair& endpoint, | |
| 169 const HttpRequestHeaders& request_extra_headers, | 186 const HttpRequestHeaders& request_extra_headers, |
| 170 int request_load_flags, | 187 int request_load_flags, |
| 171 RequestPriority request_priority, | 188 RequestPriority request_priority, |
| 172 HttpNetworkSession* session, | 189 HttpNetworkSession* session, |
| 173 const ProxyInfo& proxy_info, | 190 const ProxyInfo& proxy_info, |
| 174 bool force_spdy_over_ssl, | 191 bool force_spdy_over_ssl, |
| 175 bool want_spdy_over_npn, | 192 bool want_spdy_over_npn, |
| 176 const SSLConfig& ssl_config_for_origin, | 193 const SSLConfig& ssl_config_for_origin, |
| 177 const SSLConfig& ssl_config_for_proxy, | 194 const SSLConfig& ssl_config_for_proxy, |
| 178 PrivacyMode privacy_mode, | 195 PrivacyMode privacy_mode, |
| 179 const BoundNetLog& net_log, | 196 const BoundNetLog& net_log, |
| 180 int num_preconnect_streams); | 197 int num_preconnect_streams); |
| 181 | 198 |
| 182 } // namespace net | 199 } // namespace net |
| 183 | 200 |
| 184 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ | 201 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_H_ |
| OLD | NEW |