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

Side by Side 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: removed leftover change / early return 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/predictor.h" 5 #include "chrome/browser/net/predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <sstream> 10 #include <sstream>
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 last_omnibox_preresolve_ = now; 266 last_omnibox_preresolve_ = now;
267 267
268 // Perform at least DNS pre-resolution. 268 // Perform at least DNS pre-resolution.
269 BrowserThread::PostTask( 269 BrowserThread::PostTask(
270 BrowserThread::IO, 270 BrowserThread::IO,
271 FROM_HERE, 271 FROM_HERE,
272 base::Bind(&Predictor::Resolve, base::Unretained(this), 272 base::Bind(&Predictor::Resolve, base::Unretained(this),
273 CanonicalizeUrl(url), motivation)); 273 CanonicalizeUrl(url), motivation));
274 } 274 }
275 275
276 void Predictor::PreconnectUrlAndSubresources(const GURL& url) { 276 void Predictor::PreconnectUrlAndSubresources(
277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 277 const GURL& url,
278 if (!predictor_enabled_) 278 UrlInfo::ResolutionMotivation motivation) {
279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
280 BrowserThread::CurrentlyOn(BrowserThread::IO));
281 if (!predictor_enabled_ || !preconnect_enabled() ||
282 !url.is_valid() || !url.has_host())
279 return; 283 return;
280 if (!url.is_valid() || !url.has_host()) 284
281 return; 285 std::string host = url.HostNoBrackets();
282 if (preconnect_enabled()) { 286 const int kConnectionsNeeded = 1;
283 std::string host = url.HostNoBrackets(); 287 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
284 UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED);
285 const int kConnectionsNeeded = 1;
286 PreconnectOnUIThread(CanonicalizeUrl(url), motivation, 288 PreconnectOnUIThread(CanonicalizeUrl(url), motivation,
287 kConnectionsNeeded, 289 kConnectionsNeeded,
288 url_request_context_getter_); 290 url_request_context_getter_);
289 PredictFrameSubresources(url.GetWithEmptyPath()); 291 } else {
292 PreconnectOnIOThread(CanonicalizeUrl(url), motivation,
293 kConnectionsNeeded,
294 url_request_context_getter_);
290 } 295 }
296 PredictFrameSubresources(url.GetWithEmptyPath());
291 } 297 }
292 298
293 UrlList Predictor::GetPredictedUrlListAtStartup( 299 UrlList Predictor::GetPredictedUrlListAtStartup(
294 PrefService* user_prefs, 300 PrefService* user_prefs,
295 PrefService* local_state) { 301 PrefService* local_state) {
296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
297 UrlList urls; 303 UrlList urls;
298 // Recall list of URLs we learned about during last session. 304 // Recall list of URLs we learned about during last session.
299 // This may catch secondary hostnames, pulled in by the homepages. It will 305 // This may catch secondary hostnames, pulled in by the homepages. It will
300 // also catch more of the "primary" home pages, since that was (presumably) 306 // also catch more of the "primary" home pages, since that was (presumably)
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 IOThread* io_thread, 1192 IOThread* io_thread,
1187 net::URLRequestContextGetter* getter) { 1193 net::URLRequestContextGetter* getter) {
1188 // Empty function for unittests. 1194 // Empty function for unittests.
1189 } 1195 }
1190 1196
1191 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { 1197 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) {
1192 SetShutdown(true); 1198 SetShutdown(true);
1193 } 1199 }
1194 1200
1195 } // namespace chrome_browser_net 1201 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698