Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: net/socket/socks_client_socket.h

Issue 150003: Reverting 19466. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/socket/socks_client_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SOCKS_CLIENT_SOCKET_H_ 5 #ifndef NET_BASE_SOCKS_CLIENT_SOCKET_H_
6 #define NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ 6 #define NET_BASE_SOCKS_CLIENT_SOCKET_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "net/base/address_list.h" 14 #include "net/base/address_list.h"
15 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
16 #include "net/base/host_resolver.h" 16 #include "net/base/host_resolver.h"
(...skipping 30 matching lines...) Expand all
47 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); 47 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
48 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); 48 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback);
49 49
50 #if defined(OS_LINUX) 50 #if defined(OS_LINUX)
51 // Identical to posix system call getpeername(). 51 // Identical to posix system call getpeername().
52 // Needed by ssl_client_socket_nss. 52 // Needed by ssl_client_socket_nss.
53 virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen); 53 virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen);
54 #endif 54 #endif
55 55
56 private: 56 private:
57 FRIEND_TEST(SOCKSClientSocketTest, CompleteHandshake);
58 FRIEND_TEST(SOCKSClientSocketTest, SOCKS4AFailedDNS);
59 FRIEND_TEST(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6);
60
61 enum State { 57 enum State {
62 STATE_RESOLVE_HOST, 58 STATE_RESOLVE_HOST,
63 STATE_RESOLVE_HOST_COMPLETE, 59 STATE_RESOLVE_HOST_COMPLETE,
64 STATE_HANDSHAKE_WRITE, 60 STATE_HANDSHAKE_WRITE,
65 STATE_HANDSHAKE_WRITE_COMPLETE, 61 STATE_HANDSHAKE_WRITE_COMPLETE,
66 STATE_HANDSHAKE_READ, 62 STATE_HANDSHAKE_READ,
67 STATE_HANDSHAKE_READ_COMPLETE, 63 STATE_HANDSHAKE_READ_COMPLETE,
68 STATE_NONE, 64 STATE_NONE,
69 }; 65 };
70 66
(...skipping 11 matching lines...) Expand all
82 void OnIOComplete(int result); 78 void OnIOComplete(int result);
83 79
84 int DoLoop(int last_io_result); 80 int DoLoop(int last_io_result);
85 int DoResolveHost(); 81 int DoResolveHost();
86 int DoResolveHostComplete(int result); 82 int DoResolveHostComplete(int result);
87 int DoHandshakeRead(); 83 int DoHandshakeRead();
88 int DoHandshakeReadComplete(int result); 84 int DoHandshakeReadComplete(int result);
89 int DoHandshakeWrite(); 85 int DoHandshakeWrite();
90 int DoHandshakeWriteComplete(int result); 86 int DoHandshakeWriteComplete(int result);
91 87
92 const std::string BuildHandshakeWriteBuffer() const; 88 void BuildHandshakeWriteBuffer();
93 89
94 CompletionCallbackImpl<SOCKSClientSocket> io_callback_; 90 CompletionCallbackImpl<SOCKSClientSocket> io_callback_;
95 91
96 // Stores the underlying socket. 92 // Stores the underlying socket.
97 scoped_ptr<ClientSocket> transport_; 93 scoped_ptr<ClientSocket> transport_;
98 94
99 State next_state_; 95 State next_state_;
100 SocksVersion socks_version_; 96 SocksVersion socks_version_;
101 97
102 // Stores the callback to the layer above, called on completing Connect(). 98 // Stores the callback to the layer above, called on completing Connect().
103 CompletionCallback* user_callback_; 99 CompletionCallback* user_callback_;
104 100
105 // This IOBuffer is used by the class to read and write 101 // This IOBuffer is used by the class to read and write
106 // SOCKS handshake data. The length contains the expected size to 102 // SOCKS handshake data. The length contains the expected size to
107 // read or write. 103 // read or write.
108 scoped_refptr<IOBuffer> handshake_buf_; 104 scoped_refptr<IOBuffer> handshake_buf_;
105 int handshake_buf_len_;
109 106
110 // While writing, this buffer stores the complete write handshake data. 107 // While writing, this buffer stores the complete write handshake data.
111 // While reading, it stores the handshake information received so far. 108 // While reading, it stores the handshake information received so far.
112 std::string buffer_; 109 scoped_array<char> buffer_;
110 int buffer_len_;
113 111
114 // This becomes true when the SOCKS handshake has completed and the 112 // This becomes true when the SOCKS handshake has completed and the
115 // overlying connection is free to communicate. 113 // overlying connection is free to communicate.
116 bool completed_handshake_; 114 bool completed_handshake_;
117 115
118 // These contain the bytes sent / received by the SOCKS handshake. 116 // These contain the bytes sent / received by the SOCKS handshake.
119 size_t bytes_sent_; 117 int bytes_sent_;
120 size_t bytes_received_; 118 int bytes_received_;
121 119
122 // Used to resolve the hostname to which the SOCKS proxy will connect. 120 // Used to resolve the hostname to which the SOCKS proxy will connect.
123 SingleRequestHostResolver resolver_; 121 SingleRequestHostResolver resolver_;
124 AddressList addresses_; 122 AddressList addresses_;
125 HostResolver::RequestInfo host_request_info_; 123 HostResolver::RequestInfo host_request_info_;
126 124
127 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); 125 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket);
128 }; 126 };
129 127
130 } // namespace net 128 } // namespace net
131 129
132 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ 130 #endif // NET_BASE_SOCKS_CLIENT_SOCKET_H_
133 131
OLDNEW
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/socket/socks_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698