OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
16 #include "net/http/http_auth.h" | 16 #include "net/http/http_auth.h" |
17 #include "net/socket/client_socket_pool_base.h" | 17 #include "net/socket/client_socket_pool_base.h" |
18 #include "net/socket/client_socket_pool_histograms.h" | 18 #include "net/socket/client_socket_pool_histograms.h" |
19 #include "net/socket/client_socket_pool.h" | 19 #include "net/socket/client_socket_pool.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 class HostResolver; | 23 class HostResolver; |
24 class HttpAuthCache; | 24 class HttpAuthCache; |
25 class HttpAuthHandlerFactory; | 25 class HttpAuthHandlerFactory; |
26 class SSLClientSocketPool; | 26 class SSLClientSocketPool; |
27 class SSLSocketParams; | 27 class SSLSocketParams; |
| 28 class SpdySessionPool; |
| 29 class SpdySettingsStorage; |
| 30 class SpdyStream; |
28 class TCPClientSocketPool; | 31 class TCPClientSocketPool; |
29 class TCPSocketParams; | 32 class TCPSocketParams; |
30 | 33 |
31 // HttpProxySocketParams only needs the socket params for one of the proxy | 34 // HttpProxySocketParams only needs the socket params for one of the proxy |
32 // types. The other param must be NULL. When using an HTTP Proxy, | 35 // types. The other param must be NULL. When using an HTTP Proxy, |
33 // |tcp_params| must be set. When using an HTTPS Proxy, |ssl_params| | 36 // |tcp_params| must be set. When using an HTTPS Proxy, |ssl_params| |
34 // must be set. | 37 // must be set. |
35 class HttpProxySocketParams : public base::RefCounted<HttpProxySocketParams> { | 38 class HttpProxySocketParams : public base::RefCounted<HttpProxySocketParams> { |
36 public: | 39 public: |
37 HttpProxySocketParams(const scoped_refptr<TCPSocketParams>& tcp_params, | 40 HttpProxySocketParams(const scoped_refptr<TCPSocketParams>& tcp_params, |
38 const scoped_refptr<SSLSocketParams>& ssl_params, | 41 const scoped_refptr<SSLSocketParams>& ssl_params, |
39 const GURL& request_url, | 42 const GURL& request_url, |
40 const std::string& user_agent, | 43 const std::string& user_agent, |
41 HostPortPair endpoint, | 44 HostPortPair endpoint, |
42 HttpAuthCache* http_auth_cache, | 45 HttpAuthCache* http_auth_cache, |
43 HttpAuthHandlerFactory* http_auth_handler_factory, | 46 HttpAuthHandlerFactory* http_auth_handler_factory, |
| 47 SpdySessionPool* spdy_session_pool, |
| 48 SpdySettingsStorage* spdy_settings, |
44 bool tunnel); | 49 bool tunnel); |
45 | 50 |
46 const scoped_refptr<TCPSocketParams>& tcp_params() const { | 51 const scoped_refptr<TCPSocketParams>& tcp_params() const { |
47 return tcp_params_; | 52 return tcp_params_; |
48 } | 53 } |
49 const scoped_refptr<SSLSocketParams>& ssl_params() const { | 54 const scoped_refptr<SSLSocketParams>& ssl_params() const { |
50 return ssl_params_; | 55 return ssl_params_; |
51 } | 56 } |
52 const GURL& request_url() const { return request_url_; } | 57 const GURL& request_url() const { return request_url_; } |
53 const std::string& user_agent() const { return user_agent_; } | 58 const std::string& user_agent() const { return user_agent_; } |
54 const HostPortPair& endpoint() const { return endpoint_; } | 59 const HostPortPair& endpoint() const { return endpoint_; } |
55 HttpAuthCache* http_auth_cache() const { return http_auth_cache_; } | 60 HttpAuthCache* http_auth_cache() const { return http_auth_cache_; } |
56 HttpAuthHandlerFactory* http_auth_handler_factory() const { | 61 HttpAuthHandlerFactory* http_auth_handler_factory() const { |
57 return http_auth_handler_factory_; | 62 return http_auth_handler_factory_; |
58 } | 63 } |
| 64 SpdySessionPool* spdy_session_pool() { |
| 65 return spdy_session_pool_; |
| 66 } |
| 67 SpdySettingsStorage* spdy_settings() { |
| 68 return spdy_settings_; |
| 69 } |
59 const HostResolver::RequestInfo& destination() const; | 70 const HostResolver::RequestInfo& destination() const; |
60 bool tunnel() const { return tunnel_; } | 71 bool tunnel() const { return tunnel_; } |
61 | 72 |
62 private: | 73 private: |
63 friend class base::RefCounted<HttpProxySocketParams>; | 74 friend class base::RefCounted<HttpProxySocketParams>; |
64 ~HttpProxySocketParams(); | 75 ~HttpProxySocketParams(); |
65 | 76 |
66 const scoped_refptr<TCPSocketParams> tcp_params_; | 77 const scoped_refptr<TCPSocketParams> tcp_params_; |
67 const scoped_refptr<SSLSocketParams> ssl_params_; | 78 const scoped_refptr<SSLSocketParams> ssl_params_; |
| 79 SpdySessionPool* spdy_session_pool_; |
| 80 SpdySettingsStorage* spdy_settings_; |
68 const GURL request_url_; | 81 const GURL request_url_; |
69 const std::string user_agent_; | 82 const std::string user_agent_; |
70 const HostPortPair endpoint_; | 83 const HostPortPair endpoint_; |
71 HttpAuthCache* const http_auth_cache_; | 84 HttpAuthCache* const http_auth_cache_; |
72 HttpAuthHandlerFactory* const http_auth_handler_factory_; | 85 HttpAuthHandlerFactory* const http_auth_handler_factory_; |
73 const bool tunnel_; | 86 const bool tunnel_; |
74 | 87 |
75 DISALLOW_COPY_AND_ASSIGN(HttpProxySocketParams); | 88 DISALLOW_COPY_AND_ASSIGN(HttpProxySocketParams); |
76 }; | 89 }; |
77 | 90 |
(...skipping 15 matching lines...) Expand all Loading... |
93 virtual LoadState GetLoadState() const; | 106 virtual LoadState GetLoadState() const; |
94 | 107 |
95 private: | 108 private: |
96 enum State { | 109 enum State { |
97 STATE_TCP_CONNECT, | 110 STATE_TCP_CONNECT, |
98 STATE_TCP_CONNECT_COMPLETE, | 111 STATE_TCP_CONNECT_COMPLETE, |
99 STATE_SSL_CONNECT, | 112 STATE_SSL_CONNECT, |
100 STATE_SSL_CONNECT_COMPLETE, | 113 STATE_SSL_CONNECT_COMPLETE, |
101 STATE_HTTP_PROXY_CONNECT, | 114 STATE_HTTP_PROXY_CONNECT, |
102 STATE_HTTP_PROXY_CONNECT_COMPLETE, | 115 STATE_HTTP_PROXY_CONNECT_COMPLETE, |
| 116 STATE_SPDY_PROXY_CREATE_STREAM, |
| 117 STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE, |
| 118 STATE_SPDY_PROXY_CONNECT_COMPLETE, |
103 STATE_NONE, | 119 STATE_NONE, |
104 }; | 120 }; |
105 | 121 |
106 // Begins the tcp connection and the optional Http proxy tunnel. If the | 122 // Begins the tcp connection and the optional Http proxy tunnel. If the |
107 // request is not immediately servicable (likely), the request will return | 123 // request is not immediately servicable (likely), the request will return |
108 // ERR_IO_PENDING. An OK return from this function or the callback means | 124 // ERR_IO_PENDING. An OK return from this function or the callback means |
109 // that the connection is established; ERR_PROXY_AUTH_REQUESTED means | 125 // that the connection is established; ERR_PROXY_AUTH_REQUESTED means |
110 // that the tunnel needs authentication credentials, the socket will be | 126 // that the tunnel needs authentication credentials, the socket will be |
111 // returned in this case, and must be release back to the pool; or | 127 // returned in this case, and must be release back to the pool; or |
112 // a standard net error code will be returned. | 128 // a standard net error code will be returned. |
113 virtual int ConnectInternal(); | 129 virtual int ConnectInternal(); |
114 | 130 |
115 void OnIOComplete(int result); | 131 void OnIOComplete(int result); |
116 | 132 |
117 // Runs the state transition loop. | 133 // Runs the state transition loop. |
118 int DoLoop(int result); | 134 int DoLoop(int result); |
119 | 135 |
120 // Connecting to HTTP Proxy | 136 // Connecting to HTTP Proxy |
121 int DoTCPConnect(); | 137 int DoTCPConnect(); |
122 int DoTCPConnectComplete(int result); | 138 int DoTCPConnectComplete(int result); |
123 // Connecting to HTTPS Proxy | 139 // Connecting to HTTPS Proxy |
124 int DoSSLConnect(); | 140 int DoSSLConnect(); |
125 int DoSSLConnectComplete(int result); | 141 int DoSSLConnectComplete(int result); |
126 | 142 |
127 int DoHttpProxyConnect(); | 143 int DoHttpProxyConnect(); |
128 int DoHttpProxyConnectComplete(int result); | 144 int DoHttpProxyConnectComplete(int result); |
129 | 145 |
| 146 int DoSpdyProxyCreateStream(); |
| 147 int DoSpdyProxyCreateStreamComplete(int result); |
| 148 |
130 scoped_refptr<HttpProxySocketParams> params_; | 149 scoped_refptr<HttpProxySocketParams> params_; |
131 TCPClientSocketPool* const tcp_pool_; | 150 TCPClientSocketPool* const tcp_pool_; |
132 SSLClientSocketPool* const ssl_pool_; | 151 SSLClientSocketPool* const ssl_pool_; |
133 HostResolver* const resolver_; | 152 HostResolver* const resolver_; |
134 | 153 |
135 State next_state_; | 154 State next_state_; |
136 CompletionCallbackImpl<HttpProxyConnectJob> callback_; | 155 CompletionCallbackImpl<HttpProxyConnectJob> callback_; |
137 scoped_ptr<ClientSocketHandle> transport_socket_handle_; | 156 scoped_ptr<ClientSocketHandle> transport_socket_handle_; |
138 scoped_ptr<ClientSocket> transport_socket_; | 157 scoped_ptr<ClientSocket> transport_socket_; |
139 bool using_spdy_; | 158 bool using_spdy_; |
140 | 159 |
| 160 scoped_refptr<SpdyStream> spdy_stream_; |
| 161 |
141 DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJob); | 162 DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJob); |
142 }; | 163 }; |
143 | 164 |
144 class HttpProxyClientSocketPool : public ClientSocketPool { | 165 class HttpProxyClientSocketPool : public ClientSocketPool { |
145 public: | 166 public: |
146 HttpProxyClientSocketPool( | 167 HttpProxyClientSocketPool( |
147 int max_sockets, | 168 int max_sockets, |
148 int max_sockets_per_group, | 169 int max_sockets_per_group, |
149 ClientSocketPoolHistograms* histograms, | 170 ClientSocketPoolHistograms* histograms, |
150 HostResolver* host_resolver, | 171 HostResolver* host_resolver, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 254 |
234 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocketPool); | 255 DISALLOW_COPY_AND_ASSIGN(HttpProxyClientSocketPool); |
235 }; | 256 }; |
236 | 257 |
237 REGISTER_SOCKET_PARAMS_FOR_POOL(HttpProxyClientSocketPool, | 258 REGISTER_SOCKET_PARAMS_FOR_POOL(HttpProxyClientSocketPool, |
238 HttpProxySocketParams); | 259 HttpProxySocketParams); |
239 | 260 |
240 } // namespace net | 261 } // namespace net |
241 | 262 |
242 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ | 263 #endif // NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |