OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/memory_debug.h" | |
12 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
14 #include "base/win/object_watcher.h" | 13 #include "base/win/object_watcher.h" |
15 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
16 #include "net/base/address_list_net_log_param.h" | 15 #include "net/base/address_list_net_log_param.h" |
17 #include "net/base/connection_type_histograms.h" | 16 #include "net/base/connection_type_histograms.h" |
18 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
19 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
20 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
21 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 core_->read_buffer_.len = buf_len; | 682 core_->read_buffer_.len = buf_len; |
684 core_->read_buffer_.buf = buf->data(); | 683 core_->read_buffer_.buf = buf->data(); |
685 | 684 |
686 // TODO(wtc): Remove the assertion after enough testing. | 685 // TODO(wtc): Remove the assertion after enough testing. |
687 AssertEventNotSignaled(core_->read_overlapped_.hEvent); | 686 AssertEventNotSignaled(core_->read_overlapped_.hEvent); |
688 DWORD num, flags = 0; | 687 DWORD num, flags = 0; |
689 int rv = WSARecv(socket_, &core_->read_buffer_, 1, &num, &flags, | 688 int rv = WSARecv(socket_, &core_->read_buffer_, 1, &num, &flags, |
690 &core_->read_overlapped_, NULL); | 689 &core_->read_overlapped_, NULL); |
691 if (rv == 0) { | 690 if (rv == 0) { |
692 if (ResetEventIfSignaled(core_->read_overlapped_.hEvent)) { | 691 if (ResetEventIfSignaled(core_->read_overlapped_.hEvent)) { |
693 // Because of how WSARecv fills memory when used asynchronously, Purify | |
694 // isn't able to detect that it's been initialized, so it scans for 0xcd | |
695 // in the buffer and reports UMRs (uninitialized memory reads) for those | |
696 // individual bytes. We override that in PURIFY builds to avoid the | |
697 // false error reports. | |
698 // See bug 5297. | |
699 base::MemoryDebug::MarkAsInitialized(core_->read_buffer_.buf, num); | |
700 base::StatsCounter read_bytes("tcp.read_bytes"); | 692 base::StatsCounter read_bytes("tcp.read_bytes"); |
701 read_bytes.Add(num); | 693 read_bytes.Add(num); |
702 num_bytes_read_ += num; | 694 num_bytes_read_ += num; |
703 if (num > 0) | 695 if (num > 0) |
704 use_history_.set_was_used_to_convey_data(); | 696 use_history_.set_was_used_to_convey_data(); |
705 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, num, | 697 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, num, |
706 core_->read_buffer_.buf); | 698 core_->read_buffer_.buf); |
707 return static_cast<int>(num); | 699 return static_cast<int>(num); |
708 } | 700 } |
709 } else { | 701 } else { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 use_history_.set_was_used_to_convey_data(); | 898 use_history_.set_was_used_to_convey_data(); |
907 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes, | 899 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes, |
908 core_->write_buffer_.buf); | 900 core_->write_buffer_.buf); |
909 } | 901 } |
910 } | 902 } |
911 core_->write_iobuffer_ = NULL; | 903 core_->write_iobuffer_ = NULL; |
912 DoWriteCallback(rv); | 904 DoWriteCallback(rv); |
913 } | 905 } |
914 | 906 |
915 } // namespace net | 907 } // namespace net |
OLD | NEW |