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_win.h" | 5 #include "net/socket/tcp_client_socket_win.h" |
6 | 6 |
7 #include <mstcpip.h> | 7 #include <mstcpip.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/win/object_watcher.h" | 13 #include "base/win/object_watcher.h" |
14 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
15 #include "net/base/address_list_net_log_param.h" | |
16 #include "net/base/connection_type_histograms.h" | 15 #include "net/base/connection_type_histograms.h" |
17 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
18 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
19 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
20 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
21 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
22 #include "net/base/network_change_notifier.h" | 21 #include "net/base/network_change_notifier.h" |
23 #include "net/base/winsock_init.h" | 22 #include "net/base/winsock_init.h" |
24 #include "net/base/winsock_util.h" | 23 #include "net/base/winsock_util.h" |
25 #include "net/socket/socket_error_params.h" | 24 #include "net/socket/socket_error_params.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 DCHECK(CalledOnValidThread()); | 398 DCHECK(CalledOnValidThread()); |
400 | 399 |
401 // If already connected, then just return OK. | 400 // If already connected, then just return OK. |
402 if (socket_ != INVALID_SOCKET) | 401 if (socket_ != INVALID_SOCKET) |
403 return OK; | 402 return OK; |
404 | 403 |
405 base::StatsCounter connects("tcp.connect"); | 404 base::StatsCounter connects("tcp.connect"); |
406 connects.Increment(); | 405 connects.Increment(); |
407 | 406 |
408 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT, | 407 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT, |
409 new AddressListNetLogParam(addresses_)); | 408 addresses_.CreateNetLogCallback()); |
410 | 409 |
411 // We will try to connect to each address in addresses_. Start with the | 410 // We will try to connect to each address in addresses_. Start with the |
412 // first one in the list. | 411 // first one in the list. |
413 next_connect_state_ = CONNECT_STATE_CONNECT; | 412 next_connect_state_ = CONNECT_STATE_CONNECT; |
414 current_address_index_ = 0; | 413 current_address_index_ = 0; |
415 | 414 |
416 int rv = DoConnectLoop(OK); | 415 int rv = DoConnectLoop(OK); |
417 if (rv == ERR_IO_PENDING) { | 416 if (rv == ERR_IO_PENDING) { |
418 // Synchronous operation not supported. | 417 // Synchronous operation not supported. |
419 DCHECK(!callback.is_null()); | 418 DCHECK(!callback.is_null()); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 use_history_.set_was_used_to_convey_data(); | 945 use_history_.set_was_used_to_convey_data(); |
947 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes, | 946 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes, |
948 core_->write_buffer_.buf); | 947 core_->write_buffer_.buf); |
949 } | 948 } |
950 } | 949 } |
951 core_->write_iobuffer_ = NULL; | 950 core_->write_iobuffer_ = NULL; |
952 DoWriteCallback(rv); | 951 DoWriteCallback(rv); |
953 } | 952 } |
954 | 953 |
955 } // namespace net | 954 } // namespace net |
OLD | NEW |