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

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: sync 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 unified diff | Download patch | Annotate | Revision Log
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 {
darin (slow to review) 2012/10/09 17:38:34 nit: new line after open of namespace
szym 2012/10/09 21:40:43 Done.
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;
darin (slow to review) 2012/10/09 17:38:34 static and anonymous namespace are redundant. you
szym 2012/10/09 21:40:43 Done.
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,
darin (slow to review) 2012/10/09 17:38:34 nit: looks like you can format like this: scope
szym 2012/10/09 21:40:43 Done.
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);
szym 2012/10/09 21:40:43 Replaced those NULLs with default constructors.
62 if (enable_cache)
63 cache = HostCache::CreateDefaultCache();
64 scoped_ptr<DnsClient> dns_client(NULL);
65 if (enable_async) {
66 #if !defined(ENABLE_BUILT_IN_DNS)
67 NOTREACHED();
68 return scoped_ptr<HostResolver>(NULL);
69 #else
70 dns_client = DnsClient::CreateClient(net_log);
71 #endif
72 }
73
74 return scoped_ptr<HostResolver>(new HostResolverImpl(
75 cache.Pass(),
76 PrioritizedDispatcher::Limits(NUM_PRIORITIES, max_concurrent_resolves),
77 HostResolverImpl::ProcTaskParams(NULL, max_retry_attempts),
78 dns_client.Pass(),
79 net_log));
80 }
81
82 // static
83 scoped_ptr<HostResolver>
darin (slow to review) 2012/10/09 17:38:34 ditto
szym 2012/10/09 21:40:43 Done. But now that HostResolver::Options has a def
84 HostResolver::CreateDefaultResolver(NetLog* net_log) {
85 return CreateSystemResolver(kDefaultParallelism,
86 kDefaultRetryAttempts,
87 true /* enable_cache */,
88 false /* enable_async */,
89 net_log);
90 }
91
36 HostResolver::HostResolver() { 92 HostResolver::HostResolver() {
37 } 93 }
38 94
39 } // namespace net 95 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698