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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 // to the IO thread if necessary. | 226 // to the IO thread if necessary. |
| 227 void EnablePredictor(bool enable); | 227 void EnablePredictor(bool enable); |
| 228 | 228 |
| 229 void EnablePredictorOnIOThread(bool enable); | 229 void EnablePredictorOnIOThread(bool enable); |
| 230 | 230 |
| 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 // May be called from either the IO or UI thread and will PostTask | |
|
cbentzel
2013/06/24 10:48:39
Is this comment correct? The name of it seems to i
kouhei (in TOK)
2013/06/25 03:33:50
Sorry I put this by mistake. Thank you for pointin
| |
| 237 // to the IO thread if necessary. | |
| 236 void PreconnectUrlOnIOThread(const GURL& url, | 238 void PreconnectUrlOnIOThread(const GURL& url, |
| 237 const GURL& first_party_for_cookies, | 239 const GURL& first_party_for_cookies, |
| 238 UrlInfo::ResolutionMotivation motivation, | 240 UrlInfo::ResolutionMotivation motivation, |
| 239 int count); | 241 int count); |
| 240 | 242 |
| 241 void RecordPreconnectNavigationStats(const GURL& url); | 243 // May be called from either the IO or UI thread and will PostTask |
| 244 // to the IO thread if necessary. | |
| 245 void RecordPreconnectTrigger(const GURL& url); | |
| 246 | |
| 247 // May be called from either the IO or UI thread and will PostTask | |
| 248 // to the IO thread if necessary. | |
| 249 void RecordPreconnectNavigationStat(const GURL& url, | |
| 250 const GURL& original_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 RecordPreconnectNavigationStatOnIOThread(const GURL& url, | |
| 468 const GURL& original_url); | |
| 469 | |
| 456 // ------------- End IO thread methods. | 470 // ------------- End IO thread methods. |
| 457 | 471 |
| 458 scoped_ptr<InitialObserver> initial_observer_; | 472 scoped_ptr<InitialObserver> initial_observer_; |
| 459 | 473 |
| 460 // Reference to URLRequestContextGetter from the Profile which owns the | 474 // Reference to URLRequestContextGetter from the Profile which owns the |
| 461 // predictor. Used by Preconnect. | 475 // predictor. Used by Preconnect. |
| 462 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 476 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 463 | 477 |
| 464 // Status of speculative DNS resolution and speculative TCP/IP connection | 478 // Status of speculative DNS resolution and speculative TCP/IP connection |
| 465 // feature. | 479 // 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_. | 516 // The time when the last preresolve was done for last_omnibox_host_. |
| 503 base::TimeTicks last_omnibox_preresolve_; | 517 base::TimeTicks last_omnibox_preresolve_; |
| 504 | 518 |
| 505 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested | 519 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested |
| 506 // preconnecting (because it was to a search service). | 520 // preconnecting (because it was to a search service). |
| 507 int consecutive_omnibox_preconnect_count_; | 521 int consecutive_omnibox_preconnect_count_; |
| 508 | 522 |
| 509 // The time when the last preconnection was requested to a search service. | 523 // The time when the last preconnection was requested to a search service. |
| 510 base::TimeTicks last_omnibox_preconnect_; | 524 base::TimeTicks last_omnibox_preconnect_; |
| 511 | 525 |
| 512 TimedCache recent_preconnects_; | 526 class PreconnectUsage; |
| 527 scoped_ptr<PreconnectUsage> preconnect_usage_; | |
| 513 | 528 |
| 514 // For each URL that we might navigate to (that we've "learned about") | 529 // 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 | 530 // 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 | 531 // need to pre-resolve or pre-connect to when there is a navigation to the |
| 517 // orginial hostname. | 532 // orginial hostname. |
| 518 Referrers referrers_; | 533 Referrers referrers_; |
| 519 | 534 |
| 520 // List of URLs in referrers_ currently being trimmed (scaled down to | 535 // List of URLs in referrers_ currently being trimmed (scaled down to |
| 521 // eventually be aged out of use). | 536 // eventually be aged out of use). |
| 522 std::vector<GURL> urls_being_trimmed_; | 537 std::vector<GURL> urls_being_trimmed_; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 539 PrefService* user_prefs, | 554 PrefService* user_prefs, |
| 540 PrefService* local_state, | 555 PrefService* local_state, |
| 541 IOThread* io_thread, | 556 IOThread* io_thread, |
| 542 net::URLRequestContextGetter* getter) OVERRIDE; | 557 net::URLRequestContextGetter* getter) OVERRIDE; |
| 543 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; | 558 virtual void ShutdownOnUIThread(PrefService* user_prefs) OVERRIDE; |
| 544 }; | 559 }; |
| 545 | 560 |
| 546 } // namespace chrome_browser_net | 561 } // namespace chrome_browser_net |
| 547 | 562 |
| 548 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 563 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |