diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 18:00:00 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 18:00:00 +0000 |
commit | 43f0aaeb568fd974d442dd088f0d0036f8e1a61f (patch) | |
tree | dc4fba8446b24d4772d558af03871322528e5ddc /net/base | |
parent | cc424a3d6b39e80dfabd683c2e9a7f79db890fe8 (diff) | |
download | chromium_src-43f0aaeb568fd974d442dd088f0d0036f8e1a61f.zip chromium_src-43f0aaeb568fd974d442dd088f0d0036f8e1a61f.tar.gz chromium_src-43f0aaeb568fd974d442dd088f0d0036f8e1a61f.tar.bz2 |
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
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/net_util.cc | 5 | ||||
-rw-r--r-- | net/base/net_util.h | 2 | ||||
-rw-r--r-- | net/base/net_util_unittest.cc | 8 |
3 files changed, 7 insertions, 8 deletions
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()); } |