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