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_win.h" | 5 #include "net/socket/tcp_socket_win.h" |
6 | 6 |
7 #include <mstcpip.h> | 7 #include <mstcpip.h> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 634 } |
635 | 635 |
636 bool TCPSocketWin::SetNoDelay(bool no_delay) { | 636 bool TCPSocketWin::SetNoDelay(bool no_delay) { |
637 return DisableNagle(socket_, no_delay); | 637 return DisableNagle(socket_, no_delay); |
638 } | 638 } |
639 | 639 |
640 void TCPSocketWin::Close() { | 640 void TCPSocketWin::Close() { |
641 DCHECK(CalledOnValidThread()); | 641 DCHECK(CalledOnValidThread()); |
642 | 642 |
643 if (socket_ != INVALID_SOCKET) { | 643 if (socket_ != INVALID_SOCKET) { |
| 644 // Only log the close event if there's actually a socket to close. |
| 645 net_log_.AddEvent(NetLog::EventType::TYPE_SOCKET_CLOSED); |
| 646 |
644 // Note: don't use CancelIo to cancel pending IO because it doesn't work | 647 // Note: don't use CancelIo to cancel pending IO because it doesn't work |
645 // when there is a Winsock layered service provider. | 648 // when there is a Winsock layered service provider. |
646 | 649 |
647 // In most socket implementations, closing a socket results in a graceful | 650 // In most socket implementations, closing a socket results in a graceful |
648 // connection shutdown, but in Winsock we have to call shutdown explicitly. | 651 // connection shutdown, but in Winsock we have to call shutdown explicitly. |
649 // See the MSDN page "Graceful Shutdown, Linger Options, and Socket Closure" | 652 // See the MSDN page "Graceful Shutdown, Linger Options, and Socket Closure" |
650 // at http://msdn.microsoft.com/en-us/library/ms738547.aspx | 653 // at http://msdn.microsoft.com/en-us/library/ms738547.aspx |
651 shutdown(socket_, SD_SEND); | 654 shutdown(socket_, SD_SEND); |
652 | 655 |
653 // This cancels any pending IO. | 656 // This cancels any pending IO. |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 waiting_read_ = false; | 1015 waiting_read_ = false; |
1013 core_->read_iobuffer_ = NULL; | 1016 core_->read_iobuffer_ = NULL; |
1014 core_->read_buffer_length_ = 0; | 1017 core_->read_buffer_length_ = 0; |
1015 | 1018 |
1016 DCHECK_NE(rv, ERR_IO_PENDING); | 1019 DCHECK_NE(rv, ERR_IO_PENDING); |
1017 base::ResetAndReturn(&read_callback_).Run(rv); | 1020 base::ResetAndReturn(&read_callback_).Run(rv); |
1018 } | 1021 } |
1019 | 1022 |
1020 } // namespace net | 1023 } // namespace net |
1021 | 1024 |
OLD | NEW |