OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // A DnsMaster object is instantiated once in the browser | 5 // A DnsMaster object is instantiated once in the browser |
6 // process, and manages asynchronous resolution of DNS hostnames. | 6 // process, and manages asynchronous resolution of DNS hostnames. |
7 // Most hostname lists are sent out by renderer processes, and | 7 // Most hostname lists are sent out by renderer processes, and |
8 // involve lists of hostnames that *might* be used in the near | 8 // involve lists of hostnames that *might* be used in the near |
9 // future by the browsing user. The goal of this class is to | 9 // future by the browsing user. The goal of this class is to |
10 // cause the underlying DNS structure to lookup a hostname before | 10 // cause the underlying DNS structure to lookup a hostname before |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/net/referrer.h" | 25 #include "chrome/browser/net/referrer.h" |
26 #include "chrome/common/net/dns.h" | 26 #include "chrome/common/net/dns.h" |
27 #include "testing/gtest/include/gtest/gtest_prod.h" | 27 #include "testing/gtest/include/gtest/gtest_prod.h" |
28 | 28 |
29 using base::TimeDelta; | 29 using base::TimeDelta; |
30 | 30 |
31 namespace net { | 31 namespace net { |
32 class HostResolver; | 32 class HostResolver; |
33 } | 33 } |
34 | 34 |
35 class MessageLoop; | |
36 | |
37 namespace chrome_browser_net { | 35 namespace chrome_browser_net { |
38 | 36 |
39 typedef chrome_common_net::NameList NameList; | 37 typedef chrome_common_net::NameList NameList; |
40 typedef std::map<std::string, DnsHostInfo> Results; | 38 typedef std::map<std::string, DnsHostInfo> Results; |
41 | 39 |
42 class DnsMaster : public base::RefCountedThreadSafe<DnsMaster> { | 40 class DnsMaster : public base::RefCountedThreadSafe<DnsMaster> { |
43 public: | 41 public: |
44 // |max_concurrent| specifies how many concurrent (paralell) prefetches will | 42 // |max_concurrent| specifies how many concurrent (paralell) prefetches will |
45 // be performed. Host lookups will be issued on the |host_resolver_loop| | 43 // be performed. Host lookups will be issued on the IO thread, using the |
46 // thread, using the |host_resolver| instance. | 44 // |host_resolver| instance. |
47 DnsMaster(net::HostResolver* host_resolver, MessageLoop* host_resolver_loop, | 45 DnsMaster(net::HostResolver* host_resolver, |
48 TimeDelta max_queue_delay_ms, size_t max_concurrent); | 46 TimeDelta max_queue_delay_ms, size_t max_concurrent); |
49 ~DnsMaster(); | 47 ~DnsMaster(); |
50 | 48 |
51 // Cancel pending requests and prevent new ones from being made. | 49 // Cancel pending requests and prevent new ones from being made. |
52 void Shutdown(); | 50 void Shutdown(); |
53 | 51 |
54 // In some circumstances, for privacy reasons, all results should be | 52 // In some circumstances, for privacy reasons, all results should be |
55 // discarded. This method gracefully handles that activity. | 53 // discarded. This method gracefully handles that activity. |
56 // Destroy all our internal state, which shows what names we've looked up, and | 54 // Destroy all our internal state, which shows what names we've looked up, and |
57 // how long each has taken, etc. etc. We also destroy records of suggesses | 55 // how long each has taken, etc. etc. We also destroy records of suggesses |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 Results cache_eviction_map_; | 227 Results cache_eviction_map_; |
230 | 228 |
231 // The number of concurrent lookups currently allowed. | 229 // The number of concurrent lookups currently allowed. |
232 const size_t max_concurrent_lookups_; | 230 const size_t max_concurrent_lookups_; |
233 | 231 |
234 // The maximum queueing delay that is acceptable before we enter congestion | 232 // The maximum queueing delay that is acceptable before we enter congestion |
235 // reduction mode, and discard all queued (but not yet assigned) resolutions. | 233 // reduction mode, and discard all queued (but not yet assigned) resolutions. |
236 const TimeDelta max_queue_delay_; | 234 const TimeDelta max_queue_delay_; |
237 | 235 |
238 // The host resovler we warm DNS entries for. The resolver (which is not | 236 // The host resovler we warm DNS entries for. The resolver (which is not |
239 // thread safe) should be accessed only on |host_resolver_loop_|. | 237 // thread safe) should be accessed only on the IO thread. |
240 scoped_refptr<net::HostResolver> host_resolver_; | 238 scoped_refptr<net::HostResolver> host_resolver_; |
241 MessageLoop* host_resolver_loop_; | |
242 | 239 |
243 DISALLOW_COPY_AND_ASSIGN(DnsMaster); | 240 DISALLOW_COPY_AND_ASSIGN(DnsMaster); |
244 }; | 241 }; |
245 | 242 |
246 } // namespace chrome_browser_net | 243 } // namespace chrome_browser_net |
247 | 244 |
248 #endif // CHROME_BROWSER_NET_DNS_MASTER_H_ | 245 #endif // CHROME_BROWSER_NET_DNS_MASTER_H_ |
OLD | NEW |