diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 02:44:08 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 02:44:08 +0000 |
commit | 36b9eeed34f581de1a0bc216aae8949f54bf17c4 (patch) | |
tree | 2e6bf6c1c254be11fb0142bf12c4ce67b35435f8 /chrome/browser/net | |
parent | 7b86fcb8eae8b2c2f06484bf8e93a500cf3b1d5c (diff) | |
download | chromium_src-36b9eeed34f581de1a0bc216aae8949f54bf17c4.zip chromium_src-36b9eeed34f581de1a0bc216aae8949f54bf17c4.tar.gz chromium_src-36b9eeed34f581de1a0bc216aae8949f54bf17c4.tar.bz2 |
Revert 106437 (seems to break _all_ the sync unit tests) - 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
TBR=rlp@chromium.org
Review URL: http://codereview.chromium.org/8355033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/preconnect.cc | 19 | ||||
-rw-r--r-- | chrome/browser/net/preconnect.h | 10 | ||||
-rw-r--r-- | chrome/browser/net/predictor.cc | 34 | ||||
-rw-r--r-- | chrome/browser/net/predictor.h | 11 |
4 files changed, 25 insertions, 49 deletions
diff --git a/chrome/browser/net/preconnect.cc b/chrome/browser/net/preconnect.cc index 456a471..56342df 100644 --- a/chrome/browser/net/preconnect.cc +++ b/chrome/browser/net/preconnect.cc @@ -4,9 +4,9 @@ #include "chrome/browser/net/preconnect.h" -#include "base/bind.h" #include "base/logging.h" #include "base/metrics/histogram.h" +#include "chrome/browser/profiles/profile.h" #include "content/browser/browser_thread.h" #include "net/base/net_log.h" #include "net/base/ssl_config_service.h" @@ -22,14 +22,13 @@ namespace chrome_browser_net { void PreconnectOnUIThread( const GURL& url, UrlInfo::ResolutionMotivation motivation, - int count, - net::URLRequestContextGetter* getter) { + int count) { // Prewarm connection to Search URL. BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&PreconnectOnIOThread, url, motivation, - count, make_scoped_refptr(getter))); + NewRunnableFunction(PreconnectOnIOThread, url, motivation, + count)); return; } @@ -37,14 +36,16 @@ void PreconnectOnUIThread( void PreconnectOnIOThread( const GURL& url, UrlInfo::ResolutionMotivation motivation, - int count, - net::URLRequestContextGetter* getter) { + int count) { + net::URLRequestContextGetter* getter = + Profile::Deprecated::GetDefaultRequestContext(); + if (!getter) + return; if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { LOG(DFATAL) << "This must be run only on the IO thread."; return; } - if (!getter) - return; + // We are now commited to doing the async preconnection call. UMA_HISTOGRAM_ENUMERATION("Net.PreconnectMotivation", motivation, UrlInfo::MAX_MOTIVATED); diff --git a/chrome/browser/net/preconnect.h b/chrome/browser/net/preconnect.h index 89e48db..056d5d6 100644 --- a/chrome/browser/net/preconnect.h +++ b/chrome/browser/net/preconnect.h @@ -13,10 +13,6 @@ class GURL; -namespace net { -class URLRequestContextGetter; -} - namespace chrome_browser_net { // Try to preconnect. Typically motivated by OMNIBOX to reach search service. @@ -24,16 +20,14 @@ namespace chrome_browser_net { // parallel. void PreconnectOnUIThread(const GURL& url, UrlInfo::ResolutionMotivation motivation, - int count, - net::URLRequestContextGetter* getter); + int count); // Try to preconnect. Typically used by predictor when a subresource probably // needs a connection. |count| may be used to request more than one connection // be established in parallel. void PreconnectOnIOThread(const GURL& url, UrlInfo::ResolutionMotivation motivation, - int count, - net::URLRequestContextGetter* getter); + int count); } // namespace chrome_browser_net diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc index 62dbd98..20fa822 100644 --- a/chrome/browser/net/predictor.cc +++ b/chrome/browser/net/predictor.cc @@ -34,7 +34,6 @@ #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; @@ -124,7 +123,6 @@ 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), @@ -145,8 +143,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); @@ -163,15 +161,12 @@ void Predictor::RegisterUserPrefs(PrefService* user_prefs) { void Predictor::InitNetworkPredictor(PrefService* user_prefs, PrefService* local_state, - IOThread* io_thread, - net::URLRequestContextGetter* getter) { + IOThread* io_thread) { 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); @@ -248,8 +243,7 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { last_omnibox_preconnect_ = now; const int kConnectionsNeeded = 1; PreconnectOnUIThread(CanonicalizeUrl(url), motivation, - kConnectionsNeeded, - url_request_context_getter_); + kConnectionsNeeded); return; // Skip pre-resolution, since we'll open a connection. } } else { @@ -288,8 +282,7 @@ void Predictor::PreconnectUrlAndSubresources(const GURL& url) { UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED); const int kConnectionsNeeded = 1; PreconnectOnUIThread(CanonicalizeUrl(url), motivation, - kConnectionsNeeded, - url_request_context_getter_); + kConnectionsNeeded); PredictFrameSubresources(url.GetWithEmptyPath()); } } @@ -894,10 +887,8 @@ 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, - url_request_context_getter_); - } + if (preconnect_enabled_) + PreconnectOnIOThread(url, UrlInfo::SELF_REFERAL_MOTIVATED, 2); return; } @@ -920,8 +911,7 @@ 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, - url_request_context_getter_); + PreconnectOnIOThread(future_url->first, motivation, count); } else if (connection_expectation > kDNSPreresolutionWorthyExpectedValue) { evalution = PRERESOLUTION; future_url->second.preresolution_increment(); @@ -1212,11 +1202,9 @@ 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, - net::URLRequestContextGetter* getter) { +void SimplePredictor::InitNetworkPredictor(PrefService* user_prefs, + PrefService* local_state, + IOThread* io_thread) { // Empty function for unittests. } diff --git a/chrome/browser/net/predictor.h b/chrome/browser/net/predictor.h index 1ed7007..710b8ae 100644 --- a/chrome/browser/net/predictor.h +++ b/chrome/browser/net/predictor.h @@ -43,7 +43,6 @@ class WaitableEvent; namespace net { class HostResolver; -class URLRequestContextGetter; } // namespace net class IOThread; @@ -107,8 +106,7 @@ class Predictor { virtual void InitNetworkPredictor(PrefService* user_prefs, PrefService* local_state, - IOThread* io_thread, - net::URLRequestContextGetter* getter); + IOThread* io_thread); // The Omnibox has proposed a given url to the user, and if it is a search // URL, then it also indicates that this is preconnectable (i.e., we could @@ -433,10 +431,6 @@ class Predictor { scoped_ptr<InitialObserver> initial_observer_; - // Reference to URLRequestContextGetter from the Profile which owns the - // predictor. Used by Preconnect. - scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; - // Status of speculative DNS resolution and speculative TCP/IP connection // feature. bool predictor_enabled_; @@ -511,8 +505,7 @@ class SimplePredictor : public Predictor { virtual ~SimplePredictor() {} virtual void InitNetworkPredictor(PrefService* user_prefs, PrefService* local_state, - IOThread* io_thread, - net::URLRequestContextGetter* getter); + IOThread* io_thread); virtual void ShutdownOnUIThread(PrefService* user_prefs); }; |