OLD | NEW |
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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 options.max_concurrent_resolves); | 30 options.max_concurrent_resolves); |
31 | 31 |
32 // If not using default, do not use the field trial. | 32 // If not using default, do not use the field trial. |
33 if (limits.total_jobs != HostResolver::kDefaultParallelism) | 33 if (limits.total_jobs != HostResolver::kDefaultParallelism) |
34 return limits; | 34 return limits; |
35 | 35 |
36 // Default, without trial is no reserved slots. | 36 // Default, without trial is no reserved slots. |
37 limits.total_jobs = kDefaultMaxProcTasks; | 37 limits.total_jobs = kDefaultMaxProcTasks; |
38 | 38 |
39 // Parallelism is determined by the field trial. | 39 // Parallelism is determined by the field trial. |
40 std::string group = base::FieldTrialList::FindFullName( | 40 std::string group = |
41 "HostResolverDispatch"); | 41 base::FieldTrialList::FindFullName("HostResolverDispatch"); |
42 | 42 |
43 if (group.empty()) | 43 if (group.empty()) |
44 return limits; | 44 return limits; |
45 | 45 |
46 // The format of the group name is a list of non-negative integers separated | 46 // The format of the group name is a list of non-negative integers separated |
47 // by ':'. Each of the elements in the list corresponds to an element in | 47 // by ':'. Each of the elements in the list corresponds to an element in |
48 // |reserved_slots|, except the last one which is the |total_jobs|. | 48 // |reserved_slots|, except the last one which is the |total_jobs|. |
49 | 49 |
50 std::vector<std::string> group_parts; | 50 std::vector<std::string> group_parts; |
51 base::SplitString(group, ':', &group_parts); | 51 base::SplitString(group, ':', &group_parts); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 : max_concurrent_resolves(kDefaultParallelism), | 88 : max_concurrent_resolves(kDefaultParallelism), |
89 max_retry_attempts(kDefaultRetryAttempts), | 89 max_retry_attempts(kDefaultRetryAttempts), |
90 enable_caching(true) { | 90 enable_caching(true) { |
91 } | 91 } |
92 | 92 |
93 HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair) | 93 HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair) |
94 : host_port_pair_(host_port_pair), | 94 : host_port_pair_(host_port_pair), |
95 address_family_(ADDRESS_FAMILY_UNSPECIFIED), | 95 address_family_(ADDRESS_FAMILY_UNSPECIFIED), |
96 host_resolver_flags_(0), | 96 host_resolver_flags_(0), |
97 allow_cached_response_(true), | 97 allow_cached_response_(true), |
98 is_speculative_(false) {} | 98 is_speculative_(false) { |
| 99 } |
99 | 100 |
100 HostResolver::~HostResolver() { | 101 HostResolver::~HostResolver() { |
101 } | 102 } |
102 | 103 |
103 AddressFamily HostResolver::GetDefaultAddressFamily() const { | 104 AddressFamily HostResolver::GetDefaultAddressFamily() const { |
104 return ADDRESS_FAMILY_UNSPECIFIED; | 105 return ADDRESS_FAMILY_UNSPECIFIED; |
105 } | 106 } |
106 | 107 |
107 void HostResolver::SetDnsClientEnabled(bool enabled) { | 108 void HostResolver::SetDnsClientEnabled(bool enabled) { |
108 } | 109 } |
109 | 110 |
110 HostCache* HostResolver::GetHostCache() { | 111 HostCache* HostResolver::GetHostCache() { |
111 return NULL; | 112 return NULL; |
112 } | 113 } |
113 | 114 |
114 base::Value* HostResolver::GetDnsConfigAsValue() const { | 115 base::Value* HostResolver::GetDnsConfigAsValue() const { |
115 return NULL; | 116 return NULL; |
116 } | 117 } |
117 | 118 |
118 // static | 119 // static |
119 scoped_ptr<HostResolver> | 120 scoped_ptr<HostResolver> HostResolver::CreateSystemResolver( |
120 HostResolver::CreateSystemResolver(const Options& options, NetLog* net_log) { | 121 const Options& options, |
| 122 NetLog* net_log) { |
121 scoped_ptr<HostCache> cache; | 123 scoped_ptr<HostCache> cache; |
122 if (options.enable_caching) | 124 if (options.enable_caching) |
123 cache = HostCache::CreateDefaultCache(); | 125 cache = HostCache::CreateDefaultCache(); |
124 return scoped_ptr<HostResolver>(new HostResolverImpl( | 126 return scoped_ptr<HostResolver>(new HostResolverImpl( |
125 cache.Pass(), | 127 cache.Pass(), |
126 GetDispatcherLimits(options), | 128 GetDispatcherLimits(options), |
127 HostResolverImpl::ProcTaskParams(NULL, options.max_retry_attempts), | 129 HostResolverImpl::ProcTaskParams(NULL, options.max_retry_attempts), |
128 net_log)); | 130 net_log)); |
129 } | 131 } |
130 | 132 |
131 // static | 133 // static |
132 scoped_ptr<HostResolver> | 134 scoped_ptr<HostResolver> HostResolver::CreateDefaultResolver(NetLog* net_log) { |
133 HostResolver::CreateDefaultResolver(NetLog* net_log) { | |
134 return CreateSystemResolver(Options(), net_log); | 135 return CreateSystemResolver(Options(), net_log); |
135 } | 136 } |
136 | 137 |
137 HostResolver::HostResolver() { | 138 HostResolver::HostResolver() { |
138 } | 139 } |
139 | 140 |
140 } // namespace net | 141 } // namespace net |
OLD | NEW |