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

Unified Diff: net/udp/udp_socket_posix.cc

Issue 1416213003: Add DatagramClientSocket::BindToDefaultNetwork(),GetBoundNetwork() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync and rework Created 5 years 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 side-by-side diff with in-line comments
Download patch
« net/udp/udp_client_socket.cc ('K') | « net/udp/udp_client_socket.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_socket_posix.cc
diff --git a/net/udp/udp_socket_posix.cc b/net/udp/udp_socket_posix.cc
index 5151f7b59807a6c399ec76bd3735edb120e8fc16..c395b88526269eb3b20756ee8a4668562327e7ae 100644
--- a/net/udp/udp_socket_posix.cc
+++ b/net/udp/udp_socket_posix.cc
@@ -326,10 +326,12 @@ int UDPSocketPosix::Bind(const IPEndPoint& address) {
int UDPSocketPosix::BindToNetwork(
NetworkChangeNotifier::NetworkHandle network) {
-#if defined(OS_ANDROID)
DCHECK_NE(socket_, kInvalidSocket);
DCHECK(CalledOnValidThread());
DCHECK(!is_connected());
+ if (network == NetworkChangeNotifier::kInvalidNetworkHandle)
+ return ERR_INVALID_ARGUMENT;
+#if defined(OS_ANDROID)
// Android prior to Lollipop didn't have support for binding sockets to
// networks.
if (base::android::BuildInfo::GetInstance()->sdk_int() <
@@ -353,7 +355,13 @@ int UDPSocketPosix::BindToNetwork(
}
if (setNetworkForSocket == nullptr)
return ERR_NOT_IMPLEMENTED;
- return MapSystemError(setNetworkForSocket(network, socket_));
+ int rv = setNetworkForSocket(network, socket_);
+ // If |network| has since disconnected, |rv| will be ENONET. Surface this as
+ // ERR_NETWORK_CHANGED, rather than MapSystemError(ENONET) which gives back
+ // the less descriptive ERR_FAILED.
+ if (rv == ENONET)
+ return ERR_NETWORK_CHANGED;
Jana 2015/12/04 20:30:16 This is probably fine, but shouldn't this be ERR_I
pauljensen 2015/12/07 13:05:55 ERR_INTERNET_DISCONNECTED means there are no netwo
+ return MapSystemError(rv);
#else
NOTIMPLEMENTED();
return ERR_NOT_IMPLEMENTED;
« net/udp/udp_client_socket.cc ('K') | « net/udp/udp_client_socket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698