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

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

Issue 1881463003: Add a browsertest suite for net predictor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke@ review Created 4 years, 8 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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 typedef std::map<GURL, UrlInfo> Results; 68 typedef std::map<GURL, UrlInfo> Results;
69 69
70 // An observer for testing. 70 // An observer for testing.
71 class PredictorObserver { 71 class PredictorObserver {
72 public: 72 public:
73 virtual ~PredictorObserver() {} 73 virtual ~PredictorObserver() {}
74 74
75 virtual void OnPreconnectUrl(const GURL& original_url, 75 virtual void OnPreconnectUrl(const GURL& original_url,
76 const GURL& first_party_for_cookies, 76 const GURL& first_party_for_cookies,
77 UrlInfo::ResolutionMotivation motivation, 77 UrlInfo::ResolutionMotivation motivation,
78 int count) = 0; 78 int count) {}
79 virtual void OnLearnFromNavigation(const GURL& referring_url,
80 const GURL& target_url) {}
mmenke 2016/04/22 16:29:25 Pre-existing issue, but this file should forward d
Charlie Harrison 2016/04/28 16:29:51 Done.
79 }; 81 };
80 82
81 // Predictor is constructed during Profile construction (on the UI thread), 83 // Predictor is constructed during Profile construction (on the UI thread),
82 // but it is destroyed on the IO thread when ProfileIOData goes away. All of 84 // but it is destroyed on the IO thread when ProfileIOData goes away. All of
83 // its core state and functionality happens on the IO thread. The only UI 85 // its core state and functionality happens on the IO thread. The only UI
84 // methods are initialization / shutdown related (including preconnect 86 // methods are initialization / shutdown related (including preconnect
85 // initialization), or convenience methods that internally forward calls to 87 // initialization), or convenience methods that internally forward calls to
86 // the IO thread. 88 // the IO thread.
87 class Predictor { 89 class Predictor {
88 public: 90 public:
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 302 }
301 303
302 bool preconnect_enabled() const { 304 bool preconnect_enabled() const {
303 return preconnect_enabled_; 305 return preconnect_enabled_;
304 } 306 }
305 307
306 bool predictor_enabled() const { 308 bool predictor_enabled() const {
307 return predictor_enabled_; 309 return predictor_enabled_;
308 } 310 }
309 311
312 // Used only for testing.
mmenke 2016/04/22 16:29:24 Maybe add "Overrides command line flag to disable
313 void set_preconnect_enabled_for_test(bool preconnect_enabled) {
314 preconnect_enabled_ = preconnect_enabled;
315 }
310 316
311 private: 317 private:
312 FRIEND_TEST_ALL_PREFIXES(PredictorTest, BenefitLookupTest); 318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, BenefitLookupTest);
313 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest); 319 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest);
314 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest); 320 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest);
315 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest); 321 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest);
316 FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest); 322 FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest);
317 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); 323 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest);
318 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); 324 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest);
319 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); 325 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // The SSLConfigService we query SNI support from (used in querying HSTS 563 // The SSLConfigService we query SNI support from (used in querying HSTS
558 // redirects). 564 // redirects).
559 net::SSLConfigService* ssl_config_service_; 565 net::SSLConfigService* ssl_config_service_;
560 566
561 // The ProxyService, used to determine whether preresolve is useful. 567 // The ProxyService, used to determine whether preresolve is useful.
562 net::ProxyService* proxy_service_; 568 net::ProxyService* proxy_service_;
563 569
564 // Are we currently using preconnection, rather than just DNS resolution, for 570 // Are we currently using preconnection, rather than just DNS resolution, for
565 // subresources and omni-box search URLs. 571 // subresources and omni-box search URLs.
566 // This is false if and only if disabled by a command line switch. 572 // This is false if and only if disabled by a command line switch.
567 const bool preconnect_enabled_; 573 bool preconnect_enabled_;
568 574
569 // Most recent suggestion from Omnibox provided via AnticipateOmniboxUrl(). 575 // Most recent suggestion from Omnibox provided via AnticipateOmniboxUrl().
570 std::string last_omnibox_host_; 576 std::string last_omnibox_host_;
571 577
572 // The time when the last preresolve was done for last_omnibox_host_. 578 // The time when the last preresolve was done for last_omnibox_host_.
573 base::TimeTicks last_omnibox_preresolve_; 579 base::TimeTicks last_omnibox_preresolve_;
574 580
575 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested 581 // The number of consecutive requests to AnticipateOmniboxUrl() that suggested
576 // preconnecting (because it was to a search service). 582 // preconnecting (because it was to a search service).
577 int consecutive_omnibox_preconnect_count_; 583 int consecutive_omnibox_preconnect_count_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 620
615 private: 621 private:
616 // These member functions return True for unittests. 622 // These member functions return True for unittests.
617 bool CanPrefetchAndPrerender() const override; 623 bool CanPrefetchAndPrerender() const override;
618 bool CanPreresolveAndPreconnect() const override; 624 bool CanPreresolveAndPreconnect() const override;
619 }; 625 };
620 626
621 } // namespace chrome_browser_net 627 } // namespace chrome_browser_net
622 628
623 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ 629 #endif // CHROME_BROWSER_NET_PREDICTOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/predictor.cc » ('j') | chrome/browser/net/predictor_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698