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 #include "net/socket/tcp_client_socket.h" | 5 #include "net/socket/tcp_client_socket.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <netdb.h> | 9 #include <netdb.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
11 #include <netinet/tcp.h> | 11 #include <netinet/tcp.h> |
12 #if defined(OS_POSIX) | 12 #if defined(OS_POSIX) |
13 #include <netinet/in.h> | 13 #include <netinet/in.h> |
14 #endif | 14 #endif |
15 | 15 |
16 #include "base/eintr_wrapper.h" | 16 #include "base/eintr_wrapper.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
19 #include "base/metrics/stats_counters.h" | 19 #include "base/metrics/stats_counters.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "net/base/address_list_net_log_param.h" | |
22 #include "net/base/connection_type_histograms.h" | 21 #include "net/base/connection_type_histograms.h" |
23 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
24 #include "net/base/ip_endpoint.h" | 23 #include "net/base/ip_endpoint.h" |
25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
26 #include "net/base/net_log.h" | 25 #include "net/base/net_log.h" |
27 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
28 #include "net/base/network_change_notifier.h" | 27 #include "net/base/network_change_notifier.h" |
29 #include "net/socket/socket_error_params.h" | 28 #include "net/socket/socket_error_params.h" |
30 | 29 |
31 namespace net { | 30 namespace net { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 205 |
207 // If already connected, then just return OK. | 206 // If already connected, then just return OK. |
208 if (socket_ != kInvalidSocket) | 207 if (socket_ != kInvalidSocket) |
209 return OK; | 208 return OK; |
210 | 209 |
211 base::StatsCounter connects("tcp.connect"); | 210 base::StatsCounter connects("tcp.connect"); |
212 connects.Increment(); | 211 connects.Increment(); |
213 | 212 |
214 DCHECK(!waiting_connect()); | 213 DCHECK(!waiting_connect()); |
215 | 214 |
216 net_log_.BeginEvent( | 215 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT, |
217 NetLog::TYPE_TCP_CONNECT, | 216 addresses_.CreateNetLogCallback()); |
218 make_scoped_refptr(new AddressListNetLogParam(addresses_))); | |
219 | 217 |
220 // We will try to connect to each address in addresses_. Start with the | 218 // We will try to connect to each address in addresses_. Start with the |
221 // first one in the list. | 219 // first one in the list. |
222 next_connect_state_ = CONNECT_STATE_CONNECT; | 220 next_connect_state_ = CONNECT_STATE_CONNECT; |
223 current_address_index_ = 0; | 221 current_address_index_ = 0; |
224 | 222 |
225 int rv = DoConnectLoop(OK); | 223 int rv = DoConnectLoop(OK); |
226 if (rv == ERR_IO_PENDING) { | 224 if (rv == ERR_IO_PENDING) { |
227 // Synchronous operation not supported. | 225 // Synchronous operation not supported. |
228 DCHECK(!callback.is_null()); | 226 DCHECK(!callback.is_null()); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 761 |
764 base::TimeDelta TCPClientSocketLibevent::GetConnectTimeMicros() const { | 762 base::TimeDelta TCPClientSocketLibevent::GetConnectTimeMicros() const { |
765 return connect_time_micros_; | 763 return connect_time_micros_; |
766 } | 764 } |
767 | 765 |
768 NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const { | 766 NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const { |
769 return kProtoUnknown; | 767 return kProtoUnknown; |
770 } | 768 } |
771 | 769 |
772 } // namespace net | 770 } // namespace net |
OLD | NEW |