From 43f0aaeb568fd974d442dd088f0d0036f8e1a61f Mon Sep 17 00:00:00 2001 From: "wtc@chromium.org" Date: Wed, 25 Mar 2009 18:00:00 +0000 Subject: GetMyHostName is renamed GetHostName to match the name of the Unix/Winsock function gethostname. R=eroman Review URL: http://codereview.chromium.org/42590 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12466 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/net_util.cc | 5 ++--- net/base/net_util.h | 2 +- net/base/net_util_unittest.cc | 8 ++++---- net/http/http_auth_handler_ntlm.cc | 2 +- net/proxy/proxy_resolver_v8.cc | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) (limited to 'net') diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 6171db3..7865b4e 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -1024,13 +1024,12 @@ std::string NetAddressToString(const struct addrinfo* net_address) { return std::string(buffer); } -std::string GetMyHostName() { +std::string GetHostName() { #if defined(OS_WIN) EnsureWinsockInit(); #endif - // Maximum size of 256 is somewhat arbitrary. Mozilla uses a size of 100 - // so this should cover the majority of cases. + // Host names are limited to 255 bytes. char buffer[256]; int result = gethostname(buffer, sizeof(buffer)); if (result != 0) { diff --git a/net/base/net_util.h b/net/base/net_util.h index 0b419bf..3305f49 100644 --- a/net/base/net_util.h +++ b/net/base/net_util.h @@ -57,7 +57,7 @@ bool GetHostAndPort(const std::string& host_and_port, std::string NetAddressToString(const struct addrinfo* net_address); // Returns the hostname of the current system. Returns empty string on failure. -std::string GetMyHostName(); +std::string GetHostName(); // Return the value of the HTTP response header with name 'name'. 'headers' // should be in the format that URLRequest::GetResponseHeaders() returns. diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index 4469283..423c62c 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -883,10 +883,10 @@ TEST(NetUtilTest, DISABLED_NetAddressToString_IPv6) { } } -TEST(NetUtilTest, GetMyHostName) { - // We can't check the result of GetMyHostName() directly, since the result +TEST(NetUtilTest, GetHostName) { + // We can't check the result of GetHostName() directly, since the result // will differ across machines. Our goal here is to simply exercise the // code path, and check that things "look about right". - std::string my_hostname = net::GetMyHostName(); - EXPECT_FALSE(my_hostname.empty()); + std::string hostname = net::GetHostName(); + EXPECT_FALSE(hostname.empty()); } diff --git a/net/http/http_auth_handler_ntlm.cc b/net/http/http_auth_handler_ntlm.cc index b409b63..1554534 100644 --- a/net/http/http_auth_handler_ntlm.cc +++ b/net/http/http_auth_handler_ntlm.cc @@ -632,7 +632,7 @@ HttpAuthHandlerNTLM::generate_random_proc_ = GenerateRandom; // static HttpAuthHandlerNTLM::HostNameProc -HttpAuthHandlerNTLM::get_host_name_proc_ = GetMyHostName; +HttpAuthHandlerNTLM::get_host_name_proc_ = GetHostName; HttpAuthHandlerNTLM::HttpAuthHandlerNTLM() { } diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc index ef4ffd8..a5d1c76 100644 --- a/net/proxy/proxy_resolver_v8.cc +++ b/net/proxy/proxy_resolver_v8.cc @@ -61,7 +61,7 @@ class DefaultJSBindings : public ProxyResolverV8::JSBindings { // Handler for "myIpAddress()". Returns empty string on failure. virtual std::string MyIpAddress() { // DnsResolve("") returns "", so no need to check for failure. - return DnsResolve(GetMyHostName()); + return DnsResolve(GetHostName()); } // Handler for "dnsResolve(host)". Returns empty string on failure. -- cgit v1.1