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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/host_resolver.h ('k') | net/base/host_resolver_impl.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 5 #include "net/base/host_resolver.h"
6 6
7 #include "net/base/host_cache.h"
8 #include "net/base/host_resolver_impl.h"
9 #include "net/dns/dns_client.h"
10 #include "net/dns/dns_config_service.h"
11
7 namespace net { 12 namespace net {
8 13
14 namespace {
15 // Maximum of 6 concurrent resolver threads (excluding retries).
16 // Some routers (or resolvers) appear to start to provide host-not-found if
17 // too many simultaneous resolutions are pending. This number needs to be
18 // further optimized, but 8 is what FF currently does. We found some routers
19 // that limit this to 6, so we're temporarily holding it at that level.
20 static const size_t kDefaultMaxProcTasks = 6u;
21
22 } // namespace
23
9 HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair) 24 HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair)
10 : host_port_pair_(host_port_pair), 25 : host_port_pair_(host_port_pair),
11 address_family_(ADDRESS_FAMILY_UNSPECIFIED), 26 address_family_(ADDRESS_FAMILY_UNSPECIFIED),
12 host_resolver_flags_(0), 27 host_resolver_flags_(0),
13 allow_cached_response_(true), 28 allow_cached_response_(true),
14 is_speculative_(false), 29 is_speculative_(false),
15 priority_(MEDIUM) { 30 priority_(MEDIUM) {
16 } 31 }
17 32
18 HostResolver::~HostResolver() { 33 HostResolver::~HostResolver() {
19 } 34 }
20 35
21 AddressFamily HostResolver::GetDefaultAddressFamily() const { 36 AddressFamily HostResolver::GetDefaultAddressFamily() const {
22 return ADDRESS_FAMILY_UNSPECIFIED; 37 return ADDRESS_FAMILY_UNSPECIFIED;
23 } 38 }
24 39
25 void HostResolver::ProbeIPv6Support() { 40 void HostResolver::ProbeIPv6Support() {
26 } 41 }
27 42
28 HostCache* HostResolver::GetHostCache() { 43 HostCache* HostResolver::GetHostCache() {
29 return NULL; 44 return NULL;
30 } 45 }
31 46
32 base::Value* HostResolver::GetDnsConfigAsValue() const { 47 base::Value* HostResolver::GetDnsConfigAsValue() const {
33 return NULL; 48 return NULL;
34 } 49 }
35 50
51 // static
52 scoped_ptr<HostResolver>
53 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
54 size_t max_retry_attempts,
55 bool enable_cache,
56 bool enable_async,
57 NetLog* net_log) {
58 if (max_concurrent_resolves == kDefaultParallelism)
59 max_concurrent_resolves = kDefaultMaxProcTasks;
60
61 scoped_ptr<HostCache> cache(NULL);
62 if (enable_cache)
63 cache = HostCache::CreateDefaultCache();
64 scoped_ptr<DnsClient> dns_client(NULL);
65 if (enable_async)
66 dns_client = DnsClient::CreateClient(net_log);
67
68 return scoped_ptr<HostResolver>(new HostResolverImpl(
69 cache.Pass(),
70 PrioritizedDispatcher::Limits(NUM_PRIORITIES, max_concurrent_resolves),
71 HostResolverImpl::ProcTaskParams(NULL, max_retry_attempts),
72 DnsConfigService::CreateSystemService(),
73 dns_client.Pass(),
74 net_log));
75 }
76
77 // static
78 scoped_ptr<HostResolver>
79 HostResolver::CreateDefaultResolver(NetLog* net_log) {
80 return CreateSystemResolver(kDefaultParallelism,
81 kDefaultRetryAttempts,
82 true /* enable_cache */,
83 false /* enable_async */,
84 net_log);
85 }
86
36 HostResolver::HostResolver() { 87 HostResolver::HostResolver() {
37 } 88 }
38 89
39 } // namespace net 90 } // namespace net
OLDNEW
« 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