Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: net/udp/udp_socket_win.cc

Issue 2453873004: Simplify if condition in UDPSocket::RandomBind (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/udp/udp_socket_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 return ERR_ADDRESS_IN_USE; 974 return ERR_ADDRESS_IN_USE;
975 return MapSystemError(last_error); 975 return MapSystemError(last_error);
976 } 976 }
977 977
978 int UDPSocketWin::RandomBind(const IPAddress& address) { 978 int UDPSocketWin::RandomBind(const IPAddress& address) {
979 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null()); 979 DCHECK(bind_type_ == DatagramSocket::RANDOM_BIND && !rand_int_cb_.is_null());
980 980
981 for (int i = 0; i < kBindRetries; ++i) { 981 for (int i = 0; i < kBindRetries; ++i) {
982 int rv = DoBind(IPEndPoint(address, static_cast<uint16_t>(rand_int_cb_.Run( 982 int rv = DoBind(IPEndPoint(address, static_cast<uint16_t>(rand_int_cb_.Run(
983 kPortStart, kPortEnd)))); 983 kPortStart, kPortEnd))));
984 if (rv == OK || rv != ERR_ADDRESS_IN_USE) 984 if (rv != ERR_ADDRESS_IN_USE)
985 return rv; 985 return rv;
986 } 986 }
987 return DoBind(IPEndPoint(address, 0)); 987 return DoBind(IPEndPoint(address, 0));
988 } 988 }
989 989
990 int UDPSocketWin::JoinGroup(const IPAddress& group_address) const { 990 int UDPSocketWin::JoinGroup(const IPAddress& group_address) const {
991 DCHECK(CalledOnValidThread()); 991 DCHECK(CalledOnValidThread());
992 if (!is_connected()) 992 if (!is_connected())
993 return ERR_SOCKET_NOT_CONNECTED; 993 return ERR_SOCKET_NOT_CONNECTED;
994 994
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 void UDPSocketWin::DetachFromThread() { 1192 void UDPSocketWin::DetachFromThread() {
1193 base::NonThreadSafe::DetachFromThread(); 1193 base::NonThreadSafe::DetachFromThread();
1194 } 1194 }
1195 1195
1196 void UDPSocketWin::UseNonBlockingIO() { 1196 void UDPSocketWin::UseNonBlockingIO() {
1197 DCHECK(!core_); 1197 DCHECK(!core_);
1198 use_non_blocking_io_ = true; 1198 use_non_blocking_io_ = true;
1199 } 1199 }
1200 1200
1201 } // namespace net 1201 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698