| 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/containers/mru_cache.h" | 8 #include "base/containers/mru_cache.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class ConnectInterceptor { | 26 class ConnectInterceptor { |
| 27 public: | 27 public: |
| 28 // Construction includes registration as an URL. | 28 // Construction includes registration as an URL. |
| 29 explicit ConnectInterceptor(Predictor* predictor); | 29 explicit ConnectInterceptor(Predictor* predictor); |
| 30 // Destruction includes unregistering. | 30 // Destruction includes unregistering. |
| 31 virtual ~ConnectInterceptor(); | 31 virtual ~ConnectInterceptor(); |
| 32 | 32 |
| 33 // Learn about referrers, and optionally preconnect based on history. | 33 // Learn about referrers, and optionally preconnect based on history. |
| 34 void WitnessURLRequest(net::URLRequest* request) const; | 34 void WitnessURLRequest(net::URLRequest* request) const; |
| 35 | 35 |
| 36 void WitnessPreconnect(const GURL& url); |
| 37 |
| 36 private: | 38 private: |
| 37 // Provide access to local class TimedCache for testing. | 39 // Provide access to local class TimedCache for testing. |
| 38 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheRecall); | 40 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheRecall); |
| 39 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheEviction); | 41 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheEviction); |
| 40 | 42 |
| 41 // Define a LRU cache that recalls all navigations within the last N seconds. | 43 // Define a LRU cache that recalls all navigations within the last N seconds. |
| 42 // When we learn about subresources to possibly preconnect to, it would be a | 44 // When we learn about subresources to possibly preconnect to, it would be a |
| 43 // waste to preconnect when the original navigation was too long ago. Any | 45 // waste to preconnect when the original navigation was too long ago. Any |
| 44 // connected, but unused TCP/IP connection, will generally be reset by the | 46 // connected, but unused TCP/IP connection, will generally be reset by the |
| 45 // server if it is not used quickly (i.e., GET or POST is sent). | 47 // server if it is not used quickly (i.e., GET or POST is sent). |
| (...skipping 18 matching lines...) Expand all Loading... |
| 64 // URLRequestJob functions. It is mutable because it tracks the urls and | 66 // URLRequestJob functions. It is mutable because it tracks the urls and |
| 65 // caches them. | 67 // caches them. |
| 66 mutable UrlMruTimedCache mru_cache_; | 68 mutable UrlMruTimedCache mru_cache_; |
| 67 | 69 |
| 68 // The longest time an entry can persist in the cache, and still be found. | 70 // The longest time an entry can persist in the cache, and still be found. |
| 69 const base::TimeDelta max_duration_; | 71 const base::TimeDelta max_duration_; |
| 70 | 72 |
| 71 DISALLOW_COPY_AND_ASSIGN(TimedCache); | 73 DISALLOW_COPY_AND_ASSIGN(TimedCache); |
| 72 }; | 74 }; |
| 73 TimedCache timed_cache_; | 75 TimedCache timed_cache_; |
| 76 TimedCache recent_preconnects_; |
| 74 Predictor* const predictor_; | 77 Predictor* const predictor_; |
| 75 | 78 |
| 76 DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor); | 79 DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor); |
| 77 }; | 80 }; |
| 78 | 81 |
| 79 } // namespace chrome_browser_net | 82 } // namespace chrome_browser_net |
| 80 | 83 |
| 81 #endif // CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ | 84 #endif // CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ |
| OLD | NEW |