| 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_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/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" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/socket/client_socket.h" | 18 #include "net/socket/client_socket.h" |
| 19 #include "testing/gtest/include/gtest/gtest_prod.h" | 19 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 class LoadLog; |
| 24 |
| 23 // The SOCKS client socket implementation | 25 // The SOCKS client socket implementation |
| 24 class SOCKSClientSocket : public ClientSocket { | 26 class SOCKSClientSocket : public ClientSocket { |
| 25 public: | 27 public: |
| 26 // Takes ownership of the |transport_socket|, which should already be | 28 // Takes ownership of the |transport_socket|, which should already be |
| 27 // connected by the time Connect() is called. | 29 // connected by the time Connect() is called. |
| 28 // | 30 // |
| 29 // |req_info| contains the hostname and port to which the socket above will | 31 // |req_info| contains the hostname and port to which the socket above will |
| 30 // communicate to via the socks layer. For testing the referrer is optional. | 32 // communicate to via the socks layer. For testing the referrer is optional. |
| 31 SOCKSClientSocket(ClientSocket* transport_socket, | 33 SOCKSClientSocket(ClientSocket* transport_socket, |
| 32 const HostResolver::RequestInfo& req_info, | 34 const HostResolver::RequestInfo& req_info, |
| 33 HostResolver* host_resolver); | 35 HostResolver* host_resolver); |
| 34 | 36 |
| 35 // On destruction Disconnect() is called. | 37 // On destruction Disconnect() is called. |
| 36 virtual ~SOCKSClientSocket(); | 38 virtual ~SOCKSClientSocket(); |
| 37 | 39 |
| 38 // ClientSocket methods: | 40 // ClientSocket methods: |
| 39 | 41 |
| 40 // Does the SOCKS handshake and completes the protocol. | 42 // Does the SOCKS handshake and completes the protocol. |
| 41 virtual int Connect(CompletionCallback* callback); | 43 virtual int Connect(CompletionCallback* callback, LoadLog* load_log); |
| 42 virtual void Disconnect(); | 44 virtual void Disconnect(); |
| 43 virtual bool IsConnected() const; | 45 virtual bool IsConnected() const; |
| 44 virtual bool IsConnectedAndIdle() const; | 46 virtual bool IsConnectedAndIdle() const; |
| 45 | 47 |
| 46 // Socket methods: | 48 // Socket methods: |
| 47 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 49 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 48 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 50 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 49 | 51 |
| 50 virtual bool SetReceiveBufferSize(int32 size); | 52 virtual bool SetReceiveBufferSize(int32 size); |
| 51 virtual bool SetSendBufferSize(int32 size); | 53 virtual bool SetSendBufferSize(int32 size); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 121 |
| 120 // These contain the bytes sent / received by the SOCKS handshake. | 122 // These contain the bytes sent / received by the SOCKS handshake. |
| 121 size_t bytes_sent_; | 123 size_t bytes_sent_; |
| 122 size_t bytes_received_; | 124 size_t bytes_received_; |
| 123 | 125 |
| 124 // Used to resolve the hostname to which the SOCKS proxy will connect. | 126 // Used to resolve the hostname to which the SOCKS proxy will connect. |
| 125 SingleRequestHostResolver host_resolver_; | 127 SingleRequestHostResolver host_resolver_; |
| 126 AddressList addresses_; | 128 AddressList addresses_; |
| 127 HostResolver::RequestInfo host_request_info_; | 129 HostResolver::RequestInfo host_request_info_; |
| 128 | 130 |
| 131 scoped_refptr<LoadLog> load_log_; |
| 132 |
| 129 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); | 133 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocket); |
| 130 }; | 134 }; |
| 131 | 135 |
| 132 } // namespace net | 136 } // namespace net |
| 133 | 137 |
| 134 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ | 138 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_H_ |
| 135 | |
| OLD | NEW |