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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 | 310 |
311 // Used only for testing. Overrides command line flag to disable preconnect, | 311 // Used only for testing. Overrides command line flag to disable preconnect, |
312 // which is added in the browser test fixture. | 312 // which is added in the browser test fixture. |
313 void SetPreconnectEnabledForTest(bool preconnect_enabled); | 313 void SetPreconnectEnabledForTest(bool preconnect_enabled); |
314 | 314 |
315 net::URLRequestContextGetter* url_request_context_getter_for_test() { | 315 net::URLRequestContextGetter* url_request_context_getter_for_test() { |
316 return url_request_context_getter_.get(); | 316 return url_request_context_getter_.get(); |
317 } | 317 } |
318 | 318 |
319 private: | 319 private: |
320 FRIEND_TEST_ALL_PREFIXES(PredictorTest, BenefitLookupTest); | 320 FRIEND_TEST_ALL_PREFIXES(PredictorBrowserTest, |
321 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest); | 321 ShutdownWhenResolutionIsPendingTest); |
322 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest); | 322 FRIEND_TEST_ALL_PREFIXES(PredictorBrowserTest, SingleLookupTest); |
323 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest); | 323 FRIEND_TEST_ALL_PREFIXES(PredictorBrowserTest, ConcurrentLookupTest); |
324 FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest); | 324 FRIEND_TEST_ALL_PREFIXES(PredictorBrowserTest, MassiveConcurrentLookupTest); |
325 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); | 325 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); |
326 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); | 326 FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); |
327 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); | 327 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ReferrerSerializationTrimTest); |
328 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor); | 328 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithDisabledAdvisor); |
329 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor); | 329 FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTestWithEnabledAdvisor); |
330 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor); | 330 FRIEND_TEST_ALL_PREFIXES(PredictorTest, TestSimplePreconnectAdvisor); |
331 FRIEND_TEST_ALL_PREFIXES(PredictorTest, NoProxyService); | 331 FRIEND_TEST_ALL_PREFIXES(PredictorTest, NoProxyService); |
332 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyEnabled); | 332 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyEnabled); |
333 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyNotEnabled); | 333 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyDefinitelyNotEnabled); |
334 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyMaybeEnabled); | 334 FRIEND_TEST_ALL_PREFIXES(PredictorTest, ProxyMaybeEnabled); |
335 friend class WaitForResolutionHelper; // For testing. | 335 friend class WaitForResolutionHelper; // For testing. |
336 friend class PredictorBrowserTest; | |
Randy Smith (Not in Mondays)
2016/05/23 19:55:18
Usually there's a way, if you friend the test fixt
Charlie Harrison
2016/05/24 16:57:06
Yeah I'll do that.
| |
336 | 337 |
337 class LookupRequest; | 338 class LookupRequest; |
338 | 339 |
339 // A simple priority queue for handling host names. | 340 // A simple priority queue for handling host names. |
340 // Some names that are queued up have |motivation| that requires very rapid | 341 // Some names that are queued up have |motivation| that requires very rapid |
341 // handling. For example, a sub-resource name lookup MUST be done before the | 342 // handling. For example, a sub-resource name lookup MUST be done before the |
342 // actual sub-resource is fetched. In contrast, a name that was speculatively | 343 // actual sub-resource is fetched. In contrast, a name that was speculatively |
343 // noted in a page has to be resolved before the user "gets around to" | 344 // noted in a page has to be resolved before the user "gets around to" |
344 // clicking on a link. By tagging (with a motivation) each push we make into | 345 // clicking on a link. By tagging (with a motivation) each push we make into |
345 // this FIFO queue, the queue can re-order the more important names to service | 346 // this FIFO queue, the queue can re-order the more important names to service |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 | 627 |
627 private: | 628 private: |
628 // These member functions return True for unittests. | 629 // These member functions return True for unittests. |
629 bool CanPrefetchAndPrerender() const override; | 630 bool CanPrefetchAndPrerender() const override; |
630 bool CanPreresolveAndPreconnect() const override; | 631 bool CanPreresolveAndPreconnect() const override; |
631 }; | 632 }; |
632 | 633 |
633 } // namespace chrome_browser_net | 634 } // namespace chrome_browser_net |
634 | 635 |
635 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ | 636 #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |
OLD | NEW |