| 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 // This is the global interface for the dns prefetch services. It centralizes | 5 // This is the global interface for the dns prefetch services. It centralizes |
| 6 // initialization, along with all the callbacks etc. to connect to the browser | 6 // initialization, along with all the callbacks etc. to connect to the browser |
| 7 // process. This allows the more standard DNS prefetching services, such as | 7 // process. This allows the more standard DNS prefetching services, such as |
| 8 // provided by DnsMaster to be left as more generally usable code, and possibly | 8 // provided by DnsMaster to be left as more generally usable code, and possibly |
| 9 // be shared across multiple client projects. | 9 // be shared across multiple client projects. |
| 10 | 10 |
| 11 #ifndef CHROME_BROWSER_NET_DNS_GLOBAL_H_ | 11 #ifndef CHROME_BROWSER_NET_DNS_GLOBAL_H_ |
| 12 #define CHROME_BROWSER_NET_DNS_GLOBAL_H_ | 12 #define CHROME_BROWSER_NET_DNS_GLOBAL_H_ |
| 13 | 13 |
| 14 #include "chrome/browser/net/dns_master.h" | 14 #include "chrome/browser/net/dns_master.h" |
| 15 | 15 |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 class PrefService; | 18 class PrefService; |
| 19 | 19 |
| 20 namespace chrome_browser_net { | 20 namespace chrome_browser_net { |
| 21 | 21 |
| 22 // Functions to initialize our global state so that PrefetchDns() can be called. | 22 // Initialize dns prefetching subsystem. Must be called before any other |
| 23 // functions. |
| 23 void InitDnsPrefetch(PrefService* user_prefs); | 24 void InitDnsPrefetch(PrefService* user_prefs); |
| 25 |
| 26 // Cancel pending lookup requests and don't make new ones. |
| 24 void ShutdownDnsPrefetch(); | 27 void ShutdownDnsPrefetch(); |
| 25 | 28 |
| 29 // Free all resources allocated by InitDnsPrefetch. After that you must not call |
| 30 // any function from this file. |
| 31 void FreeDnsPrefetchResources(); |
| 32 |
| 26 //------------------------------------------------------------------------------ | 33 //------------------------------------------------------------------------------ |
| 27 // Global APIs relating to Prefetching in browser | 34 // Global APIs relating to Prefetching in browser |
| 28 void EnableDnsPrefetch(bool enable); | 35 void EnableDnsPrefetch(bool enable); |
| 29 void RegisterPrefs(PrefService* local_state); | 36 void RegisterPrefs(PrefService* local_state); |
| 30 void RegisterUserPrefs(PrefService* user_prefs); | 37 void RegisterUserPrefs(PrefService* user_prefs); |
| 31 // Renderer bundles up list and sends to this browser API via IPC. | 38 // Renderer bundles up list and sends to this browser API via IPC. |
| 32 void DnsPrefetchList(const NameList& hostnames); | 39 void DnsPrefetchList(const NameList& hostnames); |
| 33 // This API is used by the autocomplete popup box (as user types). | 40 // This API is used by the autocomplete popup box (as user types). |
| 34 void DnsPrefetchUrl(const GURL& url); | 41 void DnsPrefetchUrl(const GURL& url); |
| 35 void DnsPrefetchGetHtmlInfo(std::string* output); | 42 void DnsPrefetchGetHtmlInfo(std::string* output); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 46 void RestoreSubresourceReferrers(PrefService* local_state); | 53 void RestoreSubresourceReferrers(PrefService* local_state); |
| 47 void TrimSubresourceReferrers(); | 54 void TrimSubresourceReferrers(); |
| 48 | 55 |
| 49 //------------------------------------------------------------------------------ | 56 //------------------------------------------------------------------------------ |
| 50 // Helper class to handle global init and shutdown. | 57 // Helper class to handle global init and shutdown. |
| 51 class DnsPrefetcherInit { | 58 class DnsPrefetcherInit { |
| 52 public: | 59 public: |
| 53 explicit DnsPrefetcherInit(PrefService* user_prefs) { | 60 explicit DnsPrefetcherInit(PrefService* user_prefs) { |
| 54 InitDnsPrefetch(user_prefs); | 61 InitDnsPrefetch(user_prefs); |
| 55 } | 62 } |
| 56 ~DnsPrefetcherInit() {ShutdownDnsPrefetch();} | 63 |
| 64 ~DnsPrefetcherInit() { |
| 65 FreeDnsPrefetchResources(); |
| 66 } |
| 57 | 67 |
| 58 private: | 68 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(DnsPrefetcherInit); | 69 DISALLOW_COPY_AND_ASSIGN(DnsPrefetcherInit); |
| 60 }; | 70 }; |
| 61 | 71 |
| 62 } // namespace chrome_browser_net | 72 } // namespace chrome_browser_net |
| 63 | 73 |
| 64 #endif // CHROME_BROWSER_NET_DNS_GLOBAL_H_ | 74 #endif // CHROME_BROWSER_NET_DNS_GLOBAL_H_ |
| 65 | 75 |
| OLD | NEW |