| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 virtual void OnClose(SocketStream* socket) = 0; | 72 virtual void OnClose(SocketStream* socket) = 0; |
| 73 | 73 |
| 74 // Called when proxy authentication required. | 74 // Called when proxy authentication required. |
| 75 // The delegate should call RestartWithAuth() if credential for |auth_info| | 75 // The delegate should call RestartWithAuth() if credential for |auth_info| |
| 76 // is found in password database, or call Close() to close the connection. | 76 // is found in password database, or call Close() to close the connection. |
| 77 virtual void OnAuthRequired(SocketStream* socket, | 77 virtual void OnAuthRequired(SocketStream* socket, |
| 78 AuthChallengeInfo* auth_info) { | 78 AuthChallengeInfo* auth_info) { |
| 79 // By default, no credential is available and close the connection. | 79 // By default, no credential is available and close the connection. |
| 80 socket->Close(); | 80 socket->Close(); |
| 81 } | 81 } |
| 82 |
| 83 // Called when an error occured. |
| 84 // This is only for error reporting to the delegate. |
| 85 // |error| is net::Error. |
| 86 virtual void OnError(const SocketStream* socket, int error) {} |
| 82 }; | 87 }; |
| 83 | 88 |
| 84 SocketStream(const GURL& url, Delegate* delegate); | 89 SocketStream(const GURL& url, Delegate* delegate); |
| 85 | 90 |
| 86 // The user data allows the clients to associate data with this job. | 91 // The user data allows the clients to associate data with this job. |
| 87 // Multiple user data values can be stored under different keys. | 92 // Multiple user data values can be stored under different keys. |
| 88 // This job will TAKE OWNERSHIP of the given data pointer, and will | 93 // This job will TAKE OWNERSHIP of the given data pointer, and will |
| 89 // delete the object if it is changed or the job is destroyed. | 94 // delete the object if it is changed or the job is destroyed. |
| 90 UserData* GetUserData(const void* key) const; | 95 UserData* GetUserData(const void* key) const; |
| 91 void SetUserData(const void* key, UserData* data); | 96 void SetUserData(const void* key, UserData* data); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 STATE_TCP_CONNECT, | 169 STATE_TCP_CONNECT, |
| 165 STATE_TCP_CONNECT_COMPLETE, | 170 STATE_TCP_CONNECT_COMPLETE, |
| 166 STATE_WRITE_TUNNEL_HEADERS, | 171 STATE_WRITE_TUNNEL_HEADERS, |
| 167 STATE_WRITE_TUNNEL_HEADERS_COMPLETE, | 172 STATE_WRITE_TUNNEL_HEADERS_COMPLETE, |
| 168 STATE_READ_TUNNEL_HEADERS, | 173 STATE_READ_TUNNEL_HEADERS, |
| 169 STATE_READ_TUNNEL_HEADERS_COMPLETE, | 174 STATE_READ_TUNNEL_HEADERS_COMPLETE, |
| 170 STATE_SOCKS_CONNECT, | 175 STATE_SOCKS_CONNECT, |
| 171 STATE_SOCKS_CONNECT_COMPLETE, | 176 STATE_SOCKS_CONNECT_COMPLETE, |
| 172 STATE_SSL_CONNECT, | 177 STATE_SSL_CONNECT, |
| 173 STATE_SSL_CONNECT_COMPLETE, | 178 STATE_SSL_CONNECT_COMPLETE, |
| 174 STATE_READ_WRITE | 179 STATE_READ_WRITE, |
| 180 STATE_AUTH_REQUIRED, |
| 175 }; | 181 }; |
| 176 | 182 |
| 177 enum ProxyMode { | 183 enum ProxyMode { |
| 178 kDirectConnection, // If using a direct connection | 184 kDirectConnection, // If using a direct connection |
| 179 kTunnelProxy, // If using a tunnel (CONNECT method as HTTPS) | 185 kTunnelProxy, // If using a tunnel (CONNECT method as HTTPS) |
| 180 kSOCKSProxy, // If using a SOCKS proxy | 186 kSOCKSProxy, // If using a SOCKS proxy |
| 181 }; | 187 }; |
| 182 | 188 |
| 183 typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue; | 189 typedef std::deque< scoped_refptr<IOBufferWithSize> > PendingDataQueue; |
| 184 friend class base::RefCountedThreadSafe<SocketStream>; | 190 friend class base::RefCountedThreadSafe<SocketStream>; |
| 185 ~SocketStream(); | 191 ~SocketStream(); |
| 186 | 192 |
| 187 // Finish the job. Once finished, calls OnClose of delegate, and no more | 193 // Finishes the job. |
| 194 // Calls OnError and OnClose of delegate, and no more |
| 188 // notifications will be sent to delegate. | 195 // notifications will be sent to delegate. |
| 189 void Finish(); | 196 void Finish(int result); |
| 190 | 197 |
| 191 void DidEstablishConnection(); | 198 int DidEstablishConnection(); |
| 192 void DidReceiveData(int result); | 199 void DidReceiveData(int result); |
| 193 void DidSendData(int result); | 200 void DidSendData(int result); |
| 194 | 201 |
| 195 void OnIOCompleted(int result); | 202 void OnIOCompleted(int result); |
| 196 void OnReadCompleted(int result); | 203 void OnReadCompleted(int result); |
| 197 void OnWriteCompleted(int result); | 204 void OnWriteCompleted(int result); |
| 198 | 205 |
| 199 int DoLoop(int result); | 206 void DoLoop(int result); |
| 200 | 207 |
| 201 int DoResolveProxy(); | 208 int DoResolveProxy(); |
| 202 int DoResolveProxyComplete(int result); | 209 int DoResolveProxyComplete(int result); |
| 203 int DoResolveHost(); | 210 int DoResolveHost(); |
| 204 int DoResolveHostComplete(int result); | 211 int DoResolveHostComplete(int result); |
| 205 int DoTcpConnect(); | 212 int DoTcpConnect(); |
| 206 int DoTcpConnectComplete(int result); | 213 int DoTcpConnectComplete(int result); |
| 207 int DoWriteTunnelHeaders(); | 214 int DoWriteTunnelHeaders(); |
| 208 int DoWriteTunnelHeadersComplete(int result); | 215 int DoWriteTunnelHeadersComplete(int result); |
| 209 int DoReadTunnelHeaders(); | 216 int DoReadTunnelHeaders(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 int write_buf_offset_; | 287 int write_buf_offset_; |
| 281 int write_buf_size_; | 288 int write_buf_size_; |
| 282 PendingDataQueue pending_write_bufs_; | 289 PendingDataQueue pending_write_bufs_; |
| 283 | 290 |
| 284 DISALLOW_COPY_AND_ASSIGN(SocketStream); | 291 DISALLOW_COPY_AND_ASSIGN(SocketStream); |
| 285 }; | 292 }; |
| 286 | 293 |
| 287 } // namespace net | 294 } // namespace net |
| 288 | 295 |
| 289 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ | 296 #endif // NET_SOCKET_STREAM_SOCKET_STREAM_H_ |
| OLD | NEW |