Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/net/predictor.h

Issue 1857383002: Refactor net predictor to use ResourceThrottles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on #396550 Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/net/connect_interceptor.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 bool PreconnectEnabled() const; 311 bool PreconnectEnabled() const;
312 312
313 // Used only for testing. Overrides command line flag to disable preconnect, 313 // Used only for testing. Overrides command line flag to disable preconnect,
314 // which is added in the browser test fixture. 314 // which is added in the browser test fixture.
315 void SetPreconnectEnabledForTest(bool preconnect_enabled); 315 void SetPreconnectEnabledForTest(bool preconnect_enabled);
316 316
317 net::URLRequestContextGetter* url_request_context_getter_for_test() { 317 net::URLRequestContextGetter* url_request_context_getter_for_test() {
318 return url_request_context_getter_.get(); 318 return url_request_context_getter_.get();
319 } 319 }
320 320
321 TimedCache* timed_cache() { return timed_cache_.get(); }
322
321 private: 323 private:
322 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); 324 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest);
323 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); 325 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest);
324 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); 326 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest);
325 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor); 327 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor);
326 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor); 328 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor);
327 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor); 329 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor);
328 FRIEND_TEST_ALL_PREFIXES(PredictorTest, NoProxyService); 330 FRIEND_TEST_ALL_PREFIXES(PredictorTest, NoProxyService);
329 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyEnabled); 331 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyEnabled);
330 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyNotEnabled); 332 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyNotEnabled);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // List of URLs in referrers_ currently being trimmed (scaled down to 578 // List of URLs in referrers_ currently being trimmed (scaled down to
577 // eventually be aged out of use). 579 // eventually be aged out of use).
578 std::vector<GURL> urls_being_trimmed_; 580 std::vector<GURL> urls_being_trimmed_;
579 581
580 // A time after which we need to do more trimming of referrers. 582 // A time after which we need to do more trimming of referrers.
581 base::TimeTicks next_trim_time_; 583 base::TimeTicks next_trim_time_;
582 584
583 // An observer for testing. 585 // An observer for testing.
584 PredictorObserver* observer_; 586 PredictorObserver* observer_;
585 587
588 std::unique_ptr<TimedCache> timed_cache_;
589
586 std::unique_ptr<base::WeakPtrFactory<Predictor>> weak_factory_; 590 std::unique_ptr<base::WeakPtrFactory<Predictor>> weak_factory_;
587 591
588 // Protects |preconnect_enabled_|. 592 // Protects |preconnect_enabled_|.
589 mutable base::Lock preconnect_enabled_lock_; 593 mutable base::Lock preconnect_enabled_lock_;
590 594
591 DISALLOW_COPY_AND_ASSIGN(Predictor); 595 DISALLOW_COPY_AND_ASSIGN(Predictor);
592 }; 596 };
593 597
594 // This version of the predictor is used for testing. 598 // This version of the predictor is used for testing.
595 class SimplePredictor : public Predictor { 599 class SimplePredictor : public Predictor {
596 public: 600 public:
597 explicit SimplePredictor(bool preconnect_enabled, bool predictor_enabled) 601 explicit SimplePredictor(bool preconnect_enabled, bool predictor_enabled)
598 : Predictor(preconnect_enabled, predictor_enabled) {} 602 : Predictor(preconnect_enabled, predictor_enabled) {}
599 ~SimplePredictor() override {} 603 ~SimplePredictor() override {}
600 void InitNetworkPredictor(PrefService* user_prefs, 604 void InitNetworkPredictor(PrefService* user_prefs,
601 IOThread* io_thread, 605 IOThread* io_thread,
602 net::URLRequestContextGetter* getter, 606 net::URLRequestContextGetter* getter,
603 ProfileIOData* profile_io_data) override; 607 ProfileIOData* profile_io_data) override;
604 void ShutdownOnUIThread() override; 608 void ShutdownOnUIThread() override;
605 609
606 private: 610 private:
607 // These member functions return True for unittests. 611 // These member functions return True for unittests.
608 bool CanPrefetchAndPrerender() const override; 612 bool CanPrefetchAndPrerender() const override;
609 bool CanPreresolveAndPreconnect() const override; 613 bool CanPreresolveAndPreconnect() const override;
610 }; 614 };
611 615
612 } // namespace chrome_browser_net 616 } // namespace chrome_browser_net
613 617
614 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ 618 #endif // CHROME_BROWSER_NET_PREDICTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/connect_interceptor.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698