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

Side by Side Diff: net/dns/host_resolver.cc

Issue 238433003: Provide Shill IP Address to myIpAddress() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + feedback Created 6 years, 6 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/dns/host_resolver.h ('k') | net/dns/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/dns/host_resolver.h" 5 #include "net/dns/host_resolver.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "net/dns/dns_client.h" 11 #include "net/dns/dns_client.h"
12 #include "net/dns/dns_config_service.h" 12 #include "net/dns/dns_config_service.h"
13 #include "net/dns/host_cache.h" 13 #include "net/dns/host_cache.h"
14 #include "net/dns/host_resolver_impl.h" 14 #include "net/dns/host_resolver_impl.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 namespace { 18 namespace {
19 19
20 // Maximum of 6 concurrent resolver threads (excluding retries). 20 // Maximum of 6 concurrent resolver threads (excluding retries).
21 // Some routers (or resolvers) appear to start to provide host-not-found if 21 // Some routers (or resolvers) appear to start to provide host-not-found if
22 // too many simultaneous resolutions are pending. This number needs to be 22 // too many simultaneous resolutions are pending. This number needs to be
23 // further optimized, but 8 is what FF currently does. We found some routers 23 // further optimized, but 8 is what FF currently does. We found some routers
24 // that limit this to 6, so we're temporarily holding it at that level. 24 // that limit this to 6, so we're temporarily holding it at that level.
25 const size_t kDefaultMaxProcTasks = 6u; 25 const size_t kDefaultMaxProcTasks = 6u;
26 26
27 PrioritizedDispatcher::Limits GetDispatcherLimits( 27 } // namespace
28 const HostResolver::Options& options) { 28
29 PrioritizedDispatcher::Limits limits(NUM_PRIORITIES, 29 PrioritizedDispatcher::Limits HostResolver::Options::GetDispatcherLimits()
30 options.max_concurrent_resolves); 30 const {
31 PrioritizedDispatcher::Limits limits(NUM_PRIORITIES, max_concurrent_resolves);
31 32
32 // If not using default, do not use the field trial. 33 // If not using default, do not use the field trial.
33 if (limits.total_jobs != HostResolver::kDefaultParallelism) 34 if (limits.total_jobs != HostResolver::kDefaultParallelism)
34 return limits; 35 return limits;
35 36
36 // Default, without trial is no reserved slots. 37 // Default, without trial is no reserved slots.
37 limits.total_jobs = kDefaultMaxProcTasks; 38 limits.total_jobs = kDefaultMaxProcTasks;
38 39
39 // Parallelism is determined by the field trial. 40 // Parallelism is determined by the field trial.
40 std::string group = base::FieldTrialList::FindFullName( 41 std::string group = base::FieldTrialList::FindFullName(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 (total_reserved_slots == total_jobs && parsed[MINIMUM_PRIORITY] == 0)) { 76 (total_reserved_slots == total_jobs && parsed[MINIMUM_PRIORITY] == 0)) {
76 NOTREACHED(); 77 NOTREACHED();
77 return limits; 78 return limits;
78 } 79 }
79 80
80 limits.total_jobs = total_jobs; 81 limits.total_jobs = total_jobs;
81 limits.reserved_slots = parsed; 82 limits.reserved_slots = parsed;
82 return limits; 83 return limits;
83 } 84 }
84 85
85 } // namespace
86
87 HostResolver::Options::Options() 86 HostResolver::Options::Options()
88 : max_concurrent_resolves(kDefaultParallelism), 87 : max_concurrent_resolves(kDefaultParallelism),
89 max_retry_attempts(kDefaultRetryAttempts), 88 max_retry_attempts(kDefaultRetryAttempts),
90 enable_caching(true) { 89 enable_caching(true) {
91 } 90 }
92 91
93 HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair) 92 HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair)
94 : host_port_pair_(host_port_pair), 93 : host_port_pair_(host_port_pair),
95 address_family_(ADDRESS_FAMILY_UNSPECIFIED), 94 address_family_(ADDRESS_FAMILY_UNSPECIFIED),
96 host_resolver_flags_(0), 95 host_resolver_flags_(0),
(...skipping 12 matching lines...) Expand all
109 108
110 HostCache* HostResolver::GetHostCache() { 109 HostCache* HostResolver::GetHostCache() {
111 return NULL; 110 return NULL;
112 } 111 }
113 112
114 base::Value* HostResolver::GetDnsConfigAsValue() const { 113 base::Value* HostResolver::GetDnsConfigAsValue() const {
115 return NULL; 114 return NULL;
116 } 115 }
117 116
118 // static 117 // static
119 scoped_ptr<HostResolver> 118 scoped_ptr<HostResolver> HostResolver::CreateSystemResolver(
120 HostResolver::CreateSystemResolver(const Options& options, NetLog* net_log) { 119 const Options& options,
121 scoped_ptr<HostCache> cache; 120 NetLog* net_log) {
122 if (options.enable_caching) 121 return scoped_ptr<HostResolver>(new HostResolverImpl(options, net_log));
123 cache = HostCache::CreateDefaultCache();
124 return scoped_ptr<HostResolver>(new HostResolverImpl(
125 cache.Pass(),
126 GetDispatcherLimits(options),
127 HostResolverImpl::ProcTaskParams(NULL, options.max_retry_attempts),
128 net_log));
129 } 122 }
130 123
131 // static 124 // static
132 scoped_ptr<HostResolver> 125 scoped_ptr<HostResolver> HostResolver::CreateDefaultResolver(NetLog* net_log) {
133 HostResolver::CreateDefaultResolver(NetLog* net_log) { 126 return scoped_ptr<HostResolver>(new HostResolverImpl(Options(), net_log));
134 return CreateSystemResolver(Options(), net_log);
135 } 127 }
136 128
137 HostResolver::HostResolver() { 129 HostResolver::HostResolver() {
138 } 130 }
139 131
140 } // namespace net 132 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver.h ('k') | net/dns/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698