OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void DoCallback(int result); | 85 void DoCallback(int result); |
86 void OnIOComplete(int result); | 86 void OnIOComplete(int result); |
| 87 void OnReadWriteComplete(const CompletionCallback& callback, int result); |
87 | 88 |
88 int DoLoop(int last_io_result); | 89 int DoLoop(int last_io_result); |
89 int DoResolveHost(); | 90 int DoResolveHost(); |
90 int DoResolveHostComplete(int result); | 91 int DoResolveHostComplete(int result); |
91 int DoHandshakeRead(); | 92 int DoHandshakeRead(); |
92 int DoHandshakeReadComplete(int result); | 93 int DoHandshakeReadComplete(int result); |
93 int DoHandshakeWrite(); | 94 int DoHandshakeWrite(); |
94 int DoHandshakeWriteComplete(int result); | 95 int DoHandshakeWriteComplete(int result); |
95 | 96 |
96 const std::string BuildHandshakeWriteBuffer() const; | 97 const std::string BuildHandshakeWriteBuffer() const; |
97 | 98 |
98 // Stores the underlying socket. | 99 // Stores the underlying socket. |
99 scoped_ptr<ClientSocketHandle> transport_; | 100 scoped_ptr<ClientSocketHandle> transport_; |
100 | 101 |
101 State next_state_; | 102 State next_state_; |
102 | 103 |
103 // Stores the callback to the layer above, called on completing Connect(). | 104 // Stores the callbacks to the layer above, called on completing Connect(). |
104 CompletionCallback user_callback_; | 105 CompletionCallback user_callback_; |
105 | 106 |
106 // This IOBuffer is used by the class to read and write | 107 // This IOBuffer is used by the class to read and write |
107 // SOCKS handshake data. The length contains the expected size to | 108 // SOCKS handshake data. The length contains the expected size to |
108 // read or write. | 109 // read or write. |
109 scoped_refptr<IOBuffer> handshake_buf_; | 110 scoped_refptr<IOBuffer> handshake_buf_; |
110 | 111 |
111 // While writing, this buffer stores the complete write handshake data. | 112 // While writing, this buffer stores the complete write handshake data. |
112 // While reading, it stores the handshake information received so far. | 113 // While reading, it stores the handshake information received so far. |
113 std::string buffer_; | 114 std::string buffer_; |
114 | 115 |
115 // This becomes true when the SOCKS handshake has completed and the | 116 // This becomes true when the SOCKS handshake has completed and the |
116 // overlying connection is free to communicate. | 117 // overlying connection is free to communicate. |
117 bool completed_handshake_; | 118 bool completed_handshake_; |
118 | 119 |
119 // These contain the bytes sent / received by the SOCKS handshake. | 120 // These contain the bytes sent / received by the SOCKS handshake. |
120 size_t bytes_sent_; | 121 size_t bytes_sent_; |
121 size_t bytes_received_; | 122 size_t bytes_received_; |
122 | 123 |
| 124 // This becomes true when the socket is used to send or receive data. |
| 125 bool was_ever_used_; |
| 126 |
123 // Used to resolve the hostname to which the SOCKS proxy will connect. | 127 // Used to resolve the hostname to which the SOCKS proxy will connect. |
124 SingleRequestHostResolver host_resolver_; | 128 SingleRequestHostResolver host_resolver_; |
125 AddressList addresses_; | 129 AddressList addresses_; |
126 HostResolver::RequestInfo host_request_info_; | 130 HostResolver::RequestInfo host_request_info_; |
127 RequestPriority priority_; | 131 RequestPriority priority_; |
128 | 132 |
129 BoundNetLog net_log_; | 133 BoundNetLog net_log_; |
130 | 134 |
131 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); | 135 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); |
132 }; | 136 }; |
133 | 137 |
134 } // namespace net | 138 } // namespace net |
135 | 139 |
136 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ | 140 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ |
OLD | NEW |