Chromium Code Reviews| Index: chrome/browser/io_thread.cc |
| =================================================================== |
| --- chrome/browser/io_thread.cc (revision 89645) |
| +++ chrome/browser/io_thread.cc (working copy) |
| @@ -318,8 +318,6 @@ |
| 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. |
| @@ -367,6 +365,7 @@ |
| size_t max_speculative_parallel_resolves, |
| const chrome_common_net::UrlList& startup_urls, |
| ListValue* referral_list, |
| + Profile* profile, |
| bool preconnect_enabled) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| message_loop()->PostTask( |
| @@ -376,7 +375,7 @@ |
| &IOThread::InitNetworkPredictorOnIOThread, |
| prefetching_enabled, max_dns_queue_delay, |
| max_speculative_parallel_resolves, |
| - startup_urls, referral_list, preconnect_enabled)); |
| + startup_urls, referral_list, preconnect_enabled, profile)); |
| } |
| void IOThread::RegisterURLRequestContextGetter( |
| @@ -403,13 +402,14 @@ |
| url_request_context_getters_.erase(it); |
| } |
| -void IOThread::ChangedToOnTheRecord() { |
| +void IOThread::ChangedToOnTheRecord(Profile* profile) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| message_loop()->PostTask( |
| FROM_HERE, |
| NewRunnableMethod( |
| this, |
| - &IOThread::ChangedToOnTheRecordOnIOThread)); |
| + &IOThread::ChangedToOnTheRecordOnIOThread, |
| + profile)); |
| } |
| net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { |
| @@ -420,13 +420,15 @@ |
| return system_url_request_context_getter_; |
| } |
| -void IOThread::ClearNetworkingHistory() { |
| +void IOThread::ClearNetworkingHistory( |
| + chrome_browser_net::Predictor* predictor) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| ClearHostCache(); |
| // Discard acrued data used to speculate in the future. |
| - chrome_browser_net::DiscardInitialNavigationHistory(); |
| - if (predictor_) |
| - predictor_->DiscardAllResults(); |
| + if (predictor) { |
| + predictor->DiscardInitialNavigationHistory(); |
| + predictor->DiscardAllResults(); |
| + } |
| } |
| void IOThread::Init() { |
| @@ -530,21 +532,6 @@ |
| // 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_; |
| @@ -607,33 +594,28 @@ |
| size_t max_speculative_parallel_resolves, |
| const chrome_common_net::UrlList& startup_urls, |
| ListValue* referral_list, |
| - bool preconnect_enabled) { |
| + bool preconnect_enabled, |
| + Profile* profile) { |
|
willchan no longer on Chromium
2011/07/21 12:10:53
Profile* is not allowed to be used on the IO threa
rpetterson
2011/08/10 02:24:46
Done.
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - CHECK(!predictor_); |
| + CHECK(!profile->GetPredictor()); |
| - chrome_browser_net::EnablePredictor(prefetching_enabled); |
| - |
| - predictor_ = new chrome_browser_net::Predictor( |
| + profile->SetPredictor(new chrome_browser_net::Predictor( |
| globals_->host_resolver.get(), |
| max_dns_queue_delay, |
| max_speculative_parallel_resolves, |
| - preconnect_enabled); |
| - predictor_->AddRef(); |
| + preconnect_enabled, |
| + prefetching_enabled)); |
| - // Speculative_interceptor_ is used to predict subresource usage. |
| - DCHECK(!speculative_interceptor_); |
| - speculative_interceptor_ = new chrome_browser_net::ConnectInterceptor; |
| - |
| - FinalizePredictorInitialization(predictor_, startup_urls, referral_list); |
| + profile->GetPredictor()->FinalizeInitialization(startup_urls, referral_list); |
| } |
| -void IOThread::ChangedToOnTheRecordOnIOThread() { |
| +void IOThread::ChangedToOnTheRecordOnIOThread(Profile* profile) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - if (predictor_) { |
| + if (profile->GetPredictor()) { |
|
willchan no longer on Chromium
2011/07/21 12:10:53
This should die. Once you've made the Predictor be
rpetterson
2011/08/10 02:24:46
Done.
|
| // Destroy all evidence of our OTR session. |
| // Note: OTR mode never saves InitialNavigationHistory data. |
| - predictor_->Predictor::DiscardAllResults(); |
| + profile->GetPredictor()->DiscardAllResults(); |
| } |
| // Clear the host cache to avoid showing entries from the OTR session |