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

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: Created 7 years, 8 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 6e82188244e7451743d8fe9c2103217ce72ea212..5ec2e457c076e798b7ba17f7582ab134c5954336 100644
--- a/chrome/browser/net/predictor.cc
+++ b/chrome/browser/net/predictor.cc
@@ -273,19 +273,29 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) {
CanonicalizeUrl(url), motivation));
}
-void Predictor::PreconnectUrlAndSubresources(const GURL& url) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+void Predictor::PreconnectUrlAndSubresources(
+ const GURL& url,
+ UrlInfo::ResolutionMotivation motivation,
+ uint32_t motivationVariationId) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
+ BrowserThread::CurrentlyOn(BrowserThread::IO));
jar (doing other things) 2013/05/04 00:32:05 I need to check... but the old assertion suggests
if (!predictor_enabled_)
jar (doing other things) 2013/05/04 00:32:05 This is vaguely thread safe (it is "only" a bool :
kouhei (in TOK) 2013/05/07 09:16:12 Actually, some methods on this class is already ca
return;
if (!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;
- PreconnectOnUIThread(CanonicalizeUrl(url), motivation,
- kConnectionsNeeded,
- url_request_context_getter_);
+ // TODO(kouhei): pass motivationVariationId
+ if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ PreconnectOnUIThread(CanonicalizeUrl(url), motivation,
+ kConnectionsNeeded,
+ url_request_context_getter_);
jar (doing other things) 2013/05/04 00:32:05 I have to read the code more to see that your acce
+ } else {
+ PreconnectOnIOThread(CanonicalizeUrl(url), motivation,
+ kConnectionsNeeded,
+ url_request_context_getter_);
+ }
PredictFrameSubresources(url.GetWithEmptyPath());
}
}

Powered by Google App Engine
This is Rietveld 408576698