| Index: chrome/browser/net/connect_interceptor.cc
|
| ===================================================================
|
| --- chrome/browser/net/connect_interceptor.cc (revision 97464)
|
| +++ chrome/browser/net/connect_interceptor.cc (working copy)
|
| @@ -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 @@
|
| // 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 @@
|
| 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 @@
|
| 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 @@
|
| // 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 @@
|
| // 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 @@
|
| 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());
|
| }
|
|
|