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/udp/udp_socket_win.h" | 5 #include "net/udp/udp_socket_win.h" |
6 | 6 |
7 #include <mstcpip.h> | 7 #include <mstcpip.h> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/metrics/histogram.h" |
12 #include "base/metrics/stats_counters.h" | 13 #include "base/metrics/stats_counters.h" |
13 #include "base/posix/eintr_wrapper.h" | 14 #include "base/posix/eintr_wrapper.h" |
14 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
16 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
18 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
19 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
20 #include "net/base/winsock_init.h" | 21 #include "net/base/winsock_init.h" |
21 #include "net/base/winsock_util.h" | 22 #include "net/base/winsock_util.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 DCHECK(CalledOnValidThread()); | 184 DCHECK(CalledOnValidThread()); |
184 | 185 |
185 if (!is_connected()) | 186 if (!is_connected()) |
186 return; | 187 return; |
187 | 188 |
188 // Zero out any pending read/write callback state. | 189 // Zero out any pending read/write callback state. |
189 read_callback_.Reset(); | 190 read_callback_.Reset(); |
190 recv_from_address_ = NULL; | 191 recv_from_address_ = NULL; |
191 write_callback_.Reset(); | 192 write_callback_.Reset(); |
192 | 193 |
| 194 base::TimeTicks start_time = base::TimeTicks::Now(); |
193 closesocket(socket_); | 195 closesocket(socket_); |
| 196 UMA_HISTOGRAM_TIMES("Net.UDPSocketWinClose", |
| 197 base::TimeTicks::Now() - start_time); |
194 socket_ = INVALID_SOCKET; | 198 socket_ = INVALID_SOCKET; |
195 | 199 |
196 core_->Detach(); | 200 core_->Detach(); |
197 core_ = NULL; | 201 core_ = NULL; |
198 } | 202 } |
199 | 203 |
200 int UDPSocketWin::GetPeerAddress(IPEndPoint* address) const { | 204 int UDPSocketWin::GetPeerAddress(IPEndPoint* address) const { |
201 DCHECK(CalledOnValidThread()); | 205 DCHECK(CalledOnValidThread()); |
202 DCHECK(address); | 206 DCHECK(address); |
203 if (!is_connected()) | 207 if (!is_connected()) |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 } | 606 } |
603 return DoBind(IPEndPoint(ip, 0)); | 607 return DoBind(IPEndPoint(ip, 0)); |
604 } | 608 } |
605 | 609 |
606 bool UDPSocketWin::ReceiveAddressToIPEndpoint(IPEndPoint* address) const { | 610 bool UDPSocketWin::ReceiveAddressToIPEndpoint(IPEndPoint* address) const { |
607 SockaddrStorage& storage = core_->recv_addr_storage_; | 611 SockaddrStorage& storage = core_->recv_addr_storage_; |
608 return address->FromSockAddr(storage.addr, storage.addr_len); | 612 return address->FromSockAddr(storage.addr, storage.addr_len); |
609 } | 613 } |
610 | 614 |
611 } // namespace net | 615 } // namespace net |
OLD | NEW |