OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <Winsock2.h> | 8 #include <Winsock2.h> |
9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
10 #include <netdb.h> | 10 #include <netdb.h> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 HostCache* cache = new HostCache( | 45 HostCache* cache = new HostCache( |
46 kMaxHostCacheEntries, | 46 kMaxHostCacheEntries, |
47 base::TimeDelta::FromMinutes(1), | 47 base::TimeDelta::FromMinutes(1), |
48 base::TimeDelta::FromSeconds(0)); // Disable caching of failed DNS. | 48 base::TimeDelta::FromSeconds(0)); // Disable caching of failed DNS. |
49 | 49 |
50 return cache; | 50 return cache; |
51 } | 51 } |
52 | 52 |
53 } // anonymous namespace | 53 } // anonymous namespace |
54 | 54 |
55 HostResolver* CreateSystemHostResolver() { | 55 HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves) { |
56 // Maximum of 50 concurrent threads. | 56 // Maximum of 50 concurrent threads. |
57 // TODO(eroman): Adjust this, do some A/B experiments. | 57 // TODO(eroman): Adjust this, do some A/B experiments. |
58 static const size_t kMaxJobs = 50u; | 58 static const size_t kDefaultMaxJobs = 50u; |
| 59 |
| 60 if (max_concurrent_resolves == HostResolver::kDefaultParallelism) |
| 61 max_concurrent_resolves = kDefaultMaxJobs; |
59 | 62 |
60 HostResolverImpl* resolver = | 63 HostResolverImpl* resolver = |
61 new HostResolverImpl(NULL, CreateDefaultCache(), kMaxJobs); | 64 new HostResolverImpl(NULL, CreateDefaultCache(), |
| 65 max_concurrent_resolves); |
62 | 66 |
63 return resolver; | 67 return resolver; |
64 } | 68 } |
65 | 69 |
66 static int ResolveAddrInfo(HostResolverProc* resolver_proc, | 70 static int ResolveAddrInfo(HostResolverProc* resolver_proc, |
67 const std::string& host, | 71 const std::string& host, |
68 AddressFamily address_family, | 72 AddressFamily address_family, |
69 HostResolverFlags host_resolver_flags, | 73 HostResolverFlags host_resolver_flags, |
70 AddressList* out, | 74 AddressList* out, |
71 int* os_error) { | 75 int* os_error) { |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 if (r == req) | 1153 if (r == req) |
1150 return error; | 1154 return error; |
1151 | 1155 |
1152 r->OnComplete(error, AddressList()); | 1156 r->OnComplete(error, AddressList()); |
1153 } | 1157 } |
1154 | 1158 |
1155 return ERR_IO_PENDING; | 1159 return ERR_IO_PENDING; |
1156 } | 1160 } |
1157 | 1161 |
1158 } // namespace net | 1162 } // namespace net |
OLD | NEW |