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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 // page "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" for the gory details. | 798 // page "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" for the gory details. |
799 if (last_error == WSAEACCES || last_error == WSAEADDRNOTAVAIL) | 799 if (last_error == WSAEACCES || last_error == WSAEADDRNOTAVAIL) |
800 return ERR_ADDRESS_IN_USE; | 800 return ERR_ADDRESS_IN_USE; |
801 return MapSystemError(last_error); | 801 return MapSystemError(last_error); |
802 } | 802 } |
803 | 803 |
804 int UDPSocketWin::RandomBind(const IPAddressNumber& address) { | 804 int UDPSocketWin::RandomBind(const IPAddressNumber& address) { |
805 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null()); | 805 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null()); |
806 | 806 |
807 for (int i = 0; i < kBindRetries; ++i) { | 807 for (int i = 0; i < kBindRetries; ++i) { |
808 int rv = DoBind(IPEndPoint(address, | 808 int rv = DoBind(IPEndPoint( |
809 rand_int_cb_.Run(kPortStart, kPortEnd))); | 809 address, static_cast<uint16>(rand_int_cb_.Run(kPortStart, kPortEnd)))); |
810 if (rv == OK || rv != ERR_ADDRESS_IN_USE) | 810 if (rv == OK || rv != ERR_ADDRESS_IN_USE) |
811 return rv; | 811 return rv; |
812 } | 812 } |
813 return DoBind(IPEndPoint(address, 0)); | 813 return DoBind(IPEndPoint(address, 0)); |
814 } | 814 } |
815 | 815 |
816 bool UDPSocketWin::ReceiveAddressToIPEndpoint(IPEndPoint* address) const { | 816 bool UDPSocketWin::ReceiveAddressToIPEndpoint(IPEndPoint* address) const { |
817 SockaddrStorage& storage = core_->recv_addr_storage_; | 817 SockaddrStorage& storage = core_->recv_addr_storage_; |
818 return address->FromSockAddr(storage.addr, storage.addr_len); | 818 return address->FromSockAddr(storage.addr, storage.addr_len); |
819 } | 819 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 NULL); | 1016 NULL); |
1017 | 1017 |
1018 return OK; | 1018 return OK; |
1019 } | 1019 } |
1020 | 1020 |
1021 void UDPSocketWin::DetachFromThread() { | 1021 void UDPSocketWin::DetachFromThread() { |
1022 base::NonThreadSafe::DetachFromThread(); | 1022 base::NonThreadSafe::DetachFromThread(); |
1023 } | 1023 } |
1024 | 1024 |
1025 } // namespace net | 1025 } // namespace net |
OLD | NEW |