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

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

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years 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 | Annotate | Revision Log
OLDNEW
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/time.h" 11 #include "base/time.h"
11 #include "net/url_request/url_request_job_factory.h" 12
13 class GURL;
14
15 namespace net {
16 class URLRequest;
17 }
12 18
13 namespace chrome_browser_net { 19 namespace chrome_browser_net {
14 20
15 class Predictor; 21 class Predictor;
16 22
17 //------------------------------------------------------------------------------ 23 //------------------------------------------------------------------------------
18 // An interceptor to monitor URLRequests so that we can do speculative DNS 24 // An interceptor to monitor URLRequests so that we can do speculative DNS
19 // resolution and/or speculative TCP preconnections. 25 // resolution and/or speculative TCP preconnections.
20 class ConnectInterceptor : public net::URLRequestJobFactory::Interceptor { 26 class ConnectInterceptor {
21 public: 27 public:
22 // Construction includes registration as an URL. 28 // Construction includes registration as an URL.
23 explicit ConnectInterceptor(Predictor* predictor); 29 explicit ConnectInterceptor(Predictor* predictor);
24 // Destruction includes unregistering. 30 // Destruction includes unregistering.
25 virtual ~ConnectInterceptor(); 31 virtual ~ConnectInterceptor();
26 32
27 protected:
28 // Overridden from net::URLRequest::Interceptor:
29 // Learn about referrers, and optionally preconnect based on history. 33 // Learn about referrers, and optionally preconnect based on history.
30 virtual net::URLRequestJob* MaybeIntercept( 34 void WitnessURLRequest(net::URLRequest* request) const;
31 net::URLRequest* request,
32 net::NetworkDelegate* network_delegate) const OVERRIDE;
33 virtual net::URLRequestJob* MaybeInterceptResponse(
34 net::URLRequest* request,
35 net::NetworkDelegate* network_delegate) const OVERRIDE;
36 virtual net::URLRequestJob* MaybeInterceptRedirect(
37 const GURL& location,
38 net::URLRequest* request,
39 net::NetworkDelegate* network_delegate) const OVERRIDE;
40 35
41 private: 36 private:
42 // Provide access to local class TimedCache for testing. 37 // Provide access to local class TimedCache for testing.
43 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheRecall); 38 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheRecall);
44 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheEviction); 39 FRIEND_TEST_ALL_PREFIXES(ConnectInterceptorTest, TimedCacheEviction);
45 40
46 // Define a LRU cache that recalls all navigations within the last N seconds. 41 // Define a LRU cache that recalls all navigations within the last N seconds.
47 // When we learn about subresources to possibly preconnect to, it would be a 42 // When we learn about subresources to possibly preconnect to, it would be a
48 // waste to preconnect when the original navigation was too long ago. Any 43 // waste to preconnect when the original navigation was too long ago. Any
49 // connected, but unused TCP/IP connection, will generally be reset by the 44 // connected, but unused TCP/IP connection, will generally be reset by the
(...skipping 27 matching lines...) Expand all
77 }; 72 };
78 TimedCache timed_cache_; 73 TimedCache timed_cache_;
79 Predictor* const predictor_; 74 Predictor* const predictor_;
80 75
81 DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor); 76 DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor);
82 }; 77 };
83 78
84 } // namespace chrome_browser_net 79 } // namespace chrome_browser_net
85 80
86 #endif // CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_ 81 #endif // CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | chrome/browser/net/connect_interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698