| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 Predictor object is instantiated once in the browser process, and manages | 5 // A Predictor object is instantiated once in the browser process, and manages |
| 6 // both preresolution of hostnames, as well as TCP/IP preconnection to expected | 6 // both preresolution of hostnames, as well as TCP/IP preconnection to expected |
| 7 // subresources. | 7 // subresources. |
| 8 // Most hostname lists are provided by the renderer processes, and include URLs | 8 // Most hostname lists are provided by the renderer processes, and include URLs |
| 9 // that *might* be used in the near future by the browsing user. One goal of | 9 // that *might* be used in the near future by the browsing user. One goal of |
| 10 // this class is to cause the underlying DNS structure to lookup a hostname | 10 // this class is to cause the underlying DNS structure to lookup a hostname |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 class TransportSecurityState; | 56 class TransportSecurityState; |
| 57 class URLRequestContextGetter; | 57 class URLRequestContextGetter; |
| 58 } | 58 } |
| 59 | 59 |
| 60 namespace user_prefs { | 60 namespace user_prefs { |
| 61 class PrefRegistrySyncable; | 61 class PrefRegistrySyncable; |
| 62 } | 62 } |
| 63 | 63 |
| 64 namespace chrome_browser_net { | 64 namespace chrome_browser_net { |
| 65 | 65 |
| 66 typedef network_hints::UrlList UrlList; | |
| 67 typedef network_hints::NameList NameList; | |
| 68 typedef std::map<GURL, UrlInfo> Results; | 66 typedef std::map<GURL, UrlInfo> Results; |
| 69 | 67 |
| 70 // An observer for testing. | 68 // An observer for testing. |
| 71 class PredictorObserver { | 69 class PredictorObserver { |
| 72 public: | 70 public: |
| 73 virtual ~PredictorObserver() {} | 71 virtual ~PredictorObserver() {} |
| 74 | 72 |
| 75 virtual void OnPreconnectUrl(const GURL& original_url, | 73 virtual void OnPreconnectUrl(const GURL& original_url, |
| 76 const GURL& first_party_for_cookies, | 74 const GURL& first_party_for_cookies, |
| 77 UrlInfo::ResolutionMotivation motivation, | 75 UrlInfo::ResolutionMotivation motivation, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 144 |
| 147 // The Omnibox has proposed a given url to the user, and if it is a search | 145 // The Omnibox has proposed a given url to the user, and if it is a search |
| 148 // URL, then it also indicates that this is preconnectable (i.e., we could | 146 // URL, then it also indicates that this is preconnectable (i.e., we could |
| 149 // preconnect to the search server). | 147 // preconnect to the search server). |
| 150 void AnticipateOmniboxUrl(const GURL& url, bool preconnectable); | 148 void AnticipateOmniboxUrl(const GURL& url, bool preconnectable); |
| 151 | 149 |
| 152 // Preconnect a URL and all of its subresource domains. | 150 // Preconnect a URL and all of its subresource domains. |
| 153 void PreconnectUrlAndSubresources(const GURL& url, | 151 void PreconnectUrlAndSubresources(const GURL& url, |
| 154 const GURL& first_party_for_cookies); | 152 const GURL& first_party_for_cookies); |
| 155 | 153 |
| 156 static UrlList GetPredictedUrlListAtStartup(PrefService* user_prefs); | 154 static std::vector<GURL> GetPredictedUrlListAtStartup( |
| 155 PrefService* user_prefs); |
| 157 | 156 |
| 158 static void set_max_queueing_delay(int max_queueing_delay_ms); | 157 static void set_max_queueing_delay(int max_queueing_delay_ms); |
| 159 | 158 |
| 160 static void set_max_parallel_resolves(size_t max_parallel_resolves); | 159 static void set_max_parallel_resolves(size_t max_parallel_resolves); |
| 161 | 160 |
| 162 virtual void ShutdownOnUIThread(); | 161 virtual void ShutdownOnUIThread(); |
| 163 | 162 |
| 164 // ------------- End UI thread methods. | 163 // ------------- End UI thread methods. |
| 165 | 164 |
| 166 // ------------- Start IO thread methods. | 165 // ------------- Start IO thread methods. |
| 167 | 166 |
| 168 // Cancel pending requests and prevent new ones from being made. | 167 // Cancel pending requests and prevent new ones from being made. |
| 169 void Shutdown(); | 168 void Shutdown(); |
| 170 | 169 |
| 171 // In some circumstances, for privacy reasons, all results should be | 170 // In some circumstances, for privacy reasons, all results should be |
| 172 // discarded. This method gracefully handles that activity. | 171 // discarded. This method gracefully handles that activity. |
| 173 // Destroy all our internal state, which shows what names we've looked up, and | 172 // Destroy all our internal state, which shows what names we've looked up, and |
| 174 // how long each has taken, etc. etc. We also destroy records of suggesses | 173 // how long each has taken, etc. etc. We also destroy records of suggesses |
| 175 // (cache hits etc.). | 174 // (cache hits etc.). |
| 176 void DiscardAllResults(); | 175 void DiscardAllResults(); |
| 177 | 176 |
| 178 // Add hostname(s) to the queue for processing. | 177 // Add hostname(s) to the queue for processing. |
| 179 void ResolveList(const UrlList& urls, | 178 void ResolveList(const std::vector<GURL>& urls, |
| 180 UrlInfo::ResolutionMotivation motivation); | 179 UrlInfo::ResolutionMotivation motivation); |
| 181 | 180 |
| 182 void Resolve(const GURL& url, UrlInfo::ResolutionMotivation motivation); | 181 void Resolve(const GURL& url, UrlInfo::ResolutionMotivation motivation); |
| 183 | 182 |
| 184 // Record details of a navigation so that we can preresolve the host name | 183 // Record details of a navigation so that we can preresolve the host name |
| 185 // ahead of time the next time the users navigates to the indicated host. | 184 // ahead of time the next time the users navigates to the indicated host. |
| 186 // Should only be called when urls are distinct, and they should already be | 185 // Should only be called when urls are distinct, and they should already be |
| 187 // canonicalized to not have a path. | 186 // canonicalized to not have a path. |
| 188 void LearnFromNavigation(const GURL& referring_url, const GURL& target_url); | 187 void LearnFromNavigation(const GURL& referring_url, const GURL& target_url); |
| 189 | 188 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 const std::vector<GURL>& urls_to_prefetch, | 221 const std::vector<GURL>& urls_to_prefetch, |
| 223 base::ListValue* referral_list, | 222 base::ListValue* referral_list, |
| 224 IOThread* io_thread, | 223 IOThread* io_thread, |
| 225 ProfileIOData* profile_io_data); | 224 ProfileIOData* profile_io_data); |
| 226 | 225 |
| 227 // During startup, we learn what the first N urls visited are, and then | 226 // During startup, we learn what the first N urls visited are, and then |
| 228 // resolve the associated hosts ASAP during our next startup. | 227 // resolve the associated hosts ASAP during our next startup. |
| 229 void LearnAboutInitialNavigation(const GURL& url); | 228 void LearnAboutInitialNavigation(const GURL& url); |
| 230 | 229 |
| 231 // Renderer bundles up list and sends to this browser API via IPC. | 230 // Renderer bundles up list and sends to this browser API via IPC. |
| 232 // TODO(jar): Use UrlList instead to include port and scheme. | 231 // TODO(csharrison): Use a GURL vector instead to include port and scheme. |
| 233 void DnsPrefetchList(const NameList& hostnames); | 232 void DnsPrefetchList(const std::vector<std::string>& hostnames); |
| 234 | 233 |
| 235 // May be called from either the IO or UI thread and will PostTask | 234 // May be called from either the IO or UI thread and will PostTask |
| 236 // to the IO thread if necessary. | 235 // to the IO thread if necessary. |
| 237 void DnsPrefetchMotivatedList(const UrlList& urls, | 236 void DnsPrefetchMotivatedList(const std::vector<GURL>& urls, |
| 238 UrlInfo::ResolutionMotivation motivation); | 237 UrlInfo::ResolutionMotivation motivation); |
| 239 | 238 |
| 240 // May be called from either the IO or UI thread and will PostTask | 239 // May be called from either the IO or UI thread and will PostTask |
| 241 // to the IO thread if necessary. | 240 // to the IO thread if necessary. |
| 242 void SaveStateForNextStartupAndTrim(); | 241 void SaveStateForNextStartupAndTrim(); |
| 243 | 242 |
| 244 void SaveDnsPrefetchStateForNextStartupAndTrim( | 243 void SaveDnsPrefetchStateForNextStartupAndTrim( |
| 245 base::ListValue* startup_list, | 244 base::ListValue* startup_list, |
| 246 base::ListValue* referral_list, | 245 base::ListValue* referral_list, |
| 247 base::WaitableEvent* completion); | 246 base::WaitableEvent* completion); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 597 |
| 599 private: | 598 private: |
| 600 // These member functions return True for unittests. | 599 // These member functions return True for unittests. |
| 601 bool CanPrefetchAndPrerender() const override; | 600 bool CanPrefetchAndPrerender() const override; |
| 602 bool CanPreresolveAndPreconnect() const override; | 601 bool CanPreresolveAndPreconnect() const override; |
| 603 }; | 602 }; |
| 604 | 603 |
| 605 } // namespace chrome_browser_net | 604 } // namespace chrome_browser_net |
| 606 | 605 |
| 607 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 606 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |