From b1af343a7deb23a3229cc07d65285b5247c8ad46 Mon Sep 17 00:00:00 2001 From: "rlp@chromium.org" Date: Fri, 19 Aug 2011 09:36:14 +0000 Subject: 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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97446 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/io_thread.cc | 99 --------------------------------------------- 1 file changed, 99 deletions(-) (limited to 'chrome/browser/io_thread.cc') diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index b8f3557..7bea24f 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -24,7 +24,6 @@ #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/connect_interceptor.h" #include "chrome/browser/net/passive_log_collector.h" -#include "chrome/browser/net/predictor_api.h" #include "chrome/browser/net/pref_proxy_config_service.h" #include "chrome/browser/net/proxy_service_factory.h" #include "chrome/browser/prefs/pref_service.h" @@ -344,8 +343,6 @@ IOThread::IOThread( net_log_(net_log), extension_event_router_forwarder_(extension_event_router_forwarder), globals_(NULL), - speculative_interceptor_(NULL), - predictor_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make // sure that everything is initialized in the right order. @@ -387,33 +384,6 @@ ChromeNetLog* IOThread::net_log() { return net_log_; } -void IOThread::InitNetworkPredictor( - bool prefetching_enabled, - base::TimeDelta max_dns_queue_delay, - size_t max_speculative_parallel_resolves, - const chrome_common_net::UrlList& startup_urls, - ListValue* referral_list, - bool preconnect_enabled) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod( - this, - &IOThread::InitNetworkPredictorOnIOThread, - prefetching_enabled, max_dns_queue_delay, - max_speculative_parallel_resolves, - startup_urls, referral_list, preconnect_enabled)); -} - -void IOThread::ChangedToOnTheRecord() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - message_loop()->PostTask( - FROM_HERE, - NewRunnableMethod( - this, - &IOThread::ChangedToOnTheRecordOnIOThread)); -} - net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!system_url_request_context_getter_) { @@ -422,15 +392,6 @@ net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { return system_url_request_context_getter_; } -void IOThread::ClearNetworkingHistory() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - ClearHostCache(); - // Discard acrued data used to speculate in the future. - chrome_browser_net::DiscardInitialNavigationHistory(); - if (predictor_) - predictor_->DiscardAllResults(); -} - void IOThread::Init() { // Though this thread is called the "IO" thread, it actually just routes // messages around; it shouldn't be allowed to perform any blocking disk I/O. @@ -527,21 +488,6 @@ void IOThread::CleanUp() { // This must be reset before the ChromeNetLog is destroyed. network_change_observer_.reset(); - // Not initialized in Init(). May not be initialized. - if (predictor_) { - predictor_->Shutdown(); - - // TODO(willchan): Stop reference counting Predictor. It's owned by - // IOThread now. - predictor_->Release(); - predictor_ = NULL; - chrome_browser_net::FreePredictorResources(); - } - - // Deletion will unregister this interceptor. - delete speculative_interceptor_; - speculative_interceptor_ = NULL; - system_proxy_config_service_.reset(); delete globals_; @@ -598,51 +544,6 @@ net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( negotiate_enable_port_); } -void IOThread::InitNetworkPredictorOnIOThread( - bool prefetching_enabled, - base::TimeDelta max_dns_queue_delay, - size_t max_speculative_parallel_resolves, - const chrome_common_net::UrlList& startup_urls, - ListValue* referral_list, - bool preconnect_enabled) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - CHECK(!predictor_); - - chrome_browser_net::EnablePredictor(prefetching_enabled); - - predictor_ = new chrome_browser_net::Predictor( - globals_->host_resolver.get(), - max_dns_queue_delay, - max_speculative_parallel_resolves, - preconnect_enabled); - predictor_->AddRef(); - - // Speculative_interceptor_ is used to predict subresource usage. - DCHECK(!speculative_interceptor_); - speculative_interceptor_ = new chrome_browser_net::ConnectInterceptor; - - FinalizePredictorInitialization(predictor_, startup_urls, referral_list); -} - -void IOThread::ChangedToOnTheRecordOnIOThread() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - if (predictor_) { - // Destroy all evidence of our OTR session. - // Note: OTR mode never saves InitialNavigationHistory data. - predictor_->Predictor::DiscardAllResults(); - } - - // Clear the host cache to avoid showing entries from the OTR session - // in about:net-internals. - ClearHostCache(); - - // Clear all of the passively logged data. - // TODO(eroman): this is a bit heavy handed, really all we need to do is - // clear the data pertaining to incognito context. - net_log_->ClearAllPassivelyCapturedEvents(); -} - void IOThread::ClearHostCache() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -- cgit v1.1