| 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/basictypes.h" |
| 9 #include "base/callback.h" | 10 #include "base/callback.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/metrics/stats_counters.h" | 16 #include "base/metrics/stats_counters.h" |
| 16 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
| 17 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 18 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 // page "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" for the gory details. | 802 // page "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" for the gory details. |
| 802 if (last_error == WSAEACCES || last_error == WSAEADDRNOTAVAIL) | 803 if (last_error == WSAEACCES || last_error == WSAEADDRNOTAVAIL) |
| 803 return ERR_ADDRESS_IN_USE; | 804 return ERR_ADDRESS_IN_USE; |
| 804 return MapSystemError(last_error); | 805 return MapSystemError(last_error); |
| 805 } | 806 } |
| 806 | 807 |
| 807 int UDPSocketWin::RandomBind(const IPAddressNumber& address) { | 808 int UDPSocketWin::RandomBind(const IPAddressNumber& address) { |
| 808 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null()); | 809 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null()); |
| 809 | 810 |
| 810 for (int i = 0; i < kBindRetries; ++i) { | 811 for (int i = 0; i < kBindRetries; ++i) { |
| 811 int rv = DoBind(IPEndPoint(address, | 812 int rv = DoBind(IPEndPoint( |
| 812 rand_int_cb_.Run(kPortStart, kPortEnd))); | 813 address, static_cast<uint16>(rand_int_cb_.Run(kPortStart, kPortEnd)))); |
| 813 if (rv == OK || rv != ERR_ADDRESS_IN_USE) | 814 if (rv == OK || rv != ERR_ADDRESS_IN_USE) |
| 814 return rv; | 815 return rv; |
| 815 } | 816 } |
| 816 return DoBind(IPEndPoint(address, 0)); | 817 return DoBind(IPEndPoint(address, 0)); |
| 817 } | 818 } |
| 818 | 819 |
| 819 bool UDPSocketWin::ReceiveAddressToIPEndpoint(IPEndPoint* address) const { | 820 bool UDPSocketWin::ReceiveAddressToIPEndpoint(IPEndPoint* address) const { |
| 820 SockaddrStorage& storage = core_->recv_addr_storage_; | 821 SockaddrStorage& storage = core_->recv_addr_storage_; |
| 821 return address->FromSockAddr(storage.addr, storage.addr_len); | 822 return address->FromSockAddr(storage.addr, storage.addr_len); |
| 822 } | 823 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 NULL); | 1020 NULL); |
| 1020 | 1021 |
| 1021 return OK; | 1022 return OK; |
| 1022 } | 1023 } |
| 1023 | 1024 |
| 1024 void UDPSocketWin::DetachFromThread() { | 1025 void UDPSocketWin::DetachFromThread() { |
| 1025 base::NonThreadSafe::DetachFromThread(); | 1026 base::NonThreadSafe::DetachFromThread(); |
| 1026 } | 1027 } |
| 1027 | 1028 |
| 1028 } // namespace net | 1029 } // namespace net |
| OLD | NEW |