OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ | 5 #ifndef CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ |
6 #define CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ | 6 #define CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/mru_cache.h" | 9 #include "base/memory/mru_cache.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 public: | 21 public: |
22 // Construction includes registration as an URL. | 22 // Construction includes registration as an URL. |
23 explicit ConnectInterceptor(Predictor* predictor); | 23 explicit ConnectInterceptor(Predictor* predictor); |
24 // Destruction includes unregistering. | 24 // Destruction includes unregistering. |
25 virtual ~ConnectInterceptor(); | 25 virtual ~ConnectInterceptor(); |
26 | 26 |
27 protected: | 27 protected: |
28 // Overridden from net::URLRequest::Interceptor: | 28 // Overridden from net::URLRequest::Interceptor: |
29 // Learn about referrers, and optionally preconnect based on history. | 29 // Learn about referrers, and optionally preconnect based on history. |
30 virtual net::URLRequestJob* MaybeIntercept( | 30 virtual net::URLRequestJob* MaybeIntercept( |
31 net::URLRequest* request) const OVERRIDE; | 31 net::URLRequest* request, |
| 32 net::NetworkDelegate* network_delegate) const OVERRIDE; |
32 virtual net::URLRequestJob* MaybeInterceptResponse( | 33 virtual net::URLRequestJob* MaybeInterceptResponse( |
33 net::URLRequest* request) const OVERRIDE; | 34 net::URLRequest* request, |
| 35 net::NetworkDelegate* network_delegate) const OVERRIDE; |
34 virtual net::URLRequestJob* MaybeInterceptRedirect( | 36 virtual net::URLRequestJob* MaybeInterceptRedirect( |
35 const GURL& location, net::URLRequest* request) const OVERRIDE; | 37 const GURL& location, |
| 38 net::URLRequest* request, |
| 39 net::NetworkDelegate* network_delegate) const OVERRIDE; |
36 | 40 |
37 private: | 41 private: |
38 // Provide access to local class TimedCache for testing. | 42 // Provide access to local class TimedCache for testing. |
39 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheRecall); | 43 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheRecall); |
40 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheEviction); | 44 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheEviction); |
41 | 45 |
42 // Define a LRU cache that recalls all navigations within the last N seconds. | 46 // Define a LRU cache that recalls all navigations within the last N seconds. |
43 // When we learn about subresources to possibly preconnect to, it would be a | 47 // When we learn about subresources to possibly preconnect to, it would be a |
44 // waste to preconnect when the original navigation was too long ago. Any | 48 // waste to preconnect when the original navigation was too long ago. Any |
45 // connected, but unused TCP/IP connection, will generally be reset by the | 49 // connected, but unused TCP/IP connection, will generally be reset by the |
(...skipping 27 matching lines...) Expand all Loading... |
73 }; | 77 }; |
74 TimedCache timed_cache_; | 78 TimedCache timed_cache_; |
75 Predictor* const predictor_; | 79 Predictor* const predictor_; |
76 | 80 |
77 DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor); | 81 DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor); |
78 }; | 82 }; |
79 | 83 |
80 } // namespace chrome_browser_net | 84 } // namespace chrome_browser_net |
81 | 85 |
82 #endif // CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ | 86 #endif // CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ |
OLD | NEW |