OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SOCKS5_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
6 #define NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "net/base/address_list.h" | 15 #include "net/base/address_list.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/base/host_resolver.h" | 17 #include "net/base/host_resolver.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
20 #include "net/socket/client_socket.h" | 20 #include "net/socket/stream_socket.h" |
21 #include "testing/gtest/include/gtest/gtest_prod.h" | 21 #include "testing/gtest/include/gtest/gtest_prod.h" |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 | 24 |
25 class ClientSocketHandle; | 25 class ClientSocketHandle; |
26 class BoundNetLog; | 26 class BoundNetLog; |
27 | 27 |
28 // This ClientSocket is used to setup a SOCKSv5 handshake with a socks proxy. | 28 // This StreamSocket is used to setup a SOCKSv5 handshake with a socks proxy. |
29 // Currently no SOCKSv5 authentication is supported. | 29 // Currently no SOCKSv5 authentication is supported. |
30 class SOCKS5ClientSocket : public ClientSocket { | 30 class SOCKS5ClientSocket : public StreamSocket { |
31 public: | 31 public: |
32 // Takes ownership of the |transport_socket|, which should already be | 32 // Takes ownership of the |transport_socket|, which should already be |
33 // connected by the time Connect() is called. | 33 // connected by the time Connect() is called. |
34 // | 34 // |
35 // |req_info| contains the hostname and port to which the socket above will | 35 // |req_info| contains the hostname and port to which the socket above will |
36 // communicate to via the SOCKS layer. | 36 // communicate to via the SOCKS layer. |
37 // | 37 // |
38 // Although SOCKS 5 supports 3 different modes of addressing, we will | 38 // Although SOCKS 5 supports 3 different modes of addressing, we will |
39 // always pass it a hostname. This means the DNS resolving is done | 39 // always pass it a hostname. This means the DNS resolving is done |
40 // proxy side. | 40 // proxy side. |
41 SOCKS5ClientSocket(ClientSocketHandle* transport_socket, | 41 SOCKS5ClientSocket(ClientSocketHandle* transport_socket, |
42 const HostResolver::RequestInfo& req_info); | 42 const HostResolver::RequestInfo& req_info); |
43 | 43 |
44 // Deprecated constructor (http://crbug.com/37810) that takes a ClientSocket. | 44 // Deprecated constructor (http://crbug.com/37810) that takes a StreamSocket. |
45 SOCKS5ClientSocket(ClientSocket* transport_socket, | 45 SOCKS5ClientSocket(StreamSocket* transport_socket, |
46 const HostResolver::RequestInfo& req_info); | 46 const HostResolver::RequestInfo& req_info); |
47 | 47 |
48 // On destruction Disconnect() is called. | 48 // On destruction Disconnect() is called. |
49 virtual ~SOCKS5ClientSocket(); | 49 virtual ~SOCKS5ClientSocket(); |
50 | 50 |
51 // ClientSocket methods: | 51 // StreamSocket methods: |
52 | 52 |
53 // Does the SOCKS handshake and completes the protocol. | 53 // Does the SOCKS handshake and completes the protocol. |
54 virtual int Connect(CompletionCallback* callback); | 54 virtual int Connect(CompletionCallback* callback); |
55 virtual void Disconnect(); | 55 virtual void Disconnect(); |
56 virtual bool IsConnected() const; | 56 virtual bool IsConnected() const; |
57 virtual bool IsConnectedAndIdle() const; | 57 virtual bool IsConnectedAndIdle() const; |
58 virtual const BoundNetLog& NetLog() const; | 58 virtual const BoundNetLog& NetLog() const; |
59 virtual void SetSubresourceSpeculation(); | 59 virtual void SetSubresourceSpeculation(); |
60 virtual void SetOmniboxSpeculation(); | 60 virtual void SetOmniboxSpeculation(); |
61 virtual bool WasEverUsed() const; | 61 virtual bool WasEverUsed() const; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 HostResolver::RequestInfo host_request_info_; | 147 HostResolver::RequestInfo host_request_info_; |
148 | 148 |
149 BoundNetLog net_log_; | 149 BoundNetLog net_log_; |
150 | 150 |
151 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); | 151 DISALLOW_COPY_AND_ASSIGN(SOCKS5ClientSocket); |
152 }; | 152 }; |
153 | 153 |
154 } // namespace net | 154 } // namespace net |
155 | 155 |
156 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ | 156 #endif // NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_ |
OLD | NEW |