summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/connect_interceptor.cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-19 15:44:32 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-19 15:44:32 +0000
commit9f07c9b7b32e68112ddca7968230e08293c2809c (patch)
treea64f95ff80431c05de959f93e4f46738dded21d4 /chrome/browser/net/connect_interceptor.cc
parentf334f8d30107123ed660c88d9271ed1404b96785 (diff)
downloadchromium_src-9f07c9b7b32e68112ddca7968230e08293c2809c.zip
chromium_src-9f07c9b7b32e68112ddca7968230e08293c2809c.tar.gz
chromium_src-9f07c9b7b32e68112ddca7968230e08293c2809c.tar.bz2
Revert 97446 - 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 TEST=passes existing Review URL: http://codereview.chromium.org/7467012 TBR=rlp@chromium.org Review URL: http://codereview.chromium.org/7690006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97465 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/connect_interceptor.cc')
-rw-r--r--chrome/browser/net/connect_interceptor.cc33
1 files changed, 15 insertions, 18 deletions
diff --git a/chrome/browser/net/connect_interceptor.cc b/chrome/browser/net/connect_interceptor.cc
index 0ea6dbd..5938df2 100644
--- a/chrome/browser/net/connect_interceptor.cc
+++ b/chrome/browser/net/connect_interceptor.cc
@@ -4,9 +4,8 @@
#include "chrome/browser/net/connect_interceptor.h"
-#include "chrome/browser/net/predictor.h"
+#include "chrome/browser/net/predictor_api.h"
#include "net/base/load_flags.h"
-#include "net/url_request/url_request.h"
namespace chrome_browser_net {
@@ -17,24 +16,24 @@ namespace chrome_browser_net {
// TODO(jar): We should do a persistent field trial to validate/optimize this.
static const int kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10;
-ConnectInterceptor::ConnectInterceptor(Predictor* predictor)
+ConnectInterceptor::ConnectInterceptor()
: timed_cache_(base::TimeDelta::FromSeconds(
- kMaxUnusedSocketLifetimeSecondsWithoutAGet)),
- predictor_(predictor) {
- DCHECK(predictor);
+ kMaxUnusedSocketLifetimeSecondsWithoutAGet)) {
+ net::URLRequest::Deprecated::RegisterRequestInterceptor(this);
}
ConnectInterceptor::~ConnectInterceptor() {
+ net::URLRequest::Deprecated::UnregisterRequestInterceptor(this);
}
net::URLRequestJob* ConnectInterceptor::MaybeIntercept(
- net::URLRequest* request) const {
+ net::URLRequest* request) {
GURL request_scheme_host(Predictor::CanonicalizeUrl(request->url()));
if (request_scheme_host == GURL::EmptyGURL())
return NULL;
// Learn what URLs are likely to be needed during next startup.
- predictor_->LearnAboutInitialNavigation(request_scheme_host);
+ LearnAboutInitialNavigation(request_scheme_host);
bool redirected_host = false;
if (request->referrer().empty()) {
@@ -56,8 +55,7 @@ net::URLRequestJob* ConnectInterceptor::MaybeIntercept(
if (request->original_url().path().length() <= 1 &&
timed_cache_.WasRecentlySeen(original_scheme_host)) {
// TODO(jar): These definite redirects could be learned much faster.
- predictor_->LearnFromNavigation(original_scheme_host,
- request_scheme_host);
+ LearnFromNavigation(original_scheme_host, request_scheme_host);
}
}
}
@@ -66,8 +64,7 @@ net::URLRequestJob* ConnectInterceptor::MaybeIntercept(
bool is_subresource = !(request->load_flags() & net::LOAD_MAIN_FRAME);
// Learn about our referring URL, for use in the future.
if (is_subresource && timed_cache_.WasRecentlySeen(referring_scheme_host))
- predictor_->LearnFromNavigation(referring_scheme_host,
- request_scheme_host);
+ LearnFromNavigation(referring_scheme_host, request_scheme_host);
if (referring_scheme_host == request_scheme_host) {
// We've already made any/all predictions when we navigated to the
// referring host, so we can bail out here.
@@ -83,18 +80,18 @@ net::URLRequestJob* ConnectInterceptor::MaybeIntercept(
// main frame request - way back in RenderViewHost::Navigate. So only handle
// predictions now for subresources or for redirected hosts.
if ((request->load_flags() & net::LOAD_SUB_FRAME) || redirected_host)
- predictor_->PredictFrameSubresources(request_scheme_host);
+ PredictFrameSubresources(request_scheme_host);
return NULL;
}
net::URLRequestJob* ConnectInterceptor::MaybeInterceptResponse(
- net::URLRequest* request) const {
+ net::URLRequest* request) {
return NULL;
}
net::URLRequestJob* ConnectInterceptor::MaybeInterceptRedirect(
- const GURL& location,
- net::URLRequest* request) const {
+ net::URLRequest* request,
+ const GURL& location) {
return NULL;
}
@@ -106,7 +103,7 @@ ConnectInterceptor::TimedCache::TimedCache(const base::TimeDelta& max_duration)
// Make Clang compilation happy with explicit destructor.
ConnectInterceptor::TimedCache::~TimedCache() {}
-bool ConnectInterceptor::TimedCache::WasRecentlySeen(const GURL& url) const {
+bool ConnectInterceptor::TimedCache::WasRecentlySeen(const GURL& url) {
DCHECK_EQ(url.GetWithEmptyPath(), url);
// Evict any overly old entries.
base::TimeTicks now = base::TimeTicks::Now();
@@ -120,7 +117,7 @@ bool ConnectInterceptor::TimedCache::WasRecentlySeen(const GURL& url) const {
return mru_cache_.end() != mru_cache_.Peek(url);
}
-void ConnectInterceptor::TimedCache::SetRecentlySeen(const GURL& url) const {
+void ConnectInterceptor::TimedCache::SetRecentlySeen(const GURL& url) {
DCHECK_EQ(url.GetWithEmptyPath(), url);
mru_cache_.Put(url, base::TimeTicks::Now());
}