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 11 matching lines...) Expand all Loading... |
22 #include <map> | 22 #include <map> |
23 #include <queue> | 23 #include <queue> |
24 #include <set> | 24 #include <set> |
25 #include <string> | 25 #include <string> |
26 #include <vector> | 26 #include <vector> |
27 | 27 |
28 #include "base/gtest_prod_util.h" | 28 #include "base/gtest_prod_util.h" |
29 #include "base/memory/scoped_ptr.h" | 29 #include "base/memory/scoped_ptr.h" |
30 #include "base/memory/weak_ptr.h" | 30 #include "base/memory/weak_ptr.h" |
31 #include "chrome/browser/net/referrer.h" | 31 #include "chrome/browser/net/referrer.h" |
| 32 #include "chrome/browser/net/timed_cache.h" |
32 #include "chrome/browser/net/url_info.h" | 33 #include "chrome/browser/net/url_info.h" |
33 #include "chrome/common/net/predictor_common.h" | 34 #include "chrome/common/net/predictor_common.h" |
34 #include "net/base/host_port_pair.h" | 35 #include "net/base/host_port_pair.h" |
35 | 36 |
36 class IOThread; | 37 class IOThread; |
37 class PrefService; | 38 class PrefService; |
38 class Profile; | 39 class Profile; |
39 | 40 |
40 namespace base { | 41 namespace base { |
41 class ListValue; | 42 class ListValue; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 base::ListValue* startup_list, | 214 base::ListValue* startup_list, |
214 base::ListValue* referral_list, | 215 base::ListValue* referral_list, |
215 base::WaitableEvent* completion); | 216 base::WaitableEvent* completion); |
216 | 217 |
217 // May be called from either the IO or UI thread and will PostTask | 218 // May be called from either the IO or UI thread and will PostTask |
218 // to the IO thread if necessary. | 219 // to the IO thread if necessary. |
219 void EnablePredictor(bool enable); | 220 void EnablePredictor(bool enable); |
220 | 221 |
221 void EnablePredictorOnIOThread(bool enable); | 222 void EnablePredictorOnIOThread(bool enable); |
222 | 223 |
| 224 // May be called from either the IO or UI thread and will PostTask |
| 225 // to the IO thread if necessary. |
| 226 void PreconnectUrl(const GURL& url, const GURL& first_party_for_cookies, |
| 227 UrlInfo::ResolutionMotivation motivation, int count); |
| 228 |
| 229 void PreconnectUrlOnIOThread(const GURL& url, |
| 230 const GURL& first_party_for_cookies, |
| 231 UrlInfo::ResolutionMotivation motivation, |
| 232 int count); |
| 233 |
| 234 void RecordPreconnectNavigationStats(const GURL& url); |
| 235 |
223 // ------------- End IO thread methods. | 236 // ------------- End IO thread methods. |
224 | 237 |
225 // The following methods may be called on either the IO or UI threads. | 238 // The following methods may be called on either the IO or UI threads. |
226 | 239 |
227 // Instigate pre-connection to any URLs, or pre-resolution of related host, | 240 // Instigate pre-connection to any URLs, or pre-resolution of related host, |
228 // that we predict will be needed after this navigation (typically | 241 // that we predict will be needed after this navigation (typically |
229 // more-embedded resources on a page). This method will actually post a task | 242 // more-embedded resources on a page). This method will actually post a task |
230 // to do the actual work, so as not to jump ahead of the frame navigation that | 243 // to do the actual work, so as not to jump ahead of the frame navigation that |
231 // instigated this activity. | 244 // instigated this activity. |
232 void PredictFrameSubresources(const GURL& url, | 245 void PredictFrameSubresources(const GURL& url, |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // The time when the last preresolve was done for last_omnibox_host_. | 495 // The time when the last preresolve was done for last_omnibox_host_. |
483 base::TimeTicks last_omnibox_preresolve_; | 496 base::TimeTicks last_omnibox_preresolve_; |
484 | 497 |
485 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested | 498 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested |
486 // preconnecting (because it was to a search service). | 499 // preconnecting (because it was to a search service). |
487 int consecutive_omnibox_preconnect_count_; | 500 int consecutive_omnibox_preconnect_count_; |
488 | 501 |
489 // The time when the last preconnection was requested to a search service. | 502 // The time when the last preconnection was requested to a search service. |
490 base::TimeTicks last_omnibox_preconnect_; | 503 base::TimeTicks last_omnibox_preconnect_; |
491 | 504 |
| 505 TimedCache recent_preconnects_; |
| 506 |
492 // For each URL that we might navigate to (that we've "learned about") | 507 // For each URL that we might navigate to (that we've "learned about") |
493 // we have a Referrer list. Each Referrer list has all hostnames we might | 508 // we have a Referrer list. Each Referrer list has all hostnames we might |
494 // need to pre-resolve or pre-connect to when there is a navigation to the | 509 // need to pre-resolve or pre-connect to when there is a navigation to the |
495 // orginial hostname. | 510 // orginial hostname. |
496 Referrers referrers_; | 511 Referrers referrers_; |
497 | 512 |
498 // List of URLs in referrers_ currently being trimmed (scaled down to | 513 // List of URLs in referrers_ currently being trimmed (scaled down to |
499 // eventually be aged out of use). | 514 // eventually be aged out of use). |
500 std::vector<GURL> urls_being_trimmed_; | 515 std::vector<GURL> urls_being_trimmed_; |
501 | 516 |
(...skipping 15 matching lines...) Expand all Loading... |
517 PrefService* user_prefs, | 532 PrefService* user_prefs, |
518 PrefService* local_state, | 533 PrefService* local_state, |
519 IOThread* io_thread, | 534 IOThread* io_thread, |
520 net::URLRequestContextGetter* getter) OVERRIDE; | 535 net::URLRequestContextGetter* getter) OVERRIDE; |
521 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; | 536 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; |
522 }; | 537 }; |
523 | 538 |
524 } // namespace chrome_browser_net | 539 } // namespace chrome_browser_net |
525 | 540 |
526 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 541 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
OLD | NEW |