diff options
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/predictor.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc index 3af1cf3..0b132b0 100644 --- a/chrome/browser/net/predictor.cc +++ b/chrome/browser/net/predictor.cc @@ -275,20 +275,25 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { void Predictor::PreconnectUrlAndSubresources(const GURL& url, const GURL& first_party_for_cookies) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!predictor_enabled_) - return; - if (!url.is_valid() || !url.has_host()) + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || + BrowserThread::CurrentlyOn(BrowserThread::IO)); + if (!predictor_enabled_ || !preconnect_enabled() || + !url.is_valid() || !url.has_host()) return; - if (preconnect_enabled()) { - std::string host = url.HostNoBrackets(); - UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED); - const int kConnectionsNeeded = 1; + + std::string host = url.HostNoBrackets(); + UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED); + const int kConnectionsNeeded = 1; + if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { PreconnectOnUIThread(CanonicalizeUrl(url), first_party_for_cookies, motivation, kConnectionsNeeded, url_request_context_getter_); - PredictFrameSubresources(url.GetWithEmptyPath(), first_party_for_cookies); + } else { + PreconnectOnIOThread(CanonicalizeUrl(url), first_party_for_cookies, + motivation, kConnectionsNeeded, + url_request_context_getter_); } + PredictFrameSubresources(url.GetWithEmptyPath(), first_party_for_cookies); } UrlList Predictor::GetPredictedUrlListAtStartup( |