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_POOL_H_ | 5 #ifndef NET_SOCKET_SOCKS_CLIENT_SOCKET_POOL_H_ |
6 #define NET_SOCKET_SOCKS_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_SOCKS_CLIENT_SOCKET_POOL_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
16 #include "net/dns/host_resolver.h" | 16 #include "net/dns/host_resolver.h" |
17 #include "net/socket/client_socket_pool.h" | 17 #include "net/socket/client_socket_pool.h" |
18 #include "net/socket/client_socket_pool_base.h" | 18 #include "net/socket/client_socket_pool_base.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 class ConnectJobFactory; | 22 class ConnectJobFactory; |
23 class SocketPerformanceWatcherFactory; | 23 class SocketPerformanceWatcherFactory; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // success and ERR_IO_PENDING if it cannot immediately service the request. | 90 // success and ERR_IO_PENDING if it cannot immediately service the request. |
91 // Otherwise, it returns a net error code. | 91 // Otherwise, it returns a net error code. |
92 int ConnectInternal() override; | 92 int ConnectInternal() override; |
93 | 93 |
94 scoped_refptr<SOCKSSocketParams> socks_params_; | 94 scoped_refptr<SOCKSSocketParams> socks_params_; |
95 TransportClientSocketPool* const transport_pool_; | 95 TransportClientSocketPool* const transport_pool_; |
96 HostResolver* const resolver_; | 96 HostResolver* const resolver_; |
97 | 97 |
98 State next_state_; | 98 State next_state_; |
99 CompletionCallback callback_; | 99 CompletionCallback callback_; |
100 scoped_ptr<ClientSocketHandle> transport_socket_handle_; | 100 std::unique_ptr<ClientSocketHandle> transport_socket_handle_; |
101 scoped_ptr<StreamSocket> socket_; | 101 std::unique_ptr<StreamSocket> socket_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJob); | 103 DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJob); |
104 }; | 104 }; |
105 | 105 |
106 class NET_EXPORT_PRIVATE SOCKSClientSocketPool | 106 class NET_EXPORT_PRIVATE SOCKSClientSocketPool |
107 : public ClientSocketPool, public HigherLayeredPool { | 107 : public ClientSocketPool, public HigherLayeredPool { |
108 public: | 108 public: |
109 typedef SOCKSSocketParams SocketParams; | 109 typedef SOCKSSocketParams SocketParams; |
110 | 110 |
111 SOCKSClientSocketPool(int max_sockets, | 111 SOCKSClientSocketPool(int max_sockets, |
(...skipping 16 matching lines...) Expand all Loading... |
128 | 128 |
129 void RequestSockets(const std::string& group_name, | 129 void RequestSockets(const std::string& group_name, |
130 const void* params, | 130 const void* params, |
131 int num_sockets, | 131 int num_sockets, |
132 const BoundNetLog& net_log) override; | 132 const BoundNetLog& net_log) override; |
133 | 133 |
134 void CancelRequest(const std::string& group_name, | 134 void CancelRequest(const std::string& group_name, |
135 ClientSocketHandle* handle) override; | 135 ClientSocketHandle* handle) override; |
136 | 136 |
137 void ReleaseSocket(const std::string& group_name, | 137 void ReleaseSocket(const std::string& group_name, |
138 scoped_ptr<StreamSocket> socket, | 138 std::unique_ptr<StreamSocket> socket, |
139 int id) override; | 139 int id) override; |
140 | 140 |
141 void FlushWithError(int error) override; | 141 void FlushWithError(int error) override; |
142 | 142 |
143 void CloseIdleSockets() override; | 143 void CloseIdleSockets() override; |
144 | 144 |
145 int IdleSocketCount() const override; | 145 int IdleSocketCount() const override; |
146 | 146 |
147 int IdleSocketCountInGroup(const std::string& group_name) const override; | 147 int IdleSocketCountInGroup(const std::string& group_name) const override; |
148 | 148 |
149 LoadState GetLoadState(const std::string& group_name, | 149 LoadState GetLoadState(const std::string& group_name, |
150 const ClientSocketHandle* handle) const override; | 150 const ClientSocketHandle* handle) const override; |
151 | 151 |
152 scoped_ptr<base::DictionaryValue> GetInfoAsValue( | 152 std::unique_ptr<base::DictionaryValue> GetInfoAsValue( |
153 const std::string& name, | 153 const std::string& name, |
154 const std::string& type, | 154 const std::string& type, |
155 bool include_nested_pools) const override; | 155 bool include_nested_pools) const override; |
156 | 156 |
157 base::TimeDelta ConnectionTimeout() const override; | 157 base::TimeDelta ConnectionTimeout() const override; |
158 | 158 |
159 // LowerLayeredPool implementation. | 159 // LowerLayeredPool implementation. |
160 bool IsStalled() const override; | 160 bool IsStalled() const override; |
161 | 161 |
162 void AddHigherLayeredPool(HigherLayeredPool* higher_pool) override; | 162 void AddHigherLayeredPool(HigherLayeredPool* higher_pool) override; |
(...skipping 11 matching lines...) Expand all Loading... |
174 SOCKSConnectJobFactory(TransportClientSocketPool* transport_pool, | 174 SOCKSConnectJobFactory(TransportClientSocketPool* transport_pool, |
175 HostResolver* host_resolver, | 175 HostResolver* host_resolver, |
176 NetLog* net_log) | 176 NetLog* net_log) |
177 : transport_pool_(transport_pool), | 177 : transport_pool_(transport_pool), |
178 host_resolver_(host_resolver), | 178 host_resolver_(host_resolver), |
179 net_log_(net_log) {} | 179 net_log_(net_log) {} |
180 | 180 |
181 ~SOCKSConnectJobFactory() override {} | 181 ~SOCKSConnectJobFactory() override {} |
182 | 182 |
183 // ClientSocketPoolBase::ConnectJobFactory methods. | 183 // ClientSocketPoolBase::ConnectJobFactory methods. |
184 scoped_ptr<ConnectJob> NewConnectJob( | 184 std::unique_ptr<ConnectJob> NewConnectJob( |
185 const std::string& group_name, | 185 const std::string& group_name, |
186 const PoolBase::Request& request, | 186 const PoolBase::Request& request, |
187 ConnectJob::Delegate* delegate) const override; | 187 ConnectJob::Delegate* delegate) const override; |
188 | 188 |
189 base::TimeDelta ConnectionTimeout() const override; | 189 base::TimeDelta ConnectionTimeout() const override; |
190 | 190 |
191 private: | 191 private: |
192 TransportClientSocketPool* const transport_pool_; | 192 TransportClientSocketPool* const transport_pool_; |
193 HostResolver* const host_resolver_; | 193 HostResolver* const host_resolver_; |
194 NetLog* net_log_; | 194 NetLog* net_log_; |
195 | 195 |
196 DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJobFactory); | 196 DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJobFactory); |
197 }; | 197 }; |
198 | 198 |
199 TransportClientSocketPool* const transport_pool_; | 199 TransportClientSocketPool* const transport_pool_; |
200 PoolBase base_; | 200 PoolBase base_; |
201 | 201 |
202 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocketPool); | 202 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocketPool); |
203 }; | 203 }; |
204 | 204 |
205 } // namespace net | 205 } // namespace net |
206 | 206 |
207 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_POOL_H_ | 207 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |