Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Unified Diff: net/base/host_resolver_impl.cc

Issue 6990058: Switch to the new CustomHistogram::ArrayToCustomRanges() utility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver_impl.cc
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 2f9e4bb00b438b913543a897ec3ce563d1f405a1..9a02f104a2075127807d5cbb4d2e2be40e1a9d83 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 {
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698