Don't attempt to use "network binder" for sockets bound to "ANY" IP.

BUG=NONE

Review-Url: https://codereview.webrtc.org/2701253002
Cr-Commit-Position: refs/heads/master@{#16760}
diff --git a/webrtc/base/physicalsocketserver_unittest.cc b/webrtc/base/physicalsocketserver_unittest.cc
index d0083bd..63d2f0d 100644
--- a/webrtc/base/physicalsocketserver_unittest.cc
+++ b/webrtc/base/physicalsocketserver_unittest.cc
@@ -89,13 +89,17 @@
 class FakeNetworkBinder : public NetworkBinderInterface {
  public:
   NetworkBindingResult BindSocketToNetwork(int, const IPAddress&) override {
+    ++num_binds_;
     return result_;
   }
 
   void set_result(NetworkBindingResult result) { result_ = result; }
 
+  int num_binds() { return num_binds_; }
+
  private:
   NetworkBindingResult result_ = NetworkBindingResult::SUCCESS;
+  int num_binds_ = 0;
 };
 
 class PhysicalSocketTest : public SocketTest {
@@ -441,6 +445,18 @@
   server_->set_network_binder(nullptr);
 }
 
+// Network binder shouldn't be used if the socket is bound to the "any" IP.
+TEST_F(PhysicalSocketTest,
+       NetworkBinderIsNotUsedForAnyIp) {
+  FakeNetworkBinder fake_network_binder;
+  server_->set_network_binder(&fake_network_binder);
+  std::unique_ptr<AsyncSocket> socket(
+      server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM));
+  EXPECT_EQ(0, socket->Bind(SocketAddress("0.0.0.0", 0)));
+  EXPECT_EQ(0, fake_network_binder.num_binds());
+  server_->set_network_binder(nullptr);
+}
+
 // For a loopback interface, failures to bind to the interface should be
 // tolerated.
 TEST_F(PhysicalSocketTest,