| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "net/socket/tcp_client_socket.h" | 24 #include "net/socket/tcp_client_socket.h" |
| 25 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 | 28 |
| 29 class AuthChallengeInfo; | 29 class AuthChallengeInfo; |
| 30 class ClientSocketFactory; | 30 class ClientSocketFactory; |
| 31 class HostResolver; | 31 class HostResolver; |
| 32 class SSLConfigService; | 32 class SSLConfigService; |
| 33 class SingleRequestHostResolver; | 33 class SingleRequestHostResolver; |
| 34 class SocketStreamThrottle; |
| 34 | 35 |
| 35 // SocketStream is used to implement Web Sockets. | 36 // SocketStream is used to implement Web Sockets. |
| 36 // It provides plain full-duplex stream with proxy and SSL support. | 37 // It provides plain full-duplex stream with proxy and SSL support. |
| 37 // For proxy authentication, only basic mechanisum is supported. It will try | 38 // For proxy authentication, only basic mechanisum is supported. It will try |
| 38 // authentication identity for proxy URL first. If server requires proxy | 39 // authentication identity for proxy URL first. If server requires proxy |
| 39 // authentication, it will try authentication identity for realm that server | 40 // authentication, it will try authentication identity for realm that server |
| 40 // requests. | 41 // requests. |
| 41 class SocketStream : public base::RefCountedThreadSafe<SocketStream> { | 42 class SocketStream : public base::RefCountedThreadSafe<SocketStream> { |
| 42 public: | 43 public: |
| 43 // Derive from this class and add your own data members to associate extra | 44 // Derive from this class and add your own data members to associate extra |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 SocketStream(const GURL& url, Delegate* delegate); | 90 SocketStream(const GURL& url, Delegate* delegate); |
| 90 | 91 |
| 91 // The user data allows the clients to associate data with this job. | 92 // The user data allows the clients to associate data with this job. |
| 92 // Multiple user data values can be stored under different keys. | 93 // Multiple user data values can be stored under different keys. |
| 93 // This job will TAKE OWNERSHIP of the given data pointer, and will | 94 // This job will TAKE OWNERSHIP of the given data pointer, and will |
| 94 // delete the object if it is changed or the job is destroyed. | 95 // delete the object if it is changed or the job is destroyed. |
| 95 UserData* GetUserData(const void* key) const; | 96 UserData* GetUserData(const void* key) const; |
| 96 void SetUserData(const void* key, UserData* data); | 97 void SetUserData(const void* key, UserData* data); |
| 97 | 98 |
| 98 const GURL& url() const { return url_; } | 99 const GURL& url() const { return url_; } |
| 100 const AddressList& address_list() const { return addresses_; } |
| 99 Delegate* delegate() const { return delegate_; } | 101 Delegate* delegate() const { return delegate_; } |
| 100 int max_pending_send_allowed() const { return max_pending_send_allowed_; } | 102 int max_pending_send_allowed() const { return max_pending_send_allowed_; } |
| 101 | 103 |
| 102 URLRequestContext* context() const { return context_.get(); } | 104 URLRequestContext* context() const { return context_.get(); } |
| 103 void set_context(URLRequestContext* context); | 105 void set_context(URLRequestContext* context); |
| 104 | 106 |
| 105 // Opens the connection on the IO thread. | 107 // Opens the connection on the IO thread. |
| 106 // Once the connection is established, calls delegate's OnConnected. | 108 // Once the connection is established, calls delegate's OnConnected. |
| 107 void Connect(); | 109 void Connect(); |
| 108 | 110 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 enum ProxyMode { | 186 enum ProxyMode { |
| 185 kDirectConnection, // If using a direct connection | 187 kDirectConnection, // If using a direct connection |
| 186 kTunnelProxy, // If using a tunnel (CONNECT method as HTTPS) | 188 kTunnelProxy, // If using a tunnel (CONNECT method as HTTPS) |
| 187 kSOCKSProxy, // If using a SOCKS proxy | 189 kSOCKSProxy, // If using a SOCKS proxy |
| 188 }; | 190 }; |
| 189 | 191 |
| 190 typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue; | 192 typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue; |
| 191 friend class base::RefCountedThreadSafe<SocketStream>; | 193 friend class base::RefCountedThreadSafe<SocketStream>; |
| 192 ~SocketStream(); | 194 ~SocketStream(); |
| 193 | 195 |
| 196 friend class WebSocketThrottleTest; |
| 197 |
| 198 // Copies the given addrinfo list in |addresses_|. |
| 199 // Used for WebSocketThrottleTest. |
| 200 void CopyAddrInfo(struct addrinfo* head); |
| 201 |
| 194 // Finishes the job. | 202 // Finishes the job. |
| 195 // Calls OnError and OnClose of delegate, and no more | 203 // Calls OnError and OnClose of delegate, and no more |
| 196 // notifications will be sent to delegate. | 204 // notifications will be sent to delegate. |
| 197 void Finish(int result); | 205 void Finish(int result); |
| 198 | 206 |
| 199 int DidEstablishConnection(); | 207 int DidEstablishConnection(); |
| 200 void DidReceiveData(int result); | 208 int DidReceiveData(int result); |
| 201 void DidSendData(int result); | 209 int DidSendData(int result); |
| 202 | 210 |
| 203 void OnIOCompleted(int result); | 211 void OnIOCompleted(int result); |
| 204 void OnReadCompleted(int result); | 212 void OnReadCompleted(int result); |
| 205 void OnWriteCompleted(int result); | 213 void OnWriteCompleted(int result); |
| 206 | 214 |
| 207 void DoLoop(int result); | 215 void DoLoop(int result); |
| 208 | 216 |
| 209 int DoResolveProxy(); | 217 int DoResolveProxy(); |
| 210 int DoResolveProxyComplete(int result); | 218 int DoResolveProxyComplete(int result); |
| 211 int DoResolveHost(); | 219 int DoResolveHost(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // |max_pending_send_allowed_|. | 290 // |max_pending_send_allowed_|. |
| 283 // |write_buf_| holds requested data and |current_write_buf_| is used | 291 // |write_buf_| holds requested data and |current_write_buf_| is used |
| 284 // for Write operation, that is, |current_write_buf_| is | 292 // for Write operation, that is, |current_write_buf_| is |
| 285 // |write_buf_| + |write_buf_offset_|. | 293 // |write_buf_| + |write_buf_offset_|. |
| 286 scoped_refptr<IOBuffer> write_buf_; | 294 scoped_refptr<IOBuffer> write_buf_; |
| 287 scoped_refptr<DrainableIOBuffer> current_write_buf_; | 295 scoped_refptr<DrainableIOBuffer> current_write_buf_; |
| 288 int write_buf_offset_; | 296 int write_buf_offset_; |
| 289 int write_buf_size_; | 297 int write_buf_size_; |
| 290 PendingDataQueue pending_write_bufs_; | 298 PendingDataQueue pending_write_bufs_; |
| 291 | 299 |
| 300 SocketStreamThrottle* throttle_; |
| 301 |
| 292 DISALLOW_COPY_AND_ASSIGN(SocketStream); | 302 DISALLOW_COPY_AND_ASSIGN(SocketStream); |
| 293 }; | 303 }; |
| 294 | 304 |
| 295 } // namespace net | 305 } // namespace net |
| 296 | 306 |
| 297 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ | 307 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
| OLD | NEW |