Chromium Code Reviews| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 // May be called from either the IO or UI thread and will PostTask | 231 // May be called from either the IO or UI thread and will PostTask |
| 232 // to the IO thread if necessary. | 232 // to the IO thread if necessary. |
| 233 void PreconnectUrl(const GURL& url, const GURL& first_party_for_cookies, | 233 void PreconnectUrl(const GURL& url, const GURL& first_party_for_cookies, |
| 234 UrlInfo::ResolutionMotivation motivation, int count); | 234 UrlInfo::ResolutionMotivation motivation, int count); |
| 235 | 235 |
| 236 void PreconnectUrlOnIOThread(const GURL& url, | 236 void PreconnectUrlOnIOThread(const GURL& url, |
| 237 const GURL& first_party_for_cookies, | 237 const GURL& first_party_for_cookies, |
| 238 UrlInfo::ResolutionMotivation motivation, | 238 UrlInfo::ResolutionMotivation motivation, |
| 239 int count); | 239 int count); |
| 240 | 240 |
| 241 void RecordPreconnectNavigationStats(const GURL& url); | 241 // May be called from either the IO or UI thread and will PostTask |
|
jar (doing other things)
2013/08/01 22:56:47
nit: (personal?) I think it is a bad pattern to pr
kouhei (in TOK)
2013/08/02 06:18:03
I changed so that callers PostTask to IOThread.
| |
| 242 // to the IO thread if necessary. | |
| 243 void RecordPreconnectTrigger(const GURL& url); | |
| 244 | |
| 245 void RecordPreconnectNavigationStat(const std::vector<GURL>& url_chain, | |
| 246 bool is_subresource); | |
| 247 | |
| 248 // May be called from either the IO or UI thread and will PostTask | |
|
jar (doing other things)
2013/08/01 22:56:47
nit: same comment on pattern as above.
kouhei (in TOK)
2013/08/02 06:18:03
Done.
| |
| 249 // to the IO thread if necessary. | |
| 250 void RecordLinkNavigation(const GURL& url); | |
| 242 | 251 |
| 243 // ------------- End IO thread methods. | 252 // ------------- End IO thread methods. |
| 244 | 253 |
| 245 // The following methods may be called on either the IO or UI threads. | 254 // The following methods may be called on either the IO or UI threads. |
| 246 | 255 |
| 247 // Instigate pre-connection to any URLs, or pre-resolution of related host, | 256 // Instigate pre-connection to any URLs, or pre-resolution of related host, |
| 248 // that we predict will be needed after this navigation (typically | 257 // that we predict will be needed after this navigation (typically |
| 249 // more-embedded resources on a page). This method will actually post a task | 258 // more-embedded resources on a page). This method will actually post a task |
| 250 // to do the actual work, so as not to jump ahead of the frame navigation that | 259 // to do the actual work, so as not to jump ahead of the frame navigation that |
| 251 // instigated this activity. | 260 // instigated this activity. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 void LoadUrlsForTrimming(); | 455 void LoadUrlsForTrimming(); |
| 447 | 456 |
| 448 // Posts a task to do additional incremental trimming of referrers_. | 457 // Posts a task to do additional incremental trimming of referrers_. |
| 449 void PostIncrementalTrimTask(); | 458 void PostIncrementalTrimTask(); |
| 450 | 459 |
| 451 // Calls Trim() on some or all of urls_being_trimmed_. | 460 // Calls Trim() on some or all of urls_being_trimmed_. |
| 452 // If it does not process all the URLs in that vector, it posts a task to | 461 // If it does not process all the URLs in that vector, it posts a task to |
| 453 // continue with them shortly (i.e., it yeilds and continues). | 462 // continue with them shortly (i.e., it yeilds and continues). |
| 454 void IncrementalTrimReferrers(bool trim_all_now); | 463 void IncrementalTrimReferrers(bool trim_all_now); |
| 455 | 464 |
| 465 void RecordPreconnectTriggerOnIOThread(const GURL& url); | |
| 466 | |
| 467 void RecordLinkNavigationOnIOThread(const GURL& url); | |
|
jar (doing other things)
2013/08/01 22:56:47
So you have this method... it is just IMO nicer to
kouhei (in TOK)
2013/08/02 06:18:03
Done.
| |
| 468 | |
| 456 // ------------- End IO thread methods. | 469 // ------------- End IO thread methods. |
| 457 | 470 |
| 458 scoped_ptr<InitialObserver> initial_observer_; | 471 scoped_ptr<InitialObserver> initial_observer_; |
| 459 | 472 |
| 460 // Reference to URLRequestContextGetter from the Profile which owns the | 473 // Reference to URLRequestContextGetter from the Profile which owns the |
| 461 // predictor. Used by Preconnect. | 474 // predictor. Used by Preconnect. |
| 462 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 475 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 463 | 476 |
| 464 // Status of speculative DNS resolution and speculative TCP/IP connection | 477 // Status of speculative DNS resolution and speculative TCP/IP connection |
| 465 // feature. | 478 // feature. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 // The time when the last preresolve was done for last_omnibox_host_. | 515 // The time when the last preresolve was done for last_omnibox_host_. |
| 503 base::TimeTicks last_omnibox_preresolve_; | 516 base::TimeTicks last_omnibox_preresolve_; |
| 504 | 517 |
| 505 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested | 518 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested |
| 506 // preconnecting (because it was to a search service). | 519 // preconnecting (because it was to a search service). |
| 507 int consecutive_omnibox_preconnect_count_; | 520 int consecutive_omnibox_preconnect_count_; |
| 508 | 521 |
| 509 // The time when the last preconnection was requested to a search service. | 522 // The time when the last preconnection was requested to a search service. |
| 510 base::TimeTicks last_omnibox_preconnect_; | 523 base::TimeTicks last_omnibox_preconnect_; |
| 511 | 524 |
| 512 TimedCache recent_preconnects_; | 525 class PreconnectUsage; |
| 526 scoped_ptr<PreconnectUsage> preconnect_usage_; | |
| 513 | 527 |
| 514 // For each URL that we might navigate to (that we've "learned about") | 528 // For each URL that we might navigate to (that we've "learned about") |
| 515 // we have a Referrer list. Each Referrer list has all hostnames we might | 529 // we have a Referrer list. Each Referrer list has all hostnames we might |
| 516 // need to pre-resolve or pre-connect to when there is a navigation to the | 530 // need to pre-resolve or pre-connect to when there is a navigation to the |
| 517 // orginial hostname. | 531 // orginial hostname. |
| 518 Referrers referrers_; | 532 Referrers referrers_; |
| 519 | 533 |
| 520 // List of URLs in referrers_ currently being trimmed (scaled down to | 534 // List of URLs in referrers_ currently being trimmed (scaled down to |
| 521 // eventually be aged out of use). | 535 // eventually be aged out of use). |
| 522 std::vector<GURL> urls_being_trimmed_; | 536 std::vector<GURL> urls_being_trimmed_; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 539 PrefService* user_prefs, | 553 PrefService* user_prefs, |
| 540 PrefService* local_state, | 554 PrefService* local_state, |
| 541 IOThread* io_thread, | 555 IOThread* io_thread, |
| 542 net::URLRequestContextGetter* getter) OVERRIDE; | 556 net::URLRequestContextGetter* getter) OVERRIDE; |
| 543 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; | 557 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; |
| 544 }; | 558 }; |
| 545 | 559 |
| 546 } // namespace chrome_browser_net | 560 } // namespace chrome_browser_net |
| 547 | 561 |
| 548 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 562 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |