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 <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.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/log/net_log.h" | 21 #include "net/log/net_log.h" |
22 #include "net/socket/stream_socket.h" | 22 #include "net/socket/stream_socket.h" |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 | 25 |
26 class ClientSocketHandle; | 26 class ClientSocketHandle; |
27 class BoundNetLog; | 27 class NetLogWithSource; |
28 | 28 |
29 // The SOCKS client socket implementation | 29 // The SOCKS client socket implementation |
30 class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket { | 30 class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket { |
31 public: | 31 public: |
32 // |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 |
33 // 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. |
34 SOCKSClientSocket(std::unique_ptr<ClientSocketHandle> transport_socket, | 34 SOCKSClientSocket(std::unique_ptr<ClientSocketHandle> transport_socket, |
35 const HostResolver::RequestInfo& req_info, | 35 const HostResolver::RequestInfo& req_info, |
36 RequestPriority priority, | 36 RequestPriority priority, |
37 HostResolver* host_resolver); | 37 HostResolver* host_resolver); |
38 | 38 |
39 // On destruction Disconnect() is called. | 39 // On destruction Disconnect() is called. |
40 ~SOCKSClientSocket() override; | 40 ~SOCKSClientSocket() override; |
41 | 41 |
42 // StreamSocket implementation. | 42 // StreamSocket implementation. |
43 | 43 |
44 // Does the SOCKS handshake and completes the protocol. | 44 // Does the SOCKS handshake and completes the protocol. |
45 int Connect(const CompletionCallback& callback) override; | 45 int Connect(const CompletionCallback& callback) override; |
46 void Disconnect() override; | 46 void Disconnect() override; |
47 bool IsConnected() const override; | 47 bool IsConnected() const override; |
48 bool IsConnectedAndIdle() const override; | 48 bool IsConnectedAndIdle() const override; |
49 const BoundNetLog& NetLog() const override; | 49 const NetLogWithSource& NetLog() const override; |
50 void SetSubresourceSpeculation() override; | 50 void SetSubresourceSpeculation() override; |
51 void SetOmniboxSpeculation() override; | 51 void SetOmniboxSpeculation() override; |
52 bool WasEverUsed() const override; | 52 bool WasEverUsed() const override; |
53 bool WasNpnNegotiated() const override; | 53 bool WasNpnNegotiated() const override; |
54 NextProto GetNegotiatedProtocol() const override; | 54 NextProto GetNegotiatedProtocol() const override; |
55 bool GetSSLInfo(SSLInfo* ssl_info) override; | 55 bool GetSSLInfo(SSLInfo* ssl_info) override; |
56 void GetConnectionAttempts(ConnectionAttempts* out) const override; | 56 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
57 void ClearConnectionAttempts() override {} | 57 void ClearConnectionAttempts() override {} |
58 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} | 58 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} |
59 int64_t GetTotalReceivedBytes() const override; | 59 int64_t GetTotalReceivedBytes() const override; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // This becomes true when the socket is used to send or receive data. | 129 // This becomes true when the socket is used to send or receive data. |
130 bool was_ever_used_; | 130 bool was_ever_used_; |
131 | 131 |
132 // Used to resolve the hostname to which the SOCKS proxy will connect. | 132 // Used to resolve the hostname to which the SOCKS proxy will connect. |
133 HostResolver* host_resolver_; | 133 HostResolver* host_resolver_; |
134 std::unique_ptr<HostResolver::Request> request_; | 134 std::unique_ptr<HostResolver::Request> request_; |
135 AddressList addresses_; | 135 AddressList addresses_; |
136 HostResolver::RequestInfo host_request_info_; | 136 HostResolver::RequestInfo host_request_info_; |
137 RequestPriority priority_; | 137 RequestPriority priority_; |
138 | 138 |
139 BoundNetLog net_log_; | 139 NetLogWithSource 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 |