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

Unified Diff: chrome/browser/net/connect_interceptor.cc

Issue 7685009: Revert "Modifying prefetch to account for multi-profile." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/connect_interceptor.h ('k') | chrome/browser/net/net_pref_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/connect_interceptor.cc
diff --git a/chrome/browser/net/connect_interceptor.cc b/chrome/browser/net/connect_interceptor.cc
index 0ea6dbd52952f543105c1d3ab74a8ccad354c014..5938df280fb689fd7c091f9c9a494e96fc548c78 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());
}
« no previous file with comments | « chrome/browser/net/connect_interceptor.h ('k') | chrome/browser/net/net_pref_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698