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