net: Extract SetNonBlocking() function from net_util.h

There are quite few reimplementations of this function across the code
base. Refactor it into a helper function in base's file_util.h and reuse
it at some places.

BUG=488531
[email protected],[email protected],[email protected],[email protected]

Review URL: https://codereview.chromium.org/1517883004

Cr-Commit-Position: refs/heads/master@{#365461}
diff --git a/net/socket/socket_posix.cc b/net/socket/socket_posix.cc
index c8098c3..cd7aff1 100644
--- a/net/socket/socket_posix.cc
+++ b/net/socket/socket_posix.cc
@@ -9,6 +9,7 @@
 #include <sys/socket.h>
 
 #include "base/callback_helpers.h"
+#include "base/files/file_util.h"
 #include "base/logging.h"
 #include "base/posix/eintr_wrapper.h"
 #include "net/base/io_buffer.h"
@@ -79,7 +80,7 @@
     return MapSystemError(errno);
   }
 
-  if (SetNonBlocking(socket_fd_)) {
+  if (!base::SetNonBlocking(socket_fd_)) {
     int rv = MapSystemError(errno);
     Close();
     return rv;
@@ -95,7 +96,7 @@
 
   socket_fd_ = socket;
 
-  if (SetNonBlocking(socket_fd_)) {
+  if (!base::SetNonBlocking(socket_fd_)) {
     int rv = MapSystemError(errno);
     Close();
     return rv;