diff options
author | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 01:54:24 +0000 |
---|---|---|
committer | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 01:54:24 +0000 |
commit | 1b2747da8cf41299c56b60a87fc3200eceb8c002 (patch) | |
tree | fdadaf99cb015b88fb8de5b93c61909ef99d08b4 /chrome/browser/net/predictor.cc | |
parent | 8e479ac1b1c72ae85683a3ce85640803ddaf1cae (diff) | |
download | chromium_src-1b2747da8cf41299c56b60a87fc3200eceb8c002.zip chromium_src-1b2747da8cf41299c56b60a87fc3200eceb8c002.tar.gz chromium_src-1b2747da8cf41299c56b60a87fc3200eceb8c002.tar.bz2 |
Updating Preconnect to no longer get the default context. Instead it now gets the profile's context.
BUG=97759
TEST=passes existing
Review URL: http://codereview.chromium.org/8165015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/predictor.cc')
-rw-r--r-- | chrome/browser/net/predictor.cc | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc index 20fa822..62dbd98 100644 --- a/chrome/browser/net/predictor.cc +++ b/chrome/browser/net/predictor.cc @@ -34,6 +34,7 @@ #include "net/base/net_errors.h" #include "net/base/net_log.h" #include "net/base/single_request_host_resolver.h" +#include "net/url_request/url_request_context_getter.h" using base::TimeDelta; @@ -123,6 +124,7 @@ class Predictor::LookupRequest { Predictor::Predictor(bool preconnect_enabled) : initial_observer_(NULL), + url_request_context_getter_(NULL), predictor_enabled_(true), peak_pending_lookups_(0), shutdown_(false), @@ -143,8 +145,8 @@ Predictor::~Predictor() { } // static -Predictor* Predictor::CreatePredictor( - bool preconnect_enabled, bool simple_shutdown) { +Predictor* Predictor::CreatePredictor(bool preconnect_enabled, + bool simple_shutdown) { if (simple_shutdown) return new SimplePredictor(preconnect_enabled); return new Predictor(preconnect_enabled); @@ -161,12 +163,15 @@ void Predictor::RegisterUserPrefs(PrefService* user_prefs) { void Predictor::InitNetworkPredictor(PrefService* user_prefs, PrefService* local_state, - IOThread* io_thread) { + IOThread* io_thread, + net::URLRequestContextGetter* getter) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); bool predictor_enabled = user_prefs->GetBoolean(prefs::kNetworkPredictionEnabled); + url_request_context_getter_ = getter; + // Gather the list of hostnames to prefetch on startup. UrlList urls = GetPredictedUrlListAtStartup(user_prefs, local_state); @@ -243,7 +248,8 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { last_omnibox_preconnect_ = now; const int kConnectionsNeeded = 1; PreconnectOnUIThread(CanonicalizeUrl(url), motivation, - kConnectionsNeeded); + kConnectionsNeeded, + url_request_context_getter_); return; // Skip pre-resolution, since we'll open a connection. } } else { @@ -282,7 +288,8 @@ void Predictor::PreconnectUrlAndSubresources(const GURL& url) { UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED); const int kConnectionsNeeded = 1; PreconnectOnUIThread(CanonicalizeUrl(url), motivation, - kConnectionsNeeded); + kConnectionsNeeded, + url_request_context_getter_); PredictFrameSubresources(url.GetWithEmptyPath()); } } @@ -887,8 +894,10 @@ void Predictor::PrepareFrameSubresources(const GURL& url) { // size of the list with all the "Leaf" nodes in the tree (nodes that don't // load any subresources). If we learn about this resource, we will instead // provide a more carefully estimated preconnection count. - if (preconnect_enabled_) - PreconnectOnIOThread(url, UrlInfo::SELF_REFERAL_MOTIVATED, 2); + if (preconnect_enabled_) { + PreconnectOnIOThread(url, UrlInfo::SELF_REFERAL_MOTIVATED, 2, + url_request_context_getter_); + } return; } @@ -911,7 +920,8 @@ void Predictor::PrepareFrameSubresources(const GURL& url) { int count = static_cast<int>(std::ceil(connection_expectation)); if (url.host() == future_url->first.host()) ++count; - PreconnectOnIOThread(future_url->first, motivation, count); + PreconnectOnIOThread(future_url->first, motivation, count, + url_request_context_getter_); } else if (connection_expectation > kDNSPreresolutionWorthyExpectedValue) { evalution = PRERESOLUTION; future_url->second.preresolution_increment(); @@ -1202,9 +1212,11 @@ GURL Predictor::CanonicalizeUrl(const GURL& url) { return GURL(scheme + "://" + url.host() + colon_plus_port); } -void SimplePredictor::InitNetworkPredictor(PrefService* user_prefs, - PrefService* local_state, - IOThread* io_thread) { +void SimplePredictor::InitNetworkPredictor( + PrefService* user_prefs, + PrefService* local_state, + IOThread* io_thread, + net::URLRequestContextGetter* getter) { // Empty function for unittests. } |