| 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 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ |
| 6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ | 6 #define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
| 16 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 17 #include "net/http/http_auth.h" | 18 #include "net/http/http_auth.h" |
| 18 #include "net/http/http_response_info.h" | 19 #include "net/http/http_response_info.h" |
| 19 #include "net/http/proxy_client_socket.h" | 20 #include "net/http/proxy_client_socket.h" |
| 20 #include "net/socket/client_socket_pool.h" | 21 #include "net/socket/client_socket_pool.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 44 public: | 45 public: |
| 45 HttpProxySocketParams( | 46 HttpProxySocketParams( |
| 46 const scoped_refptr<TransportSocketParams>& transport_params, | 47 const scoped_refptr<TransportSocketParams>& transport_params, |
| 47 const scoped_refptr<SSLSocketParams>& ssl_params, | 48 const scoped_refptr<SSLSocketParams>& ssl_params, |
| 48 const GURL& request_url, | 49 const GURL& request_url, |
| 49 const std::string& user_agent, | 50 const std::string& user_agent, |
| 50 const HostPortPair& endpoint, | 51 const HostPortPair& endpoint, |
| 51 HttpAuthCache* http_auth_cache, | 52 HttpAuthCache* http_auth_cache, |
| 52 HttpAuthHandlerFactory* http_auth_handler_factory, | 53 HttpAuthHandlerFactory* http_auth_handler_factory, |
| 53 SpdySessionPool* spdy_session_pool, | 54 SpdySessionPool* spdy_session_pool, |
| 54 bool tunnel); | 55 bool tunnel, |
| 56 const base::Callback<void(const HostPortPair&, HttpRequestHeaders*)>& |
| 57 before_proxy_tunnel_request_callback); |
| 55 | 58 |
| 56 const scoped_refptr<TransportSocketParams>& transport_params() const { | 59 const scoped_refptr<TransportSocketParams>& transport_params() const { |
| 57 return transport_params_; | 60 return transport_params_; |
| 58 } | 61 } |
| 59 const scoped_refptr<SSLSocketParams>& ssl_params() const { | 62 const scoped_refptr<SSLSocketParams>& ssl_params() const { |
| 60 return ssl_params_; | 63 return ssl_params_; |
| 61 } | 64 } |
| 62 const GURL& request_url() const { return request_url_; } | 65 const GURL& request_url() const { return request_url_; } |
| 63 const std::string& user_agent() const { return user_agent_; } | 66 const std::string& user_agent() const { return user_agent_; } |
| 64 const HostPortPair& endpoint() const { return endpoint_; } | 67 const HostPortPair& endpoint() const { return endpoint_; } |
| 65 HttpAuthCache* http_auth_cache() const { return http_auth_cache_; } | 68 HttpAuthCache* http_auth_cache() const { return http_auth_cache_; } |
| 66 HttpAuthHandlerFactory* http_auth_handler_factory() const { | 69 HttpAuthHandlerFactory* http_auth_handler_factory() const { |
| 67 return http_auth_handler_factory_; | 70 return http_auth_handler_factory_; |
| 68 } | 71 } |
| 69 SpdySessionPool* spdy_session_pool() { | 72 SpdySessionPool* spdy_session_pool() { |
| 70 return spdy_session_pool_; | 73 return spdy_session_pool_; |
| 71 } | 74 } |
| 72 const HostResolver::RequestInfo& destination() const; | 75 const HostResolver::RequestInfo& destination() const; |
| 73 bool tunnel() const { return tunnel_; } | 76 bool tunnel() const { return tunnel_; } |
| 74 bool ignore_limits() const { return ignore_limits_; } | 77 bool ignore_limits() const { return ignore_limits_; } |
| 75 | 78 |
| 79 const base::Callback<void(const HostPortPair&, HttpRequestHeaders*)>& |
| 80 before_proxy_tunnel_request_callback() const { |
| 81 return before_proxy_tunnel_request_callback_; |
| 82 } |
| 83 |
| 76 private: | 84 private: |
| 77 friend class base::RefCounted<HttpProxySocketParams>; | 85 friend class base::RefCounted<HttpProxySocketParams>; |
| 78 ~HttpProxySocketParams(); | 86 ~HttpProxySocketParams(); |
| 79 | 87 |
| 80 const scoped_refptr<TransportSocketParams> transport_params_; | 88 const scoped_refptr<TransportSocketParams> transport_params_; |
| 81 const scoped_refptr<SSLSocketParams> ssl_params_; | 89 const scoped_refptr<SSLSocketParams> ssl_params_; |
| 82 SpdySessionPool* spdy_session_pool_; | 90 SpdySessionPool* spdy_session_pool_; |
| 83 const GURL request_url_; | 91 const GURL request_url_; |
| 84 const std::string user_agent_; | 92 const std::string user_agent_; |
| 85 const HostPortPair endpoint_; | 93 const HostPortPair endpoint_; |
| 86 HttpAuthCache* const http_auth_cache_; | 94 HttpAuthCache* const http_auth_cache_; |
| 87 HttpAuthHandlerFactory* const http_auth_handler_factory_; | 95 HttpAuthHandlerFactory* const http_auth_handler_factory_; |
| 88 const bool tunnel_; | 96 const bool tunnel_; |
| 89 bool ignore_limits_; | 97 bool ignore_limits_; |
| 98 base::Callback<void(const HostPortPair&, HttpRequestHeaders*)> |
| 99 before_proxy_tunnel_request_callback_; |
| 90 | 100 |
| 91 DISALLOW_COPY_AND_ASSIGN(HttpProxySocketParams); | 101 DISALLOW_COPY_AND_ASSIGN(HttpProxySocketParams); |
| 92 }; | 102 }; |
| 93 | 103 |
| 94 // HttpProxyConnectJob optionally establishes a tunnel through the proxy | 104 // HttpProxyConnectJob optionally establishes a tunnel through the proxy |
| 95 // server after connecting the underlying transport socket. | 105 // server after connecting the underlying transport socket. |
| 96 class HttpProxyConnectJob : public ConnectJob { | 106 class HttpProxyConnectJob : public ConnectJob { |
| 97 public: | 107 public: |
| 98 HttpProxyConnectJob(const std::string& group_name, | 108 HttpProxyConnectJob(const std::string& group_name, |
| 99 RequestPriority priority, | 109 RequestPriority priority, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 public: | 189 public: |
| 180 typedef HttpProxySocketParams SocketParams; | 190 typedef HttpProxySocketParams SocketParams; |
| 181 | 191 |
| 182 HttpProxyClientSocketPool( | 192 HttpProxyClientSocketPool( |
| 183 int max_sockets, | 193 int max_sockets, |
| 184 int max_sockets_per_group, | 194 int max_sockets_per_group, |
| 185 ClientSocketPoolHistograms* histograms, | 195 ClientSocketPoolHistograms* histograms, |
| 186 HostResolver* host_resolver, | 196 HostResolver* host_resolver, |
| 187 TransportClientSocketPool* transport_pool, | 197 TransportClientSocketPool* transport_pool, |
| 188 SSLClientSocketPool* ssl_pool, | 198 SSLClientSocketPool* ssl_pool, |
| 199 const base::Callback<void(const HostPortPair&, HttpRequestHeaders*)>& |
| 200 before_proxy_tunnel_request_callback, |
| 189 NetLog* net_log); | 201 NetLog* net_log); |
| 190 | 202 |
| 191 virtual ~HttpProxyClientSocketPool(); | 203 virtual ~HttpProxyClientSocketPool(); |
| 192 | 204 |
| 193 // ClientSocketPool implementation. | 205 // ClientSocketPool implementation. |
| 194 virtual int RequestSocket(const std::string& group_name, | 206 virtual int RequestSocket(const std::string& group_name, |
| 195 const void* connect_params, | 207 const void* connect_params, |
| 196 RequestPriority priority, | 208 RequestPriority priority, |
| 197 ClientSocketHandle* handle, | 209 ClientSocketHandle* handle, |
| 198 const CompletionCallback& callback, | 210 const CompletionCallback& callback, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 256 |
| 245 private: | 257 private: |
| 246 typedef ClientSocketPoolBase<HttpProxySocketParams> PoolBase; | 258 typedef ClientSocketPoolBase<HttpProxySocketParams> PoolBase; |
| 247 | 259 |
| 248 class HttpProxyConnectJobFactory : public PoolBase::ConnectJobFactory { | 260 class HttpProxyConnectJobFactory : public PoolBase::ConnectJobFactory { |
| 249 public: | 261 public: |
| 250 HttpProxyConnectJobFactory( | 262 HttpProxyConnectJobFactory( |
| 251 TransportClientSocketPool* transport_pool, | 263 TransportClientSocketPool* transport_pool, |
| 252 SSLClientSocketPool* ssl_pool, | 264 SSLClientSocketPool* ssl_pool, |
| 253 HostResolver* host_resolver, | 265 HostResolver* host_resolver, |
| 266 base::Callback<void(const HostPortPair&, HttpRequestHeaders*)> |
| 267 before_proxy_tunnel_request_callback, |
| 254 NetLog* net_log); | 268 NetLog* net_log); |
| 255 | 269 |
| 270 virtual ~HttpProxyConnectJobFactory(); |
| 271 |
| 256 // ClientSocketPoolBase::ConnectJobFactory methods. | 272 // ClientSocketPoolBase::ConnectJobFactory methods. |
| 257 virtual scoped_ptr<ConnectJob> NewConnectJob( | 273 virtual scoped_ptr<ConnectJob> NewConnectJob( |
| 258 const std::string& group_name, | 274 const std::string& group_name, |
| 259 const PoolBase::Request& request, | 275 const PoolBase::Request& request, |
| 260 ConnectJob::Delegate* delegate) const OVERRIDE; | 276 ConnectJob::Delegate* delegate) const OVERRIDE; |
| 261 | 277 |
| 262 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 278 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; |
| 263 | 279 |
| 264 private: | 280 private: |
| 265 TransportClientSocketPool* const transport_pool_; | 281 TransportClientSocketPool* const transport_pool_; |
| 266 SSLClientSocketPool* const ssl_pool_; | 282 SSLClientSocketPool* const ssl_pool_; |
| 267 HostResolver* const host_resolver_; | 283 HostResolver* const host_resolver_; |
| 284 base::Callback<void(const HostPortPair&, HttpRequestHeaders*)> |
| 285 before_proxy_tunnel_request_callback_; |
| 268 NetLog* net_log_; | 286 NetLog* net_log_; |
| 269 base::TimeDelta timeout_; | 287 base::TimeDelta timeout_; |
| 270 | 288 |
| 271 DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJobFactory); | 289 DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJobFactory); |
| 272 }; | 290 }; |
| 273 | 291 |
| 274 TransportClientSocketPool* const transport_pool_; | 292 TransportClientSocketPool* const transport_pool_; |
| 275 SSLClientSocketPool* const ssl_pool_; | 293 SSLClientSocketPool* const ssl_pool_; |
| 276 PoolBase base_; | 294 PoolBase base_; |
| 277 | 295 |
| 278 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocketPool); | 296 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocketPool); |
| 279 }; | 297 }; |
| 280 | 298 |
| 281 } // namespace net | 299 } // namespace net |
| 282 | 300 |
| 283 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ | 301 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |