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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 RequestPriority priority, | 59 RequestPriority priority, |
60 const scoped_refptr<SOCKSSocketParams>& params, | 60 const scoped_refptr<SOCKSSocketParams>& params, |
61 const base::TimeDelta& timeout_duration, | 61 const base::TimeDelta& timeout_duration, |
62 TransportClientSocketPool* transport_pool, | 62 TransportClientSocketPool* transport_pool, |
63 HostResolver* host_resolver, | 63 HostResolver* host_resolver, |
64 Delegate* delegate, | 64 Delegate* delegate, |
65 NetLog* net_log); | 65 NetLog* net_log); |
66 virtual ~SOCKSConnectJob(); | 66 virtual ~SOCKSConnectJob(); |
67 | 67 |
68 // ConnectJob methods. | 68 // ConnectJob methods. |
69 virtual LoadState GetLoadState() const OVERRIDE; | 69 virtual LoadState GetLoadState() const override; |
70 | 70 |
71 private: | 71 private: |
72 enum State { | 72 enum State { |
73 STATE_TRANSPORT_CONNECT, | 73 STATE_TRANSPORT_CONNECT, |
74 STATE_TRANSPORT_CONNECT_COMPLETE, | 74 STATE_TRANSPORT_CONNECT_COMPLETE, |
75 STATE_SOCKS_CONNECT, | 75 STATE_SOCKS_CONNECT, |
76 STATE_SOCKS_CONNECT_COMPLETE, | 76 STATE_SOCKS_CONNECT_COMPLETE, |
77 STATE_NONE, | 77 STATE_NONE, |
78 }; | 78 }; |
79 | 79 |
80 void OnIOComplete(int result); | 80 void OnIOComplete(int result); |
81 | 81 |
82 // Runs the state transition loop. | 82 // Runs the state transition loop. |
83 int DoLoop(int result); | 83 int DoLoop(int result); |
84 | 84 |
85 int DoTransportConnect(); | 85 int DoTransportConnect(); |
86 int DoTransportConnectComplete(int result); | 86 int DoTransportConnectComplete(int result); |
87 int DoSOCKSConnect(); | 87 int DoSOCKSConnect(); |
88 int DoSOCKSConnectComplete(int result); | 88 int DoSOCKSConnectComplete(int result); |
89 | 89 |
90 // Begins the transport connection and the SOCKS handshake. Returns OK on | 90 // Begins the transport connection and the SOCKS handshake. Returns OK on |
91 // success and ERR_IO_PENDING if it cannot immediately service the request. | 91 // success and ERR_IO_PENDING if it cannot immediately service the request. |
92 // Otherwise, it returns a net error code. | 92 // Otherwise, it returns a net error code. |
93 virtual int ConnectInternal() OVERRIDE; | 93 virtual int ConnectInternal() override; |
94 | 94 |
95 scoped_refptr<SOCKSSocketParams> socks_params_; | 95 scoped_refptr<SOCKSSocketParams> socks_params_; |
96 TransportClientSocketPool* const transport_pool_; | 96 TransportClientSocketPool* const transport_pool_; |
97 HostResolver* const resolver_; | 97 HostResolver* const resolver_; |
98 | 98 |
99 State next_state_; | 99 State next_state_; |
100 CompletionCallback callback_; | 100 CompletionCallback callback_; |
101 scoped_ptr<ClientSocketHandle> transport_socket_handle_; | 101 scoped_ptr<ClientSocketHandle> transport_socket_handle_; |
102 scoped_ptr<StreamSocket> socket_; | 102 scoped_ptr<StreamSocket> socket_; |
103 | 103 |
(...skipping 14 matching lines...) Expand all Loading... |
118 NetLog* net_log); | 118 NetLog* net_log); |
119 | 119 |
120 virtual ~SOCKSClientSocketPool(); | 120 virtual ~SOCKSClientSocketPool(); |
121 | 121 |
122 // ClientSocketPool implementation. | 122 // ClientSocketPool implementation. |
123 virtual int RequestSocket(const std::string& group_name, | 123 virtual int RequestSocket(const std::string& group_name, |
124 const void* connect_params, | 124 const void* connect_params, |
125 RequestPriority priority, | 125 RequestPriority priority, |
126 ClientSocketHandle* handle, | 126 ClientSocketHandle* handle, |
127 const CompletionCallback& callback, | 127 const CompletionCallback& callback, |
128 const BoundNetLog& net_log) OVERRIDE; | 128 const BoundNetLog& net_log) override; |
129 | 129 |
130 virtual void RequestSockets(const std::string& group_name, | 130 virtual void RequestSockets(const std::string& group_name, |
131 const void* params, | 131 const void* params, |
132 int num_sockets, | 132 int num_sockets, |
133 const BoundNetLog& net_log) OVERRIDE; | 133 const BoundNetLog& net_log) override; |
134 | 134 |
135 virtual void CancelRequest(const std::string& group_name, | 135 virtual void CancelRequest(const std::string& group_name, |
136 ClientSocketHandle* handle) OVERRIDE; | 136 ClientSocketHandle* handle) override; |
137 | 137 |
138 virtual void ReleaseSocket(const std::string& group_name, | 138 virtual void ReleaseSocket(const std::string& group_name, |
139 scoped_ptr<StreamSocket> socket, | 139 scoped_ptr<StreamSocket> socket, |
140 int id) OVERRIDE; | 140 int id) override; |
141 | 141 |
142 virtual void FlushWithError(int error) OVERRIDE; | 142 virtual void FlushWithError(int error) override; |
143 | 143 |
144 virtual void CloseIdleSockets() OVERRIDE; | 144 virtual void CloseIdleSockets() override; |
145 | 145 |
146 virtual int IdleSocketCount() const OVERRIDE; | 146 virtual int IdleSocketCount() const override; |
147 | 147 |
148 virtual int IdleSocketCountInGroup( | 148 virtual int IdleSocketCountInGroup( |
149 const std::string& group_name) const OVERRIDE; | 149 const std::string& group_name) const override; |
150 | 150 |
151 virtual LoadState GetLoadState( | 151 virtual LoadState GetLoadState( |
152 const std::string& group_name, | 152 const std::string& group_name, |
153 const ClientSocketHandle* handle) const OVERRIDE; | 153 const ClientSocketHandle* handle) const override; |
154 | 154 |
155 virtual base::DictionaryValue* GetInfoAsValue( | 155 virtual base::DictionaryValue* GetInfoAsValue( |
156 const std::string& name, | 156 const std::string& name, |
157 const std::string& type, | 157 const std::string& type, |
158 bool include_nested_pools) const OVERRIDE; | 158 bool include_nested_pools) const override; |
159 | 159 |
160 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 160 virtual base::TimeDelta ConnectionTimeout() const override; |
161 | 161 |
162 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE; | 162 virtual ClientSocketPoolHistograms* histograms() const override; |
163 | 163 |
164 // LowerLayeredPool implementation. | 164 // LowerLayeredPool implementation. |
165 virtual bool IsStalled() const OVERRIDE; | 165 virtual bool IsStalled() const override; |
166 | 166 |
167 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 167 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) override; |
168 | 168 |
169 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 169 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) override; |
170 | 170 |
171 // HigherLayeredPool implementation. | 171 // HigherLayeredPool implementation. |
172 virtual bool CloseOneIdleConnection() OVERRIDE; | 172 virtual bool CloseOneIdleConnection() override; |
173 | 173 |
174 private: | 174 private: |
175 typedef ClientSocketPoolBase<SOCKSSocketParams> PoolBase; | 175 typedef ClientSocketPoolBase<SOCKSSocketParams> PoolBase; |
176 | 176 |
177 class SOCKSConnectJobFactory : public PoolBase::ConnectJobFactory { | 177 class SOCKSConnectJobFactory : public PoolBase::ConnectJobFactory { |
178 public: | 178 public: |
179 SOCKSConnectJobFactory(TransportClientSocketPool* transport_pool, | 179 SOCKSConnectJobFactory(TransportClientSocketPool* transport_pool, |
180 HostResolver* host_resolver, | 180 HostResolver* host_resolver, |
181 NetLog* net_log) | 181 NetLog* net_log) |
182 : transport_pool_(transport_pool), | 182 : transport_pool_(transport_pool), |
183 host_resolver_(host_resolver), | 183 host_resolver_(host_resolver), |
184 net_log_(net_log) {} | 184 net_log_(net_log) {} |
185 | 185 |
186 virtual ~SOCKSConnectJobFactory() {} | 186 virtual ~SOCKSConnectJobFactory() {} |
187 | 187 |
188 // ClientSocketPoolBase::ConnectJobFactory methods. | 188 // ClientSocketPoolBase::ConnectJobFactory methods. |
189 virtual scoped_ptr<ConnectJob> NewConnectJob( | 189 virtual scoped_ptr<ConnectJob> NewConnectJob( |
190 const std::string& group_name, | 190 const std::string& group_name, |
191 const PoolBase::Request& request, | 191 const PoolBase::Request& request, |
192 ConnectJob::Delegate* delegate) const OVERRIDE; | 192 ConnectJob::Delegate* delegate) const override; |
193 | 193 |
194 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 194 virtual base::TimeDelta ConnectionTimeout() const override; |
195 | 195 |
196 private: | 196 private: |
197 TransportClientSocketPool* const transport_pool_; | 197 TransportClientSocketPool* const transport_pool_; |
198 HostResolver* const host_resolver_; | 198 HostResolver* const host_resolver_; |
199 NetLog* net_log_; | 199 NetLog* net_log_; |
200 | 200 |
201 DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJobFactory); | 201 DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJobFactory); |
202 }; | 202 }; |
203 | 203 |
204 TransportClientSocketPool* const transport_pool_; | 204 TransportClientSocketPool* const transport_pool_; |
205 PoolBase base_; | 205 PoolBase base_; |
206 | 206 |
207 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocketPool); | 207 DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocketPool); |
208 }; | 208 }; |
209 | 209 |
210 } // namespace net | 210 } // namespace net |
211 | 211 |
212 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_POOL_H_ | 212 #endif // NET_SOCKET_SOCKS_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |