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