OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/socket/socks_client_socket_pool.h" | 5 #include "net/socket/socks_client_socket_pool.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return tcp_socket_handle_->GetLoadState(); | 68 return tcp_socket_handle_->GetLoadState(); |
69 case STATE_SOCKS_CONNECT: | 69 case STATE_SOCKS_CONNECT: |
70 case STATE_SOCKS_CONNECT_COMPLETE: | 70 case STATE_SOCKS_CONNECT_COMPLETE: |
71 return LOAD_STATE_CONNECTING; | 71 return LOAD_STATE_CONNECTING; |
72 default: | 72 default: |
73 NOTREACHED(); | 73 NOTREACHED(); |
74 return LOAD_STATE_IDLE; | 74 return LOAD_STATE_IDLE; |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 int SOCKSConnectJob::ConnectInternal() { | |
79 next_state_ = STATE_TCP_CONNECT; | |
80 return DoLoop(OK); | |
81 } | |
82 | |
83 void SOCKSConnectJob::OnIOComplete(int result) { | 78 void SOCKSConnectJob::OnIOComplete(int result) { |
84 int rv = DoLoop(result); | 79 int rv = DoLoop(result); |
85 if (rv != ERR_IO_PENDING) | 80 if (rv != ERR_IO_PENDING) |
86 NotifyDelegateOfCompletion(rv); // Deletes |this| | 81 NotifyDelegateOfCompletion(rv); // Deletes |this| |
87 } | 82 } |
88 | 83 |
89 int SOCKSConnectJob::DoLoop(int result) { | 84 int SOCKSConnectJob::DoLoop(int result) { |
90 DCHECK_NE(next_state_, STATE_NONE); | 85 DCHECK_NE(next_state_, STATE_NONE); |
91 | 86 |
92 int rv = result; | 87 int rv = result; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 int SOCKSConnectJob::DoSOCKSConnectComplete(int result) { | 151 int SOCKSConnectJob::DoSOCKSConnectComplete(int result) { |
157 if (result != OK) { | 152 if (result != OK) { |
158 socket_->Disconnect(); | 153 socket_->Disconnect(); |
159 return result; | 154 return result; |
160 } | 155 } |
161 | 156 |
162 set_socket(socket_.release()); | 157 set_socket(socket_.release()); |
163 return result; | 158 return result; |
164 } | 159 } |
165 | 160 |
| 161 int SOCKSConnectJob::ConnectInternal() { |
| 162 next_state_ = STATE_TCP_CONNECT; |
| 163 return DoLoop(OK); |
| 164 } |
| 165 |
166 ConnectJob* SOCKSClientSocketPool::SOCKSConnectJobFactory::NewConnectJob( | 166 ConnectJob* SOCKSClientSocketPool::SOCKSConnectJobFactory::NewConnectJob( |
167 const std::string& group_name, | 167 const std::string& group_name, |
168 const PoolBase::Request& request, | 168 const PoolBase::Request& request, |
169 ConnectJob::Delegate* delegate) const { | 169 ConnectJob::Delegate* delegate) const { |
170 return new SOCKSConnectJob(group_name, request.params(), ConnectionTimeout(), | 170 return new SOCKSConnectJob(group_name, request.params(), ConnectionTimeout(), |
171 tcp_pool_, host_resolver_, delegate, net_log_); | 171 tcp_pool_, host_resolver_, delegate, net_log_); |
172 } | 172 } |
173 | 173 |
174 base::TimeDelta | 174 base::TimeDelta |
175 SOCKSClientSocketPool::SOCKSConnectJobFactory::ConnectionTimeout() const { | 175 SOCKSClientSocketPool::SOCKSConnectJobFactory::ConnectionTimeout() const { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 267 |
268 base::TimeDelta SOCKSClientSocketPool::ConnectionTimeout() const { | 268 base::TimeDelta SOCKSClientSocketPool::ConnectionTimeout() const { |
269 return base_.ConnectionTimeout(); | 269 return base_.ConnectionTimeout(); |
270 } | 270 } |
271 | 271 |
272 ClientSocketPoolHistograms* SOCKSClientSocketPool::histograms() const { | 272 ClientSocketPoolHistograms* SOCKSClientSocketPool::histograms() const { |
273 return base_.histograms(); | 273 return base_.histograms(); |
274 }; | 274 }; |
275 | 275 |
276 } // namespace net | 276 } // namespace net |
OLD | NEW |