Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3173)

Unified Diff: chrome/browser/net/predictor.cc

Issue 14749005: Implement WebPrescientNetworking to trigger preconnect from Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/predictor.cc
diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc
index 3af1cf3a2b5388e70d6a69964fb21b77574991be..0b132b058e596ddb8eb2f0d5c2dc9b8ec949ac44 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(

Powered by Google App Engine
This is Rietveld 408576698