| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 bool PredictorEnabled() const; | 299 bool PredictorEnabled() const; |
| 300 | 300 |
| 301 // Used only for testing. Overrides command line flag to disable the | 301 // Used only for testing. Overrides command line flag to disable the |
| 302 // predictor, which is added in the browser test fixture. | 302 // predictor, which is added in the browser test fixture. |
| 303 void SetPredictorEnabledForTest(bool predictor_enabled); | 303 void SetPredictorEnabledForTest(bool predictor_enabled); |
| 304 | 304 |
| 305 net::URLRequestContextGetter* url_request_context_getter_for_test() { | 305 net::URLRequestContextGetter* url_request_context_getter_for_test() { |
| 306 return url_request_context_getter_.get(); | 306 return url_request_context_getter_.get(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 TimedCache* timed_cache() { return timed_cache_.get(); } | |
| 310 | |
| 311 private: | 309 private: |
| 312 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); | 310 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); |
| 313 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); | 311 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); |
| 314 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); | 312 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); |
| 315 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor); | 313 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor); |
| 316 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor); | 314 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor); |
| 317 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor); | 315 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor); |
| 318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, NoProxyService); | 316 FRIEND_TEST_ALL_PREFIXES(PredictorTest, NoProxyService); |
| 319 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyEnabled); | 317 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyEnabled); |
| 320 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyNotEnabled); | 318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyNotEnabled); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 518 |
| 521 // For each URL that we might navigate to (that we've "learned about") | 519 // For each URL that we might navigate to (that we've "learned about") |
| 522 // we have a Referrer list. Each Referrer list has all hostnames we might | 520 // we have a Referrer list. Each Referrer list has all hostnames we might |
| 523 // need to pre-resolve or pre-connect to when there is a navigation to the | 521 // need to pre-resolve or pre-connect to when there is a navigation to the |
| 524 // orginial hostname. | 522 // orginial hostname. |
| 525 Referrers referrers_; | 523 Referrers referrers_; |
| 526 | 524 |
| 527 // An observer for testing. | 525 // An observer for testing. |
| 528 PredictorObserver* observer_; | 526 PredictorObserver* observer_; |
| 529 | 527 |
| 530 std::unique_ptr<TimedCache> timed_cache_; | |
| 531 | |
| 532 // TODO(csharrison): It is not great that two weak pointer factories are | 528 // TODO(csharrison): It is not great that two weak pointer factories are |
| 533 // needed in this class. Let's split it into two classes that live on each | 529 // needed in this class. Let's split it into two classes that live on each |
| 534 // thread. | 530 // thread. |
| 535 // | 531 // |
| 536 // Weak factory for weak pointers that should be dereferenced on the IO | 532 // Weak factory for weak pointers that should be dereferenced on the IO |
| 537 // thread. | 533 // thread. |
| 538 std::unique_ptr<base::WeakPtrFactory<Predictor>> io_weak_factory_; | 534 std::unique_ptr<base::WeakPtrFactory<Predictor>> io_weak_factory_; |
| 539 | 535 |
| 540 // Weak factory for weak pointers that should be dereferenced on the UI | 536 // Weak factory for weak pointers that should be dereferenced on the UI |
| 541 // thread. | 537 // thread. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 561 | 557 |
| 562 private: | 558 private: |
| 563 // These member functions return True for unittests. | 559 // These member functions return True for unittests. |
| 564 bool CanPrefetchAndPrerender() const override; | 560 bool CanPrefetchAndPrerender() const override; |
| 565 bool CanPreresolveAndPreconnect() const override; | 561 bool CanPreresolveAndPreconnect() const override; |
| 566 }; | 562 }; |
| 567 | 563 |
| 568 } // namespace chrome_browser_net | 564 } // namespace chrome_browser_net |
| 569 | 565 |
| 570 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 566 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |