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/tcp_client_socket_pool.h" | 5 #include "net/socket/tcp_client_socket_pool.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return LOAD_STATE_RESOLVING_HOST; | 90 return LOAD_STATE_RESOLVING_HOST; |
91 case STATE_TCP_CONNECT: | 91 case STATE_TCP_CONNECT: |
92 case STATE_TCP_CONNECT_COMPLETE: | 92 case STATE_TCP_CONNECT_COMPLETE: |
93 return LOAD_STATE_CONNECTING; | 93 return LOAD_STATE_CONNECTING; |
94 default: | 94 default: |
95 NOTREACHED(); | 95 NOTREACHED(); |
96 return LOAD_STATE_IDLE; | 96 return LOAD_STATE_IDLE; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 int TCPConnectJob::ConnectInternal() { | |
101 next_state_ = STATE_RESOLVE_HOST; | |
102 start_time_ = base::TimeTicks::Now(); | |
103 return DoLoop(OK); | |
104 } | |
105 | |
106 void TCPConnectJob::OnIOComplete(int result) { | 100 void TCPConnectJob::OnIOComplete(int result) { |
107 int rv = DoLoop(result); | 101 int rv = DoLoop(result); |
108 if (rv != ERR_IO_PENDING) | 102 if (rv != ERR_IO_PENDING) |
109 NotifyDelegateOfCompletion(rv); // Deletes |this| | 103 NotifyDelegateOfCompletion(rv); // Deletes |this| |
110 } | 104 } |
111 | 105 |
112 int TCPConnectJob::DoLoop(int result) { | 106 int TCPConnectJob::DoLoop(int result) { |
113 DCHECK_NE(next_state_, STATE_NONE); | 107 DCHECK_NE(next_state_, STATE_NONE); |
114 | 108 |
115 int rv = result; | 109 int rv = result; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 base::TimeDelta::FromMinutes(10), | 175 base::TimeDelta::FromMinutes(10), |
182 100); | 176 100); |
183 } else { | 177 } else { |
184 // Delete the socket on error. | 178 // Delete the socket on error. |
185 set_socket(NULL); | 179 set_socket(NULL); |
186 } | 180 } |
187 | 181 |
188 return result; | 182 return result; |
189 } | 183 } |
190 | 184 |
| 185 int TCPConnectJob::ConnectInternal() { |
| 186 next_state_ = STATE_RESOLVE_HOST; |
| 187 start_time_ = base::TimeTicks::Now(); |
| 188 return DoLoop(OK); |
| 189 } |
| 190 |
191 ConnectJob* TCPClientSocketPool::TCPConnectJobFactory::NewConnectJob( | 191 ConnectJob* TCPClientSocketPool::TCPConnectJobFactory::NewConnectJob( |
192 const std::string& group_name, | 192 const std::string& group_name, |
193 const PoolBase::Request& request, | 193 const PoolBase::Request& request, |
194 ConnectJob::Delegate* delegate) const { | 194 ConnectJob::Delegate* delegate) const { |
195 return new TCPConnectJob(group_name, request.params(), ConnectionTimeout(), | 195 return new TCPConnectJob(group_name, request.params(), ConnectionTimeout(), |
196 client_socket_factory_, host_resolver_, delegate, | 196 client_socket_factory_, host_resolver_, delegate, |
197 net_log_); | 197 net_log_); |
198 } | 198 } |
199 | 199 |
200 base::TimeDelta | 200 base::TimeDelta |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 307 |
308 base::TimeDelta TCPClientSocketPool::ConnectionTimeout() const { | 308 base::TimeDelta TCPClientSocketPool::ConnectionTimeout() const { |
309 return base_.ConnectionTimeout(); | 309 return base_.ConnectionTimeout(); |
310 } | 310 } |
311 | 311 |
312 ClientSocketPoolHistograms* TCPClientSocketPool::histograms() const { | 312 ClientSocketPoolHistograms* TCPClientSocketPool::histograms() const { |
313 return base_.histograms(); | 313 return base_.histograms(); |
314 } | 314 } |
315 | 315 |
316 } // namespace net | 316 } // namespace net |
OLD | NEW |