| Index: net/udp/udp_client_socket.cc
|
| diff --git a/net/udp/udp_client_socket.cc b/net/udp/udp_client_socket.cc
|
| index ca1f9e2439dd68c9f623a8b416dc5c9ae2372873..8d777d2bd32b86e7910ef2a6d4dc88b1f3681512 100644
|
| --- a/net/udp/udp_client_socket.cc
|
| +++ b/net/udp/udp_client_socket.cc
|
| @@ -13,15 +13,41 @@ UDPClientSocket::UDPClientSocket(DatagramSocket::BindType bind_type,
|
| const RandIntCallback& rand_int_cb,
|
| net::NetLog* net_log,
|
| const net::NetLog::Source& source)
|
| - : socket_(bind_type, rand_int_cb, net_log, source) {
|
| -}
|
| + : socket_(bind_type, rand_int_cb, net_log, source),
|
| + network_(NetworkChangeNotifier::kInvalidNetworkHandle) {}
|
|
|
| UDPClientSocket::~UDPClientSocket() {
|
| }
|
|
|
| int UDPClientSocket::BindToNetwork(
|
| NetworkChangeNotifier::NetworkHandle network) {
|
| - return socket_.BindToNetwork(network);
|
| + int rv = socket_.BindToNetwork(network);
|
| + if (rv == OK)
|
| + network_ = network;
|
| + return rv;
|
| +}
|
| +
|
| +int UDPClientSocket::BindToDefaultNetwork() {
|
| + int rv;
|
| + for (int attempt = 0; attempt < 5; attempt++) {
|
| + NetworkChangeNotifier::NetworkHandle network;
|
| + rv = NetworkChangeNotifier::GetDefaultNetwork(&network);
|
| + if (rv != OK)
|
| + return rv;
|
| + if (network == NetworkChangeNotifier::kInvalidNetworkHandle)
|
| + return ERR_INTERNET_DISCONNECTED;
|
| + rv = BindToNetwork(network);
|
| + // |network| may have disconnected between the time we query
|
| + // GetDefaultNetwork() and when we call BindToNetwork(). Loop if this is the
|
| + // case (|rv| will be ERR_NETWORK_CHANGED).
|
| + if (rv != ERR_NETWORK_CHANGED)
|
| + return rv;
|
| + }
|
| + return rv;
|
| +}
|
| +
|
| +NetworkChangeNotifier::NetworkHandle UDPClientSocket::GetBoundNetwork() {
|
| + return network_;
|
| }
|
|
|
| int UDPClientSocket::Connect(const IPEndPoint& address) {
|
|
|