| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 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 | |
| 7 // process. This allows the more standard DNS prefetching services, such as | |
| 8 // provided by Predictor to be left as more generally usable code, and possibly | |
| 9 // be shared across multiple client projects. | |
| 10 | |
| 11 #ifndef CHROME_BROWSER_NET_DNS_GLOBAL_H_ | |
| 12 #define CHROME_BROWSER_NET_DNS_GLOBAL_H_ | |
| 13 | |
| 14 | |
| 15 #include <string> | |
| 16 #include <vector> | |
| 17 | |
| 18 #include "base/field_trial.h" | |
| 19 #include "base/scoped_ptr.h" | |
| 20 #include "chrome/browser/autocomplete/autocomplete.h" | |
| 21 #include "chrome/browser/net/dns_master.h" | |
| 22 #include "net/base/host_resolver.h" | |
| 23 | |
| 24 class PrefService; | |
| 25 | |
| 26 namespace chrome_browser_net { | |
| 27 | |
| 28 // Deletes |referral_list| when done. | |
| 29 void FinalizePredictorInitialization( | |
| 30 Predictor* global_predictor, | |
| 31 net::HostResolver::Observer* global_prefetch_observer, | |
| 32 const std::vector<GURL>& urls_to_prefetch, | |
| 33 ListValue* referral_list); | |
| 34 | |
| 35 // Free all resources allocated by FinalizePredictorInitialization. After that | |
| 36 // you must not call any function from this file. | |
| 37 void FreePredictorResources(); | |
| 38 | |
| 39 // Creates the HostResolver observer for the prefetching system. | |
| 40 net::HostResolver::Observer* CreateResolverObserver(); | |
| 41 | |
| 42 //------------------------------------------------------------------------------ | |
| 43 // Global APIs relating to predictions in browser. | |
| 44 void EnablePredictor(bool enable); | |
| 45 void RegisterPrefs(PrefService* local_state); | |
| 46 void RegisterUserPrefs(PrefService* user_prefs); | |
| 47 | |
| 48 // Renderer bundles up list and sends to this browser API via IPC. | |
| 49 // TODO(jar): Use UrlList instead to include port and scheme. | |
| 50 void DnsPrefetchList(const NameList& hostnames); | |
| 51 | |
| 52 // This API is used by the autocomplete popup box (as user types). | |
| 53 // This will either preresolve the domain name, or possibly preconnect creating | |
| 54 // an open TCP/IP connection to the host. | |
| 55 void AnticipateUrl(const GURL& url, bool preconnectable); | |
| 56 | |
| 57 // When displaying info in about:dns, the following API is called. | |
| 58 void PredictorGetHtmlInfo(std::string* output); | |
| 59 | |
| 60 //------------------------------------------------------------------------------ | |
| 61 // When we navigate, we may know in advance some other URLs that will need to | |
| 62 // be resolved. This function initiates those side effects. | |
| 63 void PredictSubresources(const GURL& url); | |
| 64 | |
| 65 // When we navigate to a frame that may contain embedded resources, we may know | |
| 66 // in advance some other URLs that will need to be connected to (via TCP and | |
| 67 // sometimes SSL). This function initiates those connections | |
| 68 void PredictFrameSubresources(const GURL& url); | |
| 69 | |
| 70 // Call when we should learn from a navigation about a relationship to a | |
| 71 // subresource target, and its containing frame, which was loaded as a referring | |
| 72 // URL. | |
| 73 void LearnFromNavigation(const GURL& referring_url, const GURL& target_url); | |
| 74 | |
| 75 //------------------------------------------------------------------------------ | |
| 76 void SavePredictorStateForNextStartupAndTrim(PrefService* prefs); | |
| 77 // Helper class to handle global init and shutdown. | |
| 78 class PredictorInit { | |
| 79 public: | |
| 80 // Too many concurrent lookups negate benefits of prefetching by trashing | |
| 81 // the OS cache before all resource loading is complete. | |
| 82 // This is the default. | |
| 83 static const size_t kMaxPrefetchConcurrentLookups; | |
| 84 | |
| 85 // When prefetch requests are queued beyond some period of time, then the | |
| 86 // system is congested, and we need to clear all queued requests to get out | |
| 87 // of that state. The following is the suggested default time limit. | |
| 88 static const int kMaxPrefetchQueueingDelayMs; | |
| 89 | |
| 90 PredictorInit(PrefService* user_prefs, PrefService* local_state, | |
| 91 bool preconnect_enabled); | |
| 92 | |
| 93 private: | |
| 94 // Maintain a field trial instance when we do A/B testing. | |
| 95 scoped_refptr<FieldTrial> trial_; | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(PredictorInit); | |
| 98 }; | |
| 99 | |
| 100 } // namespace chrome_browser_net | |
| 101 | |
| 102 #endif // CHROME_BROWSER_NET_DNS_GLOBAL_H_ | |
| OLD | NEW |