OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_socket.h" | 5 #include "net/socket/tcp_socket.h" |
6 #include "net/socket/tcp_socket_win.h" | 6 #include "net/socket/tcp_socket_win.h" |
7 | 7 |
8 #include <mstcpip.h> | 8 #include <mstcpip.h> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 accept_socket_ = socket; | 418 accept_socket_ = socket; |
419 accept_address_ = address; | 419 accept_address_ = address; |
420 accept_callback_ = callback; | 420 accept_callback_ = callback; |
421 } | 421 } |
422 | 422 |
423 return result; | 423 return result; |
424 } | 424 } |
425 | 425 |
426 int TCPSocketWin::Connect(const IPEndPoint& address, | 426 int TCPSocketWin::Connect(const IPEndPoint& address, |
427 const CompletionCallback& callback) { | 427 const CompletionCallback& callback) { |
| 428 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. |
| 429 tracked_objects::ScopedTracker tracking_profile( |
| 430 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPSocketWin::Connect")); |
| 431 |
428 DCHECK(CalledOnValidThread()); | 432 DCHECK(CalledOnValidThread()); |
429 DCHECK_NE(socket_, INVALID_SOCKET); | 433 DCHECK_NE(socket_, INVALID_SOCKET); |
430 DCHECK(!waiting_connect_); | 434 DCHECK(!waiting_connect_); |
431 | 435 |
432 // |peer_address_| and |core_| will be non-NULL if Connect() has been called. | 436 // |peer_address_| and |core_| will be non-NULL if Connect() has been called. |
433 // Unless Close() is called to reset the internal state, a second call to | 437 // Unless Close() is called to reset the internal state, a second call to |
434 // Connect() is not allowed. | 438 // Connect() is not allowed. |
435 // Please note that we enforce this even if the previous Connect() has | 439 // Please note that we enforce this even if the previous Connect() has |
436 // completed and failed. Although it is allowed to connect the same |socket_| | 440 // completed and failed. Although it is allowed to connect the same |socket_| |
437 // again after a connection attempt failed on Windows, it results in | 441 // again after a connection attempt failed on Windows, it results in |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 // have a chance to accept it. | 794 // have a chance to accept it. |
791 DCHECK(ev.lNetworkEvents == 0); | 795 DCHECK(ev.lNetworkEvents == 0); |
792 | 796 |
793 // Start watching the next FD_ACCEPT event. | 797 // Start watching the next FD_ACCEPT event. |
794 WSAEventSelect(socket_, accept_event_, FD_ACCEPT); | 798 WSAEventSelect(socket_, accept_event_, FD_ACCEPT); |
795 accept_watcher_.StartWatching(accept_event_, this); | 799 accept_watcher_.StartWatching(accept_event_, this); |
796 } | 800 } |
797 } | 801 } |
798 | 802 |
799 int TCPSocketWin::DoConnect() { | 803 int TCPSocketWin::DoConnect() { |
| 804 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. |
| 805 tracked_objects::ScopedTracker tracking_profile( |
| 806 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 TCPSocketWin::DoConnect")); |
| 807 |
800 DCHECK_EQ(connect_os_error_, 0); | 808 DCHECK_EQ(connect_os_error_, 0); |
801 DCHECK(!core_.get()); | 809 DCHECK(!core_.get()); |
802 | 810 |
803 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT, | 811 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT, |
804 CreateNetLogIPEndPointCallback(peer_address_.get())); | 812 CreateNetLogIPEndPointCallback(peer_address_.get())); |
805 | 813 |
806 core_ = new Core(this); | 814 core_ = new Core(this); |
807 // WSAEventSelect sets the socket to non-blocking mode as a side effect. | 815 // WSAEventSelect sets the socket to non-blocking mode as a side effect. |
808 // Our connect() and recv() calls require that the socket be non-blocking. | 816 // Our connect() and recv() calls require that the socket be non-blocking. |
809 WSAEventSelect(socket_, core_->read_overlapped_.hEvent, FD_CONNECT); | 817 WSAEventSelect(socket_, core_->read_overlapped_.hEvent, FD_CONNECT); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 core_->read_buffer_length_ = 0; | 1046 core_->read_buffer_length_ = 0; |
1039 | 1047 |
1040 DCHECK_NE(rv, ERR_IO_PENDING); | 1048 DCHECK_NE(rv, ERR_IO_PENDING); |
1041 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. | 1049 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
1042 tracked_objects::ScopedTracker tracking_profile( | 1050 tracked_objects::ScopedTracker tracking_profile( |
1043 FROM_HERE_WITH_EXPLICIT_FUNCTION("TCPSocketWin::DidSignalRead")); | 1051 FROM_HERE_WITH_EXPLICIT_FUNCTION("TCPSocketWin::DidSignalRead")); |
1044 base::ResetAndReturn(&read_callback_).Run(rv); | 1052 base::ResetAndReturn(&read_callback_).Run(rv); |
1045 } | 1053 } |
1046 | 1054 |
1047 } // namespace net | 1055 } // namespace net |
OLD | NEW |