Index: chrome/browser/net/predictor.cc |
diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc |
index 3981c5e871bde70539efe9e5f546e3f72d7d9469..27dd4467005f906256ad26f96402285dd8cb0c4f 100644 |
--- a/chrome/browser/net/predictor.cc |
+++ b/chrome/browser/net/predictor.cc |
@@ -273,19 +273,27 @@ 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) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
+ BrowserThread::CurrentlyOn(BrowserThread::IO)); |
if (!predictor_enabled_) |
return; |
if (!url.is_valid() || !url.has_host()) |
return; |
if (preconnect_enabled()) { |
jar (doing other things)
2013/05/08 01:34:25
nit: please do an early return here, when !preconn
kouhei (in TOK)
2013/05/08 02:09:39
Done. I love early returns.
|
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_); |
+ if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
+ PreconnectOnUIThread(CanonicalizeUrl(url), motivation, |
+ kConnectionsNeeded, |
+ url_request_context_getter_); |
+ } else { |
+ PreconnectOnIOThread(CanonicalizeUrl(url), motivation, |
+ kConnectionsNeeded, |
+ url_request_context_getter_); |
+ } |
PredictFrameSubresources(url.GetWithEmptyPath()); |
} |
} |