| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // Only for testing; | 428 // Only for testing; |
| 429 size_t peak_pending_lookups() const { return peak_pending_lookups_; } | 429 size_t peak_pending_lookups() const { return peak_pending_lookups_; } |
| 430 | 430 |
| 431 // If a proxy advisor is defined, let it know that |url| will be prefetched or | 431 // If a proxy advisor is defined, let it know that |url| will be prefetched or |
| 432 // preconnected to. Can be called on either UI or IO threads and will post to | 432 // preconnected to. Can be called on either UI or IO threads and will post to |
| 433 // the IO thread if necessary, invoking AdviseProxyOnIOThread(). | 433 // the IO thread if necessary, invoking AdviseProxyOnIOThread(). |
| 434 void AdviseProxy(const GURL& url, | 434 void AdviseProxy(const GURL& url, |
| 435 UrlInfo::ResolutionMotivation motivation, | 435 UrlInfo::ResolutionMotivation motivation, |
| 436 bool is_preconnect); | 436 bool is_preconnect); |
| 437 | 437 |
| 438 // There two members call the corresponding global functions in | 438 // These two members call the appropriate global functions in |
| 439 // prediction_options.cc. | 439 // prediction_options.cc depending on which thread they are called on. |
| 440 virtual bool CanPredictNetworkActionsUI(); | 440 virtual bool CanPrefetchAndPrerender() const; |
| 441 virtual bool CanPredictNetworkActionsIO(); | 441 virtual bool CanPreresolveAndPreconnect() const; |
| 442 | 442 |
| 443 // ------------- Start IO thread methods. | 443 // ------------- Start IO thread methods. |
| 444 | 444 |
| 445 // Perform actual resolution or preconnection to subresources now. This is | 445 // Perform actual resolution or preconnection to subresources now. This is |
| 446 // an internal worker method that is reached via a post task from | 446 // an internal worker method that is reached via a post task from |
| 447 // PredictFrameSubresources(). | 447 // PredictFrameSubresources(). |
| 448 void PrepareFrameSubresources(const GURL& url, | 448 void PrepareFrameSubresources(const GURL& url, |
| 449 const GURL& first_party_for_cookies); | 449 const GURL& first_party_for_cookies); |
| 450 | 450 |
| 451 // Access method for use by async lookup request to pass resolution result. | 451 // Access method for use by async lookup request to pass resolution result. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 : Predictor(preconnect_enabled, predictor_enabled) {} | 606 : Predictor(preconnect_enabled, predictor_enabled) {} |
| 607 virtual ~SimplePredictor() {} | 607 virtual ~SimplePredictor() {} |
| 608 virtual void InitNetworkPredictor( | 608 virtual void InitNetworkPredictor( |
| 609 PrefService* user_prefs, | 609 PrefService* user_prefs, |
| 610 PrefService* local_state, | 610 PrefService* local_state, |
| 611 IOThread* io_thread, | 611 IOThread* io_thread, |
| 612 net::URLRequestContextGetter* getter, | 612 net::URLRequestContextGetter* getter, |
| 613 ProfileIOData* profile_io_data) OVERRIDE; | 613 ProfileIOData* profile_io_data) OVERRIDE; |
| 614 virtual void ShutdownOnUIThread() OVERRIDE; | 614 virtual void ShutdownOnUIThread() OVERRIDE; |
| 615 private: | 615 private: |
| 616 // There member functions return True for unittests. | 616 // These member functions return True for unittests. |
| 617 virtual bool CanPredictNetworkActionsUI() OVERRIDE; | 617 virtual bool CanPrefetchAndPrerender() const OVERRIDE; |
| 618 virtual bool CanPredictNetworkActionsIO() OVERRIDE; | 618 virtual bool CanPreresolveAndPreconnect() const OVERRIDE; |
| 619 }; | 619 }; |
| 620 | 620 |
| 621 } // namespace chrome_browser_net | 621 } // namespace chrome_browser_net |
| 622 | 622 |
| 623 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 623 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |