summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/connect_interceptor.h
diff options
context:
space:
mode:
authorrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-10 01:30:46 +0000
committerrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-10 01:30:46 +0000
commit67372ecfa788fa29193f94029f9eccac2c08af0f (patch)
treee99301edd0e3b874600d3fbcdede208e35adcbdb /chrome/browser/net/connect_interceptor.h
parent29adff69903acfae6aca00ba41b185d143f57f35 (diff)
downloadchromium_src-67372ecfa788fa29193f94029f9eccac2c08af0f.zip
chromium_src-67372ecfa788fa29193f94029f9eccac2c08af0f.tar.gz
chromium_src-67372ecfa788fa29193f94029f9eccac2c08af0f.tar.bz2
Modifying prefetch to account for multi-profile.
Items of note: - predictor_api is gone. Most functions in predictor_api.cc have moved into the chrome_browser_net::Predictor class or the Profile class. - The predictor state is cleaned up in the Profile dtor. - Predictor is owned by the ProfileIOData of the profile. - InitialObserver class is gone since each profile keeps their own info, the non-OTR don't care if anyone is OTR. - Predictor is created by the profile and then passed to the ProfileIOData. Then its initialization is finished on the IOThread. - ConnectInterceptor now subclasses off of UrlRequestJobFactory::Interceptor. - Updated Profile to create a SimpleShutdownPredictor with limited functionality when in unittests. BUG=89937,90114 TEST=passes existing Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=97446 Review URL: http://codereview.chromium.org/7467012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/connect_interceptor.h')
-rw-r--r--chrome/browser/net/connect_interceptor.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/chrome/browser/net/connect_interceptor.h b/chrome/browser/net/connect_interceptor.h
index eca1c17..657700e 100644
--- a/chrome/browser/net/connect_interceptor.h
+++ b/chrome/browser/net/connect_interceptor.h
@@ -6,30 +6,34 @@
#define CHROME_BROWSER_NET_CONNECT_INTERCEPTOR_H_
#pragma once
-#include "net/url_request/url_request.h"
-
#include "base/gtest_prod_util.h"
#include "base/memory/mru_cache.h"
+#include "base/time.h"
+#include "net/url_request/url_request_job_factory.h"
namespace chrome_browser_net {
+class Predictor;
+
//------------------------------------------------------------------------------
// An interceptor to monitor URLRequests so that we can do speculative DNS
// resolution and/or speculative TCP preconnections.
-class ConnectInterceptor : public net::URLRequest::Interceptor {
+class ConnectInterceptor : public net::URLRequestJobFactory::Interceptor {
public:
// Construction includes registration as an URL.
- ConnectInterceptor();
+ explicit ConnectInterceptor(Predictor* predictor);
// Destruction includes unregistering.
virtual ~ConnectInterceptor();
protected:
// Overridden from net::URLRequest::Interceptor:
// Learn about referrers, and optionally preconnect based on history.
- virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request);
- virtual net::URLRequestJob* MaybeInterceptResponse(net::URLRequest* request);
- virtual net::URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request,
- const GURL& location);
+ virtual net::URLRequestJob* MaybeIntercept(
+ net::URLRequest* request) const OVERRIDE;
+ virtual net::URLRequestJob* MaybeInterceptResponse(
+ net::URLRequest* request) const OVERRIDE;
+ virtual net::URLRequestJob* MaybeInterceptRedirect(
+ const GURL& location, net::URLRequest* request) const OVERRIDE;
private:
// Provide access to local class TimedCache for testing.
@@ -48,17 +52,20 @@ class ConnectInterceptor : public net::URLRequest::Interceptor {
// Evicts any entries that have been in the FIFO "too long," and then checks
// to see if the given url is (still) in the FIFO cache.
- bool WasRecentlySeen(const GURL& url);
+ bool WasRecentlySeen(const GURL& url) const;
// Adds the given url to the cache, where it will remain for max_duration_.
- void SetRecentlySeen(const GURL& url);
+ void SetRecentlySeen(const GURL& url) const;
private:
// Our cache will be keyed on a URL (actually, just a scheme/host/port).
// We will always track the time it was last added to the FIFO cache by
// remembering a TimeTicks value.
typedef base::MRUCache<GURL, base::TimeTicks> UrlMruTimedCache;
- UrlMruTimedCache mru_cache_;
+ // mru_cache_ has to be mutable in order to be accessed from the overriden
+ // URLRequestJob functions. It is mutable because it tracks the urls and
+ // caches them.
+ mutable UrlMruTimedCache mru_cache_;
// The longest time an entry can persist in the cache, and still be found.
const base::TimeDelta max_duration_;
@@ -66,6 +73,7 @@ class ConnectInterceptor : public net::URLRequest::Interceptor {
DISALLOW_COPY_AND_ASSIGN(TimedCache);
};
TimedCache timed_cache_;
+ Predictor* const predictor_;
DISALLOW_COPY_AND_ASSIGN(ConnectInterceptor);
};