Chromium Code Reviews| Index: chrome/browser/net/predictor.cc |
| diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc |
| index 2bb76985c1f3fe406b96bded8cf87e81b314ab89..b3e96ac64e0e8cccc617213a373f50af1558391d 100644 |
| --- a/chrome/browser/net/predictor.cc |
| +++ b/chrome/browser/net/predictor.cc |
| @@ -171,12 +171,13 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| if (!PredictorEnabled()) |
| return; |
| - if (!url.is_valid() || !url.has_host()) |
| + GURL canonicalized_url = CanonicalizeUrl(url); |
|
Charlie Harrison
2017/05/15 00:01:07
Here and below can you make sure we canoncalize th
xunjieli
2017/05/15 16:41:44
Done.
|
| + if (!canonicalized_url.is_valid() || !canonicalized_url.has_host()) |
| return; |
| if (!CanPreresolveAndPreconnect()) |
| return; |
| - std::string host = url.HostNoBrackets(); |
| + std::string host = canonicalized_url.HostNoBrackets(); |
| bool is_new_host_request = (host != last_omnibox_host_); |
| last_omnibox_host_ = host; |
| @@ -212,7 +213,7 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { |
| return; // We've done a preconnect recently. |
| last_omnibox_preconnect_ = now; |
| const int kConnectionsNeeded = 1; |
| - PreconnectUrl(CanonicalizeUrl(url), GURL(), motivation, |
| + PreconnectUrl(canonicalized_url, GURL(), motivation, |
| kAllowCredentialsOnPreconnectByDefault, kConnectionsNeeded); |
| return; // Skip pre-resolution, since we'll open a connection. |
| } |
| @@ -235,24 +236,26 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { |
| BrowserThread::PostTask( |
| BrowserThread::IO, FROM_HERE, |
| base::BindOnce(&Predictor::Resolve, base::Unretained(this), |
| - CanonicalizeUrl(url), motivation)); |
| + canonicalized_url, motivation)); |
| } |
| 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()) |
| + GURL canonicalized_url = CanonicalizeUrl(url); |
| + if (!PredictorEnabled() || !canonicalized_url.is_valid() || |
| + !canonicalized_url.has_host()) |
| return; |
| if (!CanPreresolveAndPreconnect()) |
| 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 +728,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, |