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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <Winsock2.h> 8 #include <Winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 static const size_t kMaxHostCacheEntries = 100; 86 static const size_t kMaxHostCacheEntries = 100;
87 87
88 HostCache* cache = new HostCache( 88 HostCache* cache = new HostCache(
89 kMaxHostCacheEntries, 89 kMaxHostCacheEntries,
90 base::TimeDelta::FromMinutes(1), 90 base::TimeDelta::FromMinutes(1),
91 base::TimeDelta::FromSeconds(0)); // Disable caching of failed DNS. 91 base::TimeDelta::FromSeconds(0)); // Disable caching of failed DNS.
92 92
93 return cache; 93 return cache;
94 } 94 }
95 95
96 // Gets a list of the likely error codes that getaddrinfo() can return
97 // (non-exhaustive). These are the error codes that we will track via
98 // a histogram.
99 std::vector<int> GetAllGetAddrinfoOSErrors() {
100 int os_errors[] = {
101 #if defined(OS_POSIX)
102 EAI_ADDRFAMILY,
103 EAI_AGAIN,
104 EAI_BADFLAGS,
105 EAI_FAIL,
106 EAI_FAMILY,
107 EAI_MEMORY,
108 EAI_NODATA,
109 EAI_NONAME,
110 EAI_SERVICE,
111 EAI_SOCKTYPE,
112 EAI_SYSTEM,
113 #elif defined(OS_WIN)
114 // See: http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx
115 WSA_NOT_ENOUGH_MEMORY,
116 WSAEAFNOSUPPORT,
117 WSAEINVAL,
118 WSAESOCKTNOSUPPORT,
119 WSAHOST_NOT_FOUND,
120 WSANO_DATA,
121 WSANO_RECOVERY,
122 WSANOTINITIALISED,
123 WSATRY_AGAIN,
124 WSATYPE_NOT_FOUND,
125 // The following are not in doc, but might be to appearing in results :-(.
126 WSA_INVALID_HANDLE,
127 #endif
128 };
129
130 // Ensure all errors are positive, as histogram only tracks positive values.
131 for (size_t i = 0; i < arraysize(os_errors); ++i) {
132 os_errors[i] = std::abs(os_errors[i]);
133 }
134
135 return base::CustomHistogram::ArrayToCustomRanges(os_errors,
136 arraysize(os_errors));
137 }
138
96 } // anonymous namespace 139 } // anonymous namespace
97 140
98 // static 141 // static
99 HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves, 142 HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves,
100 size_t max_retry_attempts, 143 size_t max_retry_attempts,
101 NetLog* net_log) { 144 NetLog* net_log) {
102 // Maximum of 8 concurrent resolver threads. 145 // Maximum of 8 concurrent resolver threads.
103 // Some routers (or resolvers) appear to start to provide host-not-found if 146 // Some routers (or resolvers) appear to start to provide host-not-found if
104 // too many simultaneous resolutions are pending. This number needs to be 147 // too many simultaneous resolutions are pending. This number needs to be
105 // further optimized, but 8 is what FF currently does. 148 // further optimized, but 8 is what FF currently does.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 dict->SetString("host", host_); 263 dict->SetString("host", host_);
221 dict->Set("source_dependency", source_.ToValue()); 264 dict->Set("source_dependency", source_.ToValue());
222 return dict; 265 return dict;
223 } 266 }
224 267
225 private: 268 private:
226 const std::string host_; 269 const std::string host_;
227 const NetLog::Source source_; 270 const NetLog::Source source_;
228 }; 271 };
229 272
230 // Gets a list of the likely error codes that getaddrinfo() can return
231 // (non-exhaustive). These are the error codes that we will track via
232 // a histogram.
233 std::vector<int> GetAllGetAddrinfoOSErrors() {
234 int os_errors[] = {
235 #if defined(OS_POSIX)
236 EAI_ADDRFAMILY,
237 EAI_AGAIN,
238 EAI_BADFLAGS,
239 EAI_FAIL,
240 EAI_FAMILY,
241 EAI_MEMORY,
242 EAI_NODATA,
243 EAI_NONAME,
244 EAI_SERVICE,
245 EAI_SOCKTYPE,
246 EAI_SYSTEM,
247 #elif defined(OS_WIN)
248 // See: http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx
249 WSA_NOT_ENOUGH_MEMORY,
250 WSAEAFNOSUPPORT,
251 WSAEINVAL,
252 WSAESOCKTNOSUPPORT,
253 WSAHOST_NOT_FOUND,
254 WSANO_DATA,
255 WSANO_RECOVERY,
256 WSANOTINITIALISED,
257 WSATRY_AGAIN,
258 WSATYPE_NOT_FOUND,
259 // The following are not in doc, but might be to appearing in results :-(.
260 WSA_INVALID_HANDLE,
261 #endif
262 };
263
264 // Histogram enumerations require positive numbers.
265 std::vector<int> errors;
266 for (size_t i = 0; i < arraysize(os_errors); ++i) {
267 errors.push_back(std::abs(os_errors[i]));
268 // Also add N+1 for each error, so the bucket that contains our expected
269 // error is of size 1. That way if we get unexpected error codes, they
270 // won't fall into the same buckets as the expected ones.
271 errors.push_back(std::abs(os_errors[i]) + 1);
272 }
273 return errors;
274 }
275
276 //----------------------------------------------------------------------------- 273 //-----------------------------------------------------------------------------
277 274
278 class HostResolverImpl::Request { 275 class HostResolverImpl::Request {
279 public: 276 public:
280 Request(const BoundNetLog& source_net_log, 277 Request(const BoundNetLog& source_net_log,
281 const BoundNetLog& request_net_log, 278 const BoundNetLog& request_net_log,
282 int id, 279 int id,
283 const RequestInfo& info, 280 const RequestInfo& info,
284 CompletionCallback* callback, 281 CompletionCallback* callback,
285 AddressList* addresses) 282 AddressList* addresses)
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY; 1603 additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY;
1607 } else { 1604 } else {
1608 additional_resolver_flags_ &= ~HOST_RESOLVER_LOOPBACK_ONLY; 1605 additional_resolver_flags_ &= ~HOST_RESOLVER_LOOPBACK_ONLY;
1609 } 1606 }
1610 #endif 1607 #endif
1611 AbortAllInProgressJobs(); 1608 AbortAllInProgressJobs();
1612 // |this| may be deleted inside AbortAllInProgressJobs(). 1609 // |this| may be deleted inside AbortAllInProgressJobs().
1613 } 1610 }
1614 1611
1615 } // namespace net 1612 } // namespace net
OLDNEW
« 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