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

Unified Diff: net/base/host_resolver.cc

Issue 10831277: [net] Change factory methods for HostResolver and HostCache to return a scoped_ptr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove FieldTrials Created 8 years, 4 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 | « net/base/host_resolver.h ('k') | net/base/host_resolver_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver.cc
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index 3e86aff4165e2a6da71f18f6b0a1f8a1f5f907cb..38aefa1e38b060d1a11c45172fc9c8a128dc6be3 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -4,8 +4,23 @@
#include "net/base/host_resolver.h"
+#include "net/base/host_cache.h"
+#include "net/base/host_resolver_impl.h"
+#include "net/dns/dns_client.h"
+#include "net/dns/dns_config_service.h"
+
namespace net {
+namespace {
+// Maximum of 6 concurrent resolver threads (excluding retries).
+// Some routers (or resolvers) appear to start to provide host-not-found if
+// too many simultaneous resolutions are pending. This number needs to be
+// further optimized, but 8 is what FF currently does. We found some routers
+// that limit this to 6, so we're temporarily holding it at that level.
+static const size_t kDefaultMaxProcTasks = 6u;
+
+} // namespace
+
HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair)
: host_port_pair_(host_port_pair),
address_family_(ADDRESS_FAMILY_UNSPECIFIED),
@@ -33,6 +48,42 @@ base::Value* HostResolver::GetDnsConfigAsValue() const {
return NULL;
}
+// static
+scoped_ptr<HostResolver>
+HostResolver::CreateSystemResolver(size_t max_concurrent_resolves,
cbentzel 2012/08/17 13:41:52 This used to be in host_resolver_impl.cc - and mea
+ size_t max_retry_attempts,
+ bool enable_cache,
+ bool enable_async,
+ NetLog* net_log) {
+ if (max_concurrent_resolves == kDefaultParallelism)
+ max_concurrent_resolves = kDefaultMaxProcTasks;
+
+ scoped_ptr<HostCache> cache(NULL);
+ if (enable_cache)
+ cache = HostCache::CreateDefaultCache();
+ scoped_ptr<DnsClient> dns_client(NULL);
+ if (enable_async)
+ dns_client = DnsClient::CreateClient(net_log);
+
+ return scoped_ptr<HostResolver>(new HostResolverImpl(
+ cache.Pass(),
+ PrioritizedDispatcher::Limits(NUM_PRIORITIES, max_concurrent_resolves),
+ HostResolverImpl::ProcTaskParams(NULL, max_retry_attempts),
+ DnsConfigService::CreateSystemService(),
+ dns_client.Pass(),
+ net_log));
+}
+
+// static
+scoped_ptr<HostResolver>
+HostResolver::CreateDefaultResolver(NetLog* net_log) {
+ return CreateSystemResolver(kDefaultParallelism,
+ kDefaultRetryAttempts,
+ true /* enable_cache */,
+ false /* enable_async */,
+ net_log);
+}
+
HostResolver::HostResolver() {
}
« no previous file with comments | « net/base/host_resolver.h ('k') | net/base/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698