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

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

Issue 2871323006: Make Network Predictor skip empty urls (Closed)
Patch Set: self Created 3 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 2bb76985c1f3fe406b96bded8cf87e81b314ab89..27d279bc7281aa8f0009c70eb8e0a64d5c0207b2 100644
--- a/chrome/browser/net/predictor.cc
+++ b/chrome/browser/net/predictor.cc
@@ -242,17 +242,19 @@ void Predictor::PreconnectUrlAndSubresources(const GURL& url,
const GURL& first_party_for_cookies) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (!PredictorEnabled() || !url.is_valid() ||
- !url.has_host())
+ if (!PredictorEnabled())
return;
if (!CanPreresolveAndPreconnect())
return;
-
+ GURL canonicalized_url = CanonicalizeUrl(url);
Charlie Harrison 2017/05/15 17:01:25 nit: const GURL
xunjieli 2017/05/15 17:06:50 Done.
+ if (!canonicalized_url.is_valid() || !canonicalized_url.has_host())
+ return;
UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED);
const int kConnectionsNeeded = 1;
- PreconnectUrl(CanonicalizeUrl(url), first_party_for_cookies, motivation,
+ PreconnectUrl(canonicalized_url, first_party_for_cookies, motivation,
kConnectionsNeeded, kAllowCredentialsOnPreconnectByDefault);
- PredictFrameSubresources(url.GetWithEmptyPath(), first_party_for_cookies);
+ PredictFrameSubresources(canonicalized_url.GetWithEmptyPath(),
+ first_party_for_cookies);
}
std::vector<GURL> Predictor::GetPredictedUrlListAtStartup(
@@ -725,6 +727,7 @@ void Predictor::PreconnectUrl(const GURL& url,
int count) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(url.is_valid());
if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
PreconnectUrlOnIOThread(url, first_party_for_cookies, motivation,
« no previous file with comments | « no previous file | chrome/browser/net/predictor_browsertest.cc » ('j') | chrome/browser/net/predictor_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698