| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 Predictor to be left as more generally usable code, and possibly | 8 // provided by Predictor 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/net/predictor.h" | 21 #include "chrome/browser/net/predictor.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class FieldTrial; | 24 class FieldTrial; |
| 25 } | 25 } |
| 26 | 26 |
| 27 class PrefService; | 27 class PrefService; |
| 28 | 28 |
| 29 namespace chrome_browser_net { | 29 namespace chrome_browser_net { |
| 30 | 30 |
| 31 // Deletes |referral_list| when done. | |
| 32 void FinalizePredictorInitialization( | |
| 33 Predictor* global_predictor, | |
| 34 const std::vector<GURL>& urls_to_prefetch, | |
| 35 ListValue* referral_list); | |
| 36 | |
| 37 // Free all resources allocated by FinalizePredictorInitialization. After that | |
| 38 // you must not call any function from this file. | |
| 39 void FreePredictorResources(); | |
| 40 | |
| 41 //------------------------------------------------------------------------------ | 31 //------------------------------------------------------------------------------ |
| 42 // Global APIs relating to predictions in browser. | 32 // Global APIs relating to predictions in browser. |
| 43 void EnablePredictor(bool enable); | |
| 44 void DiscardInitialNavigationHistory(); | |
| 45 void RegisterUserPrefs(PrefService* user_prefs); | 33 void RegisterUserPrefs(PrefService* user_prefs); |
| 46 | 34 |
| 47 // Renderer bundles up list and sends to this browser API via IPC. | |
| 48 // TODO(jar): Use UrlList instead to include port and scheme. | |
| 49 void DnsPrefetchList(const NameList& hostnames); | |
| 50 | |
| 51 // This API is used by the autocomplete popup box (as user types). | |
| 52 // This will either preresolve the domain name, or possibly preconnect creating | |
| 53 // an open TCP/IP connection to the host. | |
| 54 void AnticipateOmniboxUrl(const GURL& url, bool preconnectable); | |
| 55 | |
| 56 // This API should only be called when we're absolutely certain that we will | |
| 57 // be connecting to the URL. It will preconnect the url and it's associated | |
| 58 // subresource domains immediately. | |
| 59 void PreconnectUrlAndSubresources(const GURL& url); | |
| 60 | |
| 61 // When displaying info in about:dns, the following API is called. | |
| 62 void PredictorGetHtmlInfo(std::string* output); | |
| 63 | |
| 64 // Destroy the predictor's internal state: referrers and work queue. | |
| 65 void ClearPredictorCache(); | |
| 66 | |
| 67 //------------------------------------------------------------------------------ | |
| 68 // When we navigate to a frame that may contain embedded resources, we may know | |
| 69 // in advance some other URLs that will need to be connected to (via TCP and | |
| 70 // sometimes SSL). This function initiates those connections | |
| 71 void PredictFrameSubresources(const GURL& url); | |
| 72 | |
| 73 // During startup, we learn what the first N urls visited are, and then resolve | |
| 74 // the associated hosts ASAP during our next startup. | |
| 75 void LearnAboutInitialNavigation(const GURL& url); | |
| 76 | |
| 77 // Call when we should learn from a navigation about a relationship to a | |
| 78 // subresource target, and its containing frame, which was loaded as a referring | |
| 79 // URL. | |
| 80 void LearnFromNavigation(const GURL& referring_url, const GURL& target_url); | |
| 81 | |
| 82 //------------------------------------------------------------------------------ | |
| 83 void SavePredictorStateForNextStartupAndTrim(PrefService* prefs); | |
| 84 // Helper class to handle global init and shutdown. | 35 // Helper class to handle global init and shutdown. |
| 85 class PredictorInit { | 36 class PredictorInit { |
| 86 public: | 37 public: |
| 87 // Too many concurrent lookups performed in parallel may overload a resolver, | 38 // Too many concurrent lookups performed in parallel may overload a resolver, |
| 88 // or may cause problems for a local router. The following limits that count. | 39 // or may cause problems for a local router. The following limits that count. |
| 89 static const size_t kMaxSpeculativeParallelResolves; | 40 static const size_t kMaxSpeculativeParallelResolves; |
| 90 | 41 |
| 91 // When prefetch requests are queued beyond some period of time, then the | 42 // When prefetch requests are queued beyond some period of time, then the |
| 92 // system is congested, and we need to clear all queued requests to get out | 43 // system is congested, and we need to clear all queued requests to get out |
| 93 // of that state. The following is the suggested default time limit. | 44 // of that state. The following is the suggested default time limit. |
| 94 static const int kMaxSpeculativeResolveQueueDelayMs; | 45 static const int kMaxSpeculativeResolveQueueDelayMs; |
| 95 | 46 |
| 96 PredictorInit(PrefService* user_prefs, PrefService* local_state, | 47 PredictorInit(PrefService* user_prefs, PrefService* local_state, |
| 97 bool preconnect_enabled); | 48 Profile* profile, bool preconnect_enabled); |
| 98 ~PredictorInit(); | 49 ~PredictorInit(); |
| 99 | 50 |
| 100 private: | 51 private: |
| 101 // Maintain a field trial instance when we do A/B testing. | 52 // Maintain a field trial instance when we do A/B testing. |
| 102 scoped_refptr<base::FieldTrial> trial_; | 53 scoped_refptr<base::FieldTrial> trial_; |
| 103 | 54 |
| 104 DISALLOW_COPY_AND_ASSIGN(PredictorInit); | 55 DISALLOW_COPY_AND_ASSIGN(PredictorInit); |
| 105 }; | 56 }; |
| 106 | 57 |
| 107 } // namespace chrome_browser_net | 58 } // namespace chrome_browser_net |
| 108 | 59 |
| 109 #endif // CHROME_BROWSER_NET_PREDICTOR_API_H_ | 60 #endif // CHROME_BROWSER_NET_PREDICTOR_API_H_ |
| OLD | NEW |