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

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 unnecessary initialization; respond to review Created 8 years, 2 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..15228a6053a6b9e5e3f9813a46dec288b67efb4d 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -4,8 +4,31 @@
#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.
+const size_t kDefaultMaxProcTasks = 6u;
+
+} // namespace
+
+HostResolver::Options::Options()
+ : max_concurrent_resolves(kDefaultParallelism),
+ max_retry_attempts(kDefaultRetryAttempts),
+ enable_caching(true),
+ enable_async(false) {
+}
+
HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair)
: host_port_pair_(host_port_pair),
address_family_(ADDRESS_FAMILY_UNSPECIFIED),
@@ -33,6 +56,41 @@ base::Value* HostResolver::GetDnsConfigAsValue() const {
return NULL;
}
+// static
+scoped_ptr<HostResolver>
+HostResolver::CreateSystemResolver(const Options& options, NetLog* net_log) {
+ size_t max_concurrent_resolves = options.max_concurrent_resolves;
+ if (max_concurrent_resolves == kDefaultParallelism)
+ max_concurrent_resolves = kDefaultMaxProcTasks;
+
+ scoped_ptr<HostCache> cache;
+ if (options.enable_caching)
+ cache = HostCache::CreateDefaultCache();
+ scoped_ptr<DnsClient> dns_client;
+ if (options.enable_async) {
+#if !defined(ENABLE_BUILT_IN_DNS)
+ NOTREACHED();
+ return scoped_ptr<HostResolver>();
+#else
+ dns_client = DnsClient::CreateClient(net_log);
+#endif
+ }
+
+ return scoped_ptr<HostResolver>(new HostResolverImpl(
+ cache.Pass(),
+ PrioritizedDispatcher::Limits(NUM_PRIORITIES,
+ max_concurrent_resolves),
+ HostResolverImpl::ProcTaskParams(NULL, options.max_retry_attempts),
+ dns_client.Pass(),
+ net_log));
+}
+
+// static
+scoped_ptr<HostResolver>
+HostResolver::CreateDefaultResolver(NetLog* net_log) {
+ return CreateSystemResolver(Options(), 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