| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SOCKS_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ |
| 6 #define NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 enum State { | 75 enum State { |
| 76 STATE_RESOLVE_HOST, | 76 STATE_RESOLVE_HOST, |
| 77 STATE_RESOLVE_HOST_COMPLETE, | 77 STATE_RESOLVE_HOST_COMPLETE, |
| 78 STATE_HANDSHAKE_WRITE, | 78 STATE_HANDSHAKE_WRITE, |
| 79 STATE_HANDSHAKE_WRITE_COMPLETE, | 79 STATE_HANDSHAKE_WRITE_COMPLETE, |
| 80 STATE_HANDSHAKE_READ, | 80 STATE_HANDSHAKE_READ, |
| 81 STATE_HANDSHAKE_READ_COMPLETE, | 81 STATE_HANDSHAKE_READ_COMPLETE, |
| 82 STATE_NONE, | 82 STATE_NONE, |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // The SOCKS proxy connection either has the hostname resolved via the | |
| 86 // client or via the server. This enum stores the state of the SOCKS | |
| 87 // connection. If the client can resolve the hostname, the connection is | |
| 88 // SOCKS4, otherwise it is SOCKS4A. | |
| 89 enum SocksVersion { | |
| 90 kSOCKS4Unresolved, | |
| 91 kSOCKS4, | |
| 92 kSOCKS4a, | |
| 93 }; | |
| 94 | |
| 95 void DoCallback(int result); | 85 void DoCallback(int result); |
| 96 void OnIOComplete(int result); | 86 void OnIOComplete(int result); |
| 97 | 87 |
| 98 int DoLoop(int last_io_result); | 88 int DoLoop(int last_io_result); |
| 99 int DoResolveHost(); | 89 int DoResolveHost(); |
| 100 int DoResolveHostComplete(int result); | 90 int DoResolveHostComplete(int result); |
| 101 int DoHandshakeRead(); | 91 int DoHandshakeRead(); |
| 102 int DoHandshakeReadComplete(int result); | 92 int DoHandshakeReadComplete(int result); |
| 103 int DoHandshakeWrite(); | 93 int DoHandshakeWrite(); |
| 104 int DoHandshakeWriteComplete(int result); | 94 int DoHandshakeWriteComplete(int result); |
| 105 | 95 |
| 106 const std::string BuildHandshakeWriteBuffer() const; | 96 const std::string BuildHandshakeWriteBuffer() const; |
| 107 | 97 |
| 108 CompletionCallbackImpl<SOCKSClientSocket> io_callback_; | 98 CompletionCallbackImpl<SOCKSClientSocket> io_callback_; |
| 109 | 99 |
| 110 // Stores the underlying socket. | 100 // Stores the underlying socket. |
| 111 scoped_ptr<ClientSocketHandle> transport_; | 101 scoped_ptr<ClientSocketHandle> transport_; |
| 112 | 102 |
| 113 State next_state_; | 103 State next_state_; |
| 114 SocksVersion socks_version_; | |
| 115 | 104 |
| 116 // Stores the callback to the layer above, called on completing Connect(). | 105 // Stores the callback to the layer above, called on completing Connect(). |
| 117 CompletionCallback* user_callback_; | 106 CompletionCallback* user_callback_; |
| 118 | 107 |
| 119 // This IOBuffer is used by the class to read and write | 108 // This IOBuffer is used by the class to read and write |
| 120 // SOCKS handshake data. The length contains the expected size to | 109 // SOCKS handshake data. The length contains the expected size to |
| 121 // read or write. | 110 // read or write. |
| 122 scoped_refptr<IOBuffer> handshake_buf_; | 111 scoped_refptr<IOBuffer> handshake_buf_; |
| 123 | 112 |
| 124 // While writing, this buffer stores the complete write handshake data. | 113 // While writing, this buffer stores the complete write handshake data. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 139 HostResolver::RequestInfo host_request_info_; | 128 HostResolver::RequestInfo host_request_info_; |
| 140 | 129 |
| 141 BoundNetLog net_log_; | 130 BoundNetLog net_log_; |
| 142 | 131 |
| 143 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); | 132 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); |
| 144 }; | 133 }; |
| 145 | 134 |
| 146 } // namespace net | 135 } // namespace net |
| 147 | 136 |
| 148 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ | 137 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ |
| OLD | NEW |