| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool preconnect_enabled() const { | 302 bool preconnect_enabled() const { |
| 303 return preconnect_enabled_; | 303 return preconnect_enabled_; |
| 304 } | 304 } |
| 305 | 305 |
| 306 bool predictor_enabled() const { | 306 bool predictor_enabled() const { |
| 307 return predictor_enabled_; | 307 return predictor_enabled_; |
| 308 } | 308 } |
| 309 | 309 |
| 310 TimedCache* timed_cache() { return timed_cache_.get(); } |
| 310 | 311 |
| 311 private: | 312 private: |
| 312 FRIEND_TEST_ALL_PREFIXES(PredictorTest, BenefitLookupTest); | 313 FRIEND_TEST_ALL_PREFIXES(PredictorTest, BenefitLookupTest); |
| 313 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest); | 314 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest); |
| 314 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest); | 315 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest); |
| 315 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest); | 316 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest); |
| 316 FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest); | 317 FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest); |
| 317 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); | 318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); |
| 318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); | 319 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); |
| 319 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); | 320 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // List of URLs in referrers_ currently being trimmed (scaled down to | 589 // List of URLs in referrers_ currently being trimmed (scaled down to |
| 589 // eventually be aged out of use). | 590 // eventually be aged out of use). |
| 590 std::vector<GURL> urls_being_trimmed_; | 591 std::vector<GURL> urls_being_trimmed_; |
| 591 | 592 |
| 592 // A time after which we need to do more trimming of referrers. | 593 // A time after which we need to do more trimming of referrers. |
| 593 base::TimeTicks next_trim_time_; | 594 base::TimeTicks next_trim_time_; |
| 594 | 595 |
| 595 // An observer for testing. | 596 // An observer for testing. |
| 596 PredictorObserver* observer_; | 597 PredictorObserver* observer_; |
| 597 | 598 |
| 599 std::unique_ptr<TimedCache> timed_cache_; |
| 600 |
| 598 scoped_ptr<base::WeakPtrFactory<Predictor> > weak_factory_; | 601 scoped_ptr<base::WeakPtrFactory<Predictor> > weak_factory_; |
| 599 | 602 |
| 600 DISALLOW_COPY_AND_ASSIGN(Predictor); | 603 DISALLOW_COPY_AND_ASSIGN(Predictor); |
| 601 }; | 604 }; |
| 602 | 605 |
| 603 // This version of the predictor is used for testing. | 606 // This version of the predictor is used for testing. |
| 604 class SimplePredictor : public Predictor { | 607 class SimplePredictor : public Predictor { |
| 605 public: | 608 public: |
| 606 explicit SimplePredictor(bool preconnect_enabled, bool predictor_enabled) | 609 explicit SimplePredictor(bool preconnect_enabled, bool predictor_enabled) |
| 607 : Predictor(preconnect_enabled, predictor_enabled) {} | 610 : Predictor(preconnect_enabled, predictor_enabled) {} |
| 608 ~SimplePredictor() override {} | 611 ~SimplePredictor() override {} |
| 609 void InitNetworkPredictor(PrefService* user_prefs, | 612 void InitNetworkPredictor(PrefService* user_prefs, |
| 610 IOThread* io_thread, | 613 IOThread* io_thread, |
| 611 net::URLRequestContextGetter* getter, | 614 net::URLRequestContextGetter* getter, |
| 612 ProfileIOData* profile_io_data) override; | 615 ProfileIOData* profile_io_data) override; |
| 613 void ShutdownOnUIThread() override; | 616 void ShutdownOnUIThread() override; |
| 614 | 617 |
| 615 private: | 618 private: |
| 616 // These member functions return True for unittests. | 619 // These member functions return True for unittests. |
| 617 bool CanPrefetchAndPrerender() const override; | 620 bool CanPrefetchAndPrerender() const override; |
| 618 bool CanPreresolveAndPreconnect() const override; | 621 bool CanPreresolveAndPreconnect() const override; |
| 619 }; | 622 }; |
| 620 | 623 |
| 621 } // namespace chrome_browser_net | 624 } // namespace chrome_browser_net |
| 622 | 625 |
| 623 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 626 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
| OLD | NEW |