net: move IsLocalhost() function into url_util.h

This patch moves the last function in net_util.h into url_util.h. We are
moving it there because it also operates on a URL part (host).

BUG=488531
TEST=net_unittests --gtest_filter=UrlUtilTest.IsLocalhost
[email protected]
[email protected]

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

Cr-Commit-Position: refs/heads/master@{#377115}
diff --git a/net/base/url_util.h b/net/base/url_util.h
index 517aaa3..75f7b62 100644
--- a/net/base/url_util.h
+++ b/net/base/url_util.h
@@ -142,6 +142,14 @@
 // that falls in an IANA-reserved range.
 NET_EXPORT bool IsHostnameNonUnique(const std::string& hostname);
 
+// Returns true if |host| is one of the local hostnames
+// (e.g. "localhost") or IP addresses (IPv4 127.0.0.0/8 or IPv6 ::1).
+//
+// Note that this function does not check for IP addresses other than
+// the above, although other IP addresses may point to the local
+// machine.
+NET_EXPORT bool IsLocalhost(base::StringPiece host);
+
 // Strip the portions of |url| that aren't core to the network request.
 //   - user name / password
 //   - reference section