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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_
6 #define CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/net/timed_cache.h"
18 namespace chrome_browser_net
{
22 //------------------------------------------------------------------------------
23 // An interceptor to monitor URLRequests so that we can do speculative DNS
24 // resolution and/or speculative TCP preconnections.
25 class ConnectInterceptor
{
27 // Construction includes registration as an URL.
28 explicit ConnectInterceptor(Predictor
* predictor
);
29 // Destruction includes unregistering.
30 virtual ~ConnectInterceptor();
32 // Learn about referrers, and optionally preconnect based on history.
33 void WitnessURLRequest(net::URLRequest
* request
);
36 // Provide access to local class TimedCache for testing.
37 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest
, TimedCacheRecall
);
38 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest
, TimedCacheEviction
);
40 TimedCache timed_cache_
;
41 Predictor
* const predictor_
;
43 DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor
);
46 } // namespace chrome_browser_net
48 #endif // CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_