From 1933eb200c4bb16e4df535d779c98561f85c1e25 Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Thu, 19 Feb 2009 18:23:25 +0000 Subject: Clean up dns prefetch code, and also port it. - remove slave threads and use HostResolver in asynchronous mode instead (while still limiting number of concurrent lookups) - make the implementation portable and make DnsMaster unit test compile and pass on Linux - add more tests to DnsMaster unit test to simulate various shutdown scenarios, concurrent lookups, and to verify that we don't exceed our limit of concurrent lookup requests) - remove some tests which relied on specifics of slaves' inner working - adjust initialization and shutdown of dns prefetching (now it relies on the IO message loop being present) Bonus: shutdown is almost instant now, no need to have a timeout. BUG=5687, 6683 Review URL: http://codereview.chromium.org/15076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10021 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/net/dns_global.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'chrome/browser/net/dns_global.h') diff --git a/chrome/browser/net/dns_global.h b/chrome/browser/net/dns_global.h index 2ba0e70..80cf6ff 100644 --- a/chrome/browser/net/dns_global.h +++ b/chrome/browser/net/dns_global.h @@ -19,10 +19,17 @@ class PrefService; namespace chrome_browser_net { -// Functions to initialize our global state so that PrefetchDns() can be called. +// Initialize dns prefetching subsystem. Must be called before any other +// functions. void InitDnsPrefetch(PrefService* user_prefs); + +// Cancel pending lookup requests and don't make new ones. void ShutdownDnsPrefetch(); +// Free all resources allocated by InitDnsPrefetch. After that you must not call +// any function from this file. +void FreeDnsPrefetchResources(); + //------------------------------------------------------------------------------ // Global APIs relating to Prefetching in browser void EnableDnsPrefetch(bool enable); @@ -53,7 +60,10 @@ class DnsPrefetcherInit { explicit DnsPrefetcherInit(PrefService* user_prefs) { InitDnsPrefetch(user_prefs); } - ~DnsPrefetcherInit() {ShutdownDnsPrefetch();} + + ~DnsPrefetcherInit() { + FreeDnsPrefetchResources(); + } private: DISALLOW_COPY_AND_ASSIGN(DnsPrefetcherInit); -- cgit v1.1