summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 14:28:27 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 14:28:27 +0000
commitc89b244483969aa8859a1d4bb3396f6ceb54f875 (patch)
tree1feb67c4c99317335f9969fa2ef20f9c2a602817 /net
parent8d6bc14ce560d5549ee0e0c6784bd0f8f48757d6 (diff)
downloadchromium_src-c89b244483969aa8859a1d4bb3396f6ceb54f875.zip
chromium_src-c89b244483969aa8859a1d4bb3396f6ceb54f875.tar.gz
chromium_src-c89b244483969aa8859a1d4bb3396f6ceb54f875.tar.bz2
Switch to the new CustomHistogram::ArrayToCustomRanges() utility
function where appropriate. Add a DCHECK which may be useful to detect incorrect usage. BUG=none TEST=net_unittests, unit_tests Review URL: http://codereview.chromium.org/6990058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86822 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/host_resolver_impl.cc89
1 files changed, 43 insertions, 46 deletions
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 2f9e4bb0..9a02f10 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -93,6 +93,49 @@ HostCache* CreateDefaultCache() {
return cache;
}
+// Gets a list of the likely error codes that getaddrinfo() can return
+// (non-exhaustive). These are the error codes that we will track via
+// a histogram.
+std::vector<int> GetAllGetAddrinfoOSErrors() {
+ int os_errors[] = {
+#if defined(OS_POSIX)
+ EAI_ADDRFAMILY,
+ EAI_AGAIN,
+ EAI_BADFLAGS,
+ EAI_FAIL,
+ EAI_FAMILY,
+ EAI_MEMORY,
+ EAI_NODATA,
+ EAI_NONAME,
+ EAI_SERVICE,
+ EAI_SOCKTYPE,
+ EAI_SYSTEM,
+#elif defined(OS_WIN)
+ // See: http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx
+ WSA_NOT_ENOUGH_MEMORY,
+ WSAEAFNOSUPPORT,
+ WSAEINVAL,
+ WSAESOCKTNOSUPPORT,
+ WSAHOST_NOT_FOUND,
+ WSANO_DATA,
+ WSANO_RECOVERY,
+ WSANOTINITIALISED,
+ WSATRY_AGAIN,
+ WSATYPE_NOT_FOUND,
+ // The following are not in doc, but might be to appearing in results :-(.
+ WSA_INVALID_HANDLE,
+#endif
+ };
+
+ // Ensure all errors are positive, as histogram only tracks positive values.
+ for (size_t i = 0; i < arraysize(os_errors); ++i) {
+ os_errors[i] = std::abs(os_errors[i]);
+ }
+
+ return base::CustomHistogram::ArrayToCustomRanges(os_errors,
+ arraysize(os_errors));
+}
+
} // anonymous namespace
// static
@@ -227,52 +270,6 @@ class JobCreationParameters : public NetLog::EventParameters {
const NetLog::Source source_;
};
-// Gets a list of the likely error codes that getaddrinfo() can return
-// (non-exhaustive). These are the error codes that we will track via
-// a histogram.
-std::vector<int> GetAllGetAddrinfoOSErrors() {
- int os_errors[] = {
-#if defined(OS_POSIX)
- EAI_ADDRFAMILY,
- EAI_AGAIN,
- EAI_BADFLAGS,
- EAI_FAIL,
- EAI_FAMILY,
- EAI_MEMORY,
- EAI_NODATA,
- EAI_NONAME,
- EAI_SERVICE,
- EAI_SOCKTYPE,
- EAI_SYSTEM,
-#elif defined(OS_WIN)
- // See: http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx
- WSA_NOT_ENOUGH_MEMORY,
- WSAEAFNOSUPPORT,
- WSAEINVAL,
- WSAESOCKTNOSUPPORT,
- WSAHOST_NOT_FOUND,
- WSANO_DATA,
- WSANO_RECOVERY,
- WSANOTINITIALISED,
- WSATRY_AGAIN,
- WSATYPE_NOT_FOUND,
- // The following are not in doc, but might be to appearing in results :-(.
- WSA_INVALID_HANDLE,
-#endif
- };
-
- // Histogram enumerations require positive numbers.
- std::vector<int> errors;
- for (size_t i = 0; i < arraysize(os_errors); ++i) {
- errors.push_back(std::abs(os_errors[i]));
- // Also add N+1 for each error, so the bucket that contains our expected
- // error is of size 1. That way if we get unexpected error codes, they
- // won't fall into the same buckets as the expected ones.
- errors.push_back(std::abs(os_errors[i]) + 1);
- }
- return errors;
-}
-
//-----------------------------------------------------------------------------
class HostResolverImpl::Request {