| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | |
| 17 #include "net/base/address_list.h" | 17 #include "net/base/address_list.h" |
| 18 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/dns/host_resolver.h" | 20 #include "net/dns/host_resolver.h" |
| 21 #include "net/dns/single_request_host_resolver.h" | 21 #include "net/dns/single_request_host_resolver.h" |
| 22 #include "net/log/net_log.h" | 22 #include "net/log/net_log.h" |
| 23 #include "net/socket/stream_socket.h" | 23 #include "net/socket/stream_socket.h" |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 | 26 |
| 27 class ClientSocketHandle; | 27 class ClientSocketHandle; |
| 28 class BoundNetLog; | 28 class BoundNetLog; |
| 29 | 29 |
| 30 // The SOCKS client socket implementation | 30 // The SOCKS client socket implementation |
| 31 class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket { | 31 class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket { |
| 32 public: | 32 public: |
| 33 // |req_info| contains the hostname and port to which the socket above will | 33 // |req_info| contains the hostname and port to which the socket above will |
| 34 // communicate to via the socks layer. For testing the referrer is optional. | 34 // communicate to via the socks layer. For testing the referrer is optional. |
| 35 SOCKSClientSocket(scoped_ptr<ClientSocketHandle> transport_socket, | 35 SOCKSClientSocket(std::unique_ptr<ClientSocketHandle> transport_socket, |
| 36 const HostResolver::RequestInfo& req_info, | 36 const HostResolver::RequestInfo& req_info, |
| 37 RequestPriority priority, | 37 RequestPriority priority, |
| 38 HostResolver* host_resolver); | 38 HostResolver* host_resolver); |
| 39 | 39 |
| 40 // On destruction Disconnect() is called. | 40 // On destruction Disconnect() is called. |
| 41 ~SOCKSClientSocket() override; | 41 ~SOCKSClientSocket() override; |
| 42 | 42 |
| 43 // StreamSocket implementation. | 43 // StreamSocket implementation. |
| 44 | 44 |
| 45 // Does the SOCKS handshake and completes the protocol. | 45 // Does the SOCKS handshake and completes the protocol. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 int DoResolveHost(); | 96 int DoResolveHost(); |
| 97 int DoResolveHostComplete(int result); | 97 int DoResolveHostComplete(int result); |
| 98 int DoHandshakeRead(); | 98 int DoHandshakeRead(); |
| 99 int DoHandshakeReadComplete(int result); | 99 int DoHandshakeReadComplete(int result); |
| 100 int DoHandshakeWrite(); | 100 int DoHandshakeWrite(); |
| 101 int DoHandshakeWriteComplete(int result); | 101 int DoHandshakeWriteComplete(int result); |
| 102 | 102 |
| 103 const std::string BuildHandshakeWriteBuffer() const; | 103 const std::string BuildHandshakeWriteBuffer() const; |
| 104 | 104 |
| 105 // Stores the underlying socket. | 105 // Stores the underlying socket. |
| 106 scoped_ptr<ClientSocketHandle> transport_; | 106 std::unique_ptr<ClientSocketHandle> transport_; |
| 107 | 107 |
| 108 State next_state_; | 108 State next_state_; |
| 109 | 109 |
| 110 // Stores the callbacks to the layer above, called on completing Connect(). | 110 // Stores the callbacks to the layer above, called on completing Connect(). |
| 111 CompletionCallback user_callback_; | 111 CompletionCallback user_callback_; |
| 112 | 112 |
| 113 // This IOBuffer is used by the class to read and write | 113 // This IOBuffer is used by the class to read and write |
| 114 // SOCKS handshake data. The length contains the expected size to | 114 // SOCKS handshake data. The length contains the expected size to |
| 115 // read or write. | 115 // read or write. |
| 116 scoped_refptr<IOBuffer> handshake_buf_; | 116 scoped_refptr<IOBuffer> handshake_buf_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 137 RequestPriority priority_; | 137 RequestPriority priority_; |
| 138 | 138 |
| 139 BoundNetLog net_log_; | 139 BoundNetLog net_log_; |
| 140 | 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); | 141 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 } // namespace net | 144 } // namespace net |
| 145 | 145 |
| 146 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ | 146 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ |
| OLD | NEW |