| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 class ProfileIOData; | 42 class ProfileIOData; |
| 43 | 43 |
| 44 namespace base { | 44 namespace base { |
| 45 class ListValue; | 45 class ListValue; |
| 46 class WaitableEvent; | 46 class WaitableEvent; |
| 47 } | 47 } |
| 48 | 48 |
| 49 namespace net { | 49 namespace net { |
| 50 class HostResolver; | 50 class HostResolver; |
| 51 class SSLConfigService; | 51 class SSLConfigService; |
| 52 class ProxyService; |
| 52 class TransportSecurityState; | 53 class TransportSecurityState; |
| 53 class URLRequestContextGetter; | 54 class URLRequestContextGetter; |
| 54 } | 55 } |
| 55 | 56 |
| 56 namespace user_prefs { | 57 namespace user_prefs { |
| 57 class PrefRegistrySyncable; | 58 class PrefRegistrySyncable; |
| 58 } | 59 } |
| 59 | 60 |
| 60 namespace chrome_browser_net { | 61 namespace chrome_browser_net { |
| 61 | 62 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest); | 312 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest); |
| 312 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest); | 313 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest); |
| 313 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest); | 314 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest); |
| 314 FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest); | 315 FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest); |
| 315 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); | 316 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); |
| 316 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); | 317 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); |
| 317 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); | 318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); |
| 318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor); | 319 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor); |
| 319 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor); | 320 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor); |
| 320 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor); | 321 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor); |
| 322 FRIEND_TEST_ALL_PREFIXES(PredictorTest, NoProxyService); |
| 323 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyEnabled); |
| 324 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyNotEnabled); |
| 325 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyMaybeEnabled); |
| 321 friend class WaitForResolutionHelper; // For testing. | 326 friend class WaitForResolutionHelper; // For testing. |
| 322 | 327 |
| 323 class LookupRequest; | 328 class LookupRequest; |
| 324 | 329 |
| 325 // A simple priority queue for handling host names. | 330 // A simple priority queue for handling host names. |
| 326 // Some names that are queued up have |motivation| that requires very rapid | 331 // Some names that are queued up have |motivation| that requires very rapid |
| 327 // handling. For example, a sub-resource name lookup MUST be done before the | 332 // handling. For example, a sub-resource name lookup MUST be done before the |
| 328 // actual sub-resource is fetched. In contrast, a name that was speculatively | 333 // actual sub-resource is fetched. In contrast, a name that was speculatively |
| 329 // noted in a page has to be resolved before the user "gets around to" | 334 // noted in a page has to be resolved before the user "gets around to" |
| 330 // clicking on a link. By tagging (with a motivation) each push we make into | 335 // clicking on a link. By tagging (with a motivation) each push we make into |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // If it does not process all the URLs in that vector, it posts a task to | 499 // If it does not process all the URLs in that vector, it posts a task to |
| 495 // continue with them shortly (i.e., it yeilds and continues). | 500 // continue with them shortly (i.e., it yeilds and continues). |
| 496 void IncrementalTrimReferrers(bool trim_all_now); | 501 void IncrementalTrimReferrers(bool trim_all_now); |
| 497 | 502 |
| 498 // If a proxy advisor is defined, let it know that |url| will be prefetched or | 503 // If a proxy advisor is defined, let it know that |url| will be prefetched or |
| 499 // preconnected to. | 504 // preconnected to. |
| 500 void AdviseProxyOnIOThread(const GURL& url, | 505 void AdviseProxyOnIOThread(const GURL& url, |
| 501 UrlInfo::ResolutionMotivation motivation, | 506 UrlInfo::ResolutionMotivation motivation, |
| 502 bool is_preconnect); | 507 bool is_preconnect); |
| 503 | 508 |
| 509 // If we can determine immediately (i.e. synchronously) that requests to this |
| 510 // URL would go through a proxy, then return true. Otherwise, return false. |
| 511 // This is used to avoid issuing DNS requests when a fixed proxy configuration |
| 512 // is in place, which is important if the unproxied DNS may contain incorrect |
| 513 // entries. |
| 514 bool WouldDefinitelyProxyURL(const GURL& url); |
| 515 |
| 504 // Applies the HSTS redirect for |url|, if any. | 516 // Applies the HSTS redirect for |url|, if any. |
| 505 GURL GetHSTSRedirectOnIOThread(const GURL& url); | 517 GURL GetHSTSRedirectOnIOThread(const GURL& url); |
| 506 | 518 |
| 507 // ------------- End IO thread methods. | 519 // ------------- End IO thread methods. |
| 508 | 520 |
| 509 scoped_ptr<InitialObserver> initial_observer_; | 521 scoped_ptr<InitialObserver> initial_observer_; |
| 510 | 522 |
| 511 // Reference to URLRequestContextGetter from the Profile which owns the | 523 // Reference to URLRequestContextGetter from the Profile which owns the |
| 512 // predictor. Used by Preconnect. | 524 // predictor. Used by Preconnect. |
| 513 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 525 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 // The host resolver we warm DNS entries for. | 563 // The host resolver we warm DNS entries for. |
| 552 net::HostResolver* host_resolver_; | 564 net::HostResolver* host_resolver_; |
| 553 | 565 |
| 554 // The TransportSecurityState instance we query HSTS redirects from. | 566 // The TransportSecurityState instance we query HSTS redirects from. |
| 555 net::TransportSecurityState* transport_security_state_; | 567 net::TransportSecurityState* transport_security_state_; |
| 556 | 568 |
| 557 // The SSLConfigService we query SNI support from (used in querying HSTS | 569 // The SSLConfigService we query SNI support from (used in querying HSTS |
| 558 // redirects). | 570 // redirects). |
| 559 net::SSLConfigService* ssl_config_service_; | 571 net::SSLConfigService* ssl_config_service_; |
| 560 | 572 |
| 573 // The ProxyService, used to determine whether preresolve is useful. |
| 574 net::ProxyService* proxy_service_; |
| 575 |
| 561 // Are we currently using preconnection, rather than just DNS resolution, for | 576 // Are we currently using preconnection, rather than just DNS resolution, for |
| 562 // subresources and omni-box search URLs. | 577 // subresources and omni-box search URLs. |
| 563 // This is false if and only if disabled by a command line switch. | 578 // This is false if and only if disabled by a command line switch. |
| 564 const bool preconnect_enabled_; | 579 const bool preconnect_enabled_; |
| 565 | 580 |
| 566 // Most recent suggestion from Omnibox provided via AnticipateOmniboxUrl(). | 581 // Most recent suggestion from Omnibox provided via AnticipateOmniboxUrl(). |
| 567 std::string last_omnibox_host_; | 582 std::string last_omnibox_host_; |
| 568 | 583 |
| 569 // The time when the last preresolve was done for last_omnibox_host_. | 584 // The time when the last preresolve was done for last_omnibox_host_. |
| 570 base::TimeTicks last_omnibox_preresolve_; | 585 base::TimeTicks last_omnibox_preresolve_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 virtual void ShutdownOnUIThread() OVERRIDE; | 629 virtual void ShutdownOnUIThread() OVERRIDE; |
| 615 private: | 630 private: |
| 616 // These member functions return True for unittests. | 631 // These member functions return True for unittests. |
| 617 virtual bool CanPrefetchAndPrerender() const OVERRIDE; | 632 virtual bool CanPrefetchAndPrerender() const OVERRIDE; |
| 618 virtual bool CanPreresolveAndPreconnect() const OVERRIDE; | 633 virtual bool CanPreresolveAndPreconnect() const OVERRIDE; |
| 619 }; | 634 }; |
| 620 | 635 |
| 621 } // namespace chrome_browser_net | 636 } // namespace chrome_browser_net |
| 622 | 637 |
| 623 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 638 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |