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_SOCKET_STREAM_SOCKET_STREAM_H_ | 5 #ifndef NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
6 #define NET_SOCKET_STREAM_SOCKET_STREAM_H_ | 6 #define NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/linked_ptr.h" | 13 #include "base/linked_ptr.h" |
14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
16 #include "base/task.h" | 16 #include "base/task.h" |
17 #include "net/base/address_list.h" | 17 #include "net/base/address_list.h" |
18 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_log.h" |
20 #include "net/http/http_auth.h" | 21 #include "net/http/http_auth.h" |
21 #include "net/http/http_auth_cache.h" | 22 #include "net/http/http_auth_cache.h" |
22 #include "net/http/http_auth_handler.h" | 23 #include "net/http/http_auth_handler.h" |
23 #include "net/proxy/proxy_service.h" | 24 #include "net/proxy/proxy_service.h" |
24 #include "net/socket/tcp_client_socket.h" | 25 #include "net/socket/tcp_client_socket.h" |
25 #include "net/url_request/request_tracker.h" | |
26 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
27 | 27 |
28 namespace net { | 28 namespace net { |
29 | 29 |
30 class AuthChallengeInfo; | 30 class AuthChallengeInfo; |
31 class ClientSocketFactory; | 31 class ClientSocketFactory; |
32 class HostResolver; | 32 class HostResolver; |
33 class HttpAuthHandlerFactory; | 33 class HttpAuthHandlerFactory; |
34 class LoadLog; | |
35 class SSLConfigService; | 34 class SSLConfigService; |
36 class SingleRequestHostResolver; | 35 class SingleRequestHostResolver; |
37 class SocketStreamMetrics; | 36 class SocketStreamMetrics; |
38 class SocketStreamThrottle; | 37 class SocketStreamThrottle; |
39 | 38 |
40 // SocketStream is used to implement Web Sockets. | 39 // SocketStream is used to implement Web Sockets. |
41 // It provides plain full-duplex stream with proxy and SSL support. | 40 // It provides plain full-duplex stream with proxy and SSL support. |
42 // For proxy authentication, only basic mechanisum is supported. It will try | 41 // For proxy authentication, only basic mechanisum is supported. It will try |
43 // authentication identity for proxy URL first. If server requires proxy | 42 // authentication identity for proxy URL first. If server requires proxy |
44 // authentication, it will try authentication identity for realm that server | 43 // authentication, it will try authentication identity for realm that server |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 101 |
103 const GURL& url() const { return url_; } | 102 const GURL& url() const { return url_; } |
104 bool is_secure() const; | 103 bool is_secure() const; |
105 const AddressList& address_list() const { return addresses_; } | 104 const AddressList& address_list() const { return addresses_; } |
106 Delegate* delegate() const { return delegate_; } | 105 Delegate* delegate() const { return delegate_; } |
107 int max_pending_send_allowed() const { return max_pending_send_allowed_; } | 106 int max_pending_send_allowed() const { return max_pending_send_allowed_; } |
108 | 107 |
109 URLRequestContext* context() const { return context_.get(); } | 108 URLRequestContext* context() const { return context_.get(); } |
110 void set_context(URLRequestContext* context); | 109 void set_context(URLRequestContext* context); |
111 | 110 |
112 LoadLog* load_log() const { return load_log_; } | 111 BoundNetLog* net_log() { return &net_log_; } |
113 | 112 |
114 // Opens the connection on the IO thread. | 113 // Opens the connection on the IO thread. |
115 // Once the connection is established, calls delegate's OnConnected. | 114 // Once the connection is established, calls delegate's OnConnected. |
116 virtual void Connect(); | 115 virtual void Connect(); |
117 | 116 |
118 // Requests to send |len| bytes of |data| on the connection. | 117 // Requests to send |len| bytes of |data| on the connection. |
119 // Returns true if |data| is buffered in the job. | 118 // Returns true if |data| is buffered in the job. |
120 // Returns false if size of buffered data would exceeds | 119 // Returns false if size of buffered data would exceeds |
121 // |max_pending_send_allowed_| and |data| is not sent at all. | 120 // |max_pending_send_allowed_| and |data| is not sent at all. |
122 virtual bool SendData(const char* data, int len); | 121 virtual bool SendData(const char* data, int len); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 STATE_CLOSE, | 199 STATE_CLOSE, |
201 }; | 200 }; |
202 | 201 |
203 enum ProxyMode { | 202 enum ProxyMode { |
204 kDirectConnection, // If using a direct connection | 203 kDirectConnection, // If using a direct connection |
205 kTunnelProxy, // If using a tunnel (CONNECT method as HTTPS) | 204 kTunnelProxy, // If using a tunnel (CONNECT method as HTTPS) |
206 kSOCKSProxy, // If using a SOCKS proxy | 205 kSOCKSProxy, // If using a SOCKS proxy |
207 }; | 206 }; |
208 | 207 |
209 typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue; | 208 typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue; |
210 friend class RequestTracker<SocketStream>; | |
211 | 209 |
212 friend class WebSocketThrottleTest; | 210 friend class WebSocketThrottleTest; |
213 | 211 |
214 // Copies the given addrinfo list in |addresses_|. | 212 // Copies the given addrinfo list in |addresses_|. |
215 // Used for WebSocketThrottleTest. | 213 // Used for WebSocketThrottleTest. |
216 void CopyAddrInfo(struct addrinfo* head); | 214 void CopyAddrInfo(struct addrinfo* head); |
217 | 215 |
218 // Finishes the job. | 216 // Finishes the job. |
219 // Calls OnError and OnClose of delegate, and no more | 217 // Calls OnError and OnClose of delegate, and no more |
220 // notifications will be sent to delegate. | 218 // notifications will be sent to delegate. |
(...skipping 28 matching lines...) Expand all Loading... |
249 GURL ProxyAuthOrigin() const; | 247 GURL ProxyAuthOrigin() const; |
250 int HandleAuthChallenge(const HttpResponseHeaders* headers); | 248 int HandleAuthChallenge(const HttpResponseHeaders* headers); |
251 void DoAuthRequired(); | 249 void DoAuthRequired(); |
252 void DoRestartWithAuth(); | 250 void DoRestartWithAuth(); |
253 | 251 |
254 int HandleCertificateError(int result); | 252 int HandleCertificateError(int result); |
255 | 253 |
256 SSLConfigService* ssl_config_service() const; | 254 SSLConfigService* ssl_config_service() const; |
257 ProxyService* proxy_service() const; | 255 ProxyService* proxy_service() const; |
258 | 256 |
259 void GetInfoForTracker( | 257 BoundNetLog net_log_; |
260 RequestTracker<SocketStream>::RecentRequestInfo* info) const; | |
261 | |
262 scoped_refptr<LoadLog> load_log_; | |
263 | 258 |
264 GURL url_; | 259 GURL url_; |
265 int max_pending_send_allowed_; | 260 int max_pending_send_allowed_; |
266 scoped_refptr<URLRequestContext> context_; | 261 scoped_refptr<URLRequestContext> context_; |
267 | 262 |
268 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap; | 263 typedef std::map<const void*, linked_ptr<UserData> > UserDataMap; |
269 UserDataMap user_data_; | 264 UserDataMap user_data_; |
270 | 265 |
271 State next_state_; | 266 State next_state_; |
272 scoped_refptr<HostResolver> host_resolver_; | 267 scoped_refptr<HostResolver> host_resolver_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 scoped_refptr<IOBuffer> write_buf_; | 310 scoped_refptr<IOBuffer> write_buf_; |
316 scoped_refptr<DrainableIOBuffer> current_write_buf_; | 311 scoped_refptr<DrainableIOBuffer> current_write_buf_; |
317 int write_buf_offset_; | 312 int write_buf_offset_; |
318 int write_buf_size_; | 313 int write_buf_size_; |
319 PendingDataQueue pending_write_bufs_; | 314 PendingDataQueue pending_write_bufs_; |
320 | 315 |
321 SocketStreamThrottle* throttle_; | 316 SocketStreamThrottle* throttle_; |
322 | 317 |
323 scoped_ptr<SocketStreamMetrics> metrics_; | 318 scoped_ptr<SocketStreamMetrics> metrics_; |
324 | 319 |
325 RequestTracker<SocketStream>::Node request_tracker_node_; | |
326 | |
327 DISALLOW_COPY_AND_ASSIGN(SocketStream); | 320 DISALLOW_COPY_AND_ASSIGN(SocketStream); |
328 }; | 321 }; |
329 | 322 |
330 } // namespace net | 323 } // namespace net |
331 | 324 |
332 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ | 325 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
OLD | NEW |