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

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: use WebPrerenderingSupport instead of platform API / removed motivationId 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 UrlInfo::ResolutionMotivation motivation) {
279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
280 BrowserThread::CurrentlyOn(BrowserThread::IO));
278 if (!predictor_enabled_) 281 if (!predictor_enabled_)
279 return; 282 return;
280 if (!url.is_valid() || !url.has_host()) 283 if (!url.is_valid() || !url.has_host())
281 return; 284 return;
282 if (preconnect_enabled()) { 285 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.
283 std::string host = url.HostNoBrackets(); 286 std::string host = url.HostNoBrackets();
284 UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED);
285 const int kConnectionsNeeded = 1; 287 const int kConnectionsNeeded = 1;
286 PreconnectOnUIThread(CanonicalizeUrl(url), motivation, 288 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
287 kConnectionsNeeded, 289 PreconnectOnUIThread(CanonicalizeUrl(url), motivation,
288 url_request_context_getter_); 290 kConnectionsNeeded,
291 url_request_context_getter_);
292 } else {
293 PreconnectOnIOThread(CanonicalizeUrl(url), motivation,
294 kConnectionsNeeded,
295 url_request_context_getter_);
296 }
289 PredictFrameSubresources(url.GetWithEmptyPath()); 297 PredictFrameSubresources(url.GetWithEmptyPath());
290 } 298 }
291 } 299 }
292 300
293 UrlList Predictor::GetPredictedUrlListAtStartup( 301 UrlList Predictor::GetPredictedUrlListAtStartup(
294 PrefService* user_prefs, 302 PrefService* user_prefs,
295 PrefService* local_state) { 303 PrefService* local_state) {
296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
297 UrlList urls; 305 UrlList urls;
298 // Recall list of URLs we learned about during last session. 306 // Recall list of URLs we learned about during last session.
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 IOThread* io_thread, 1194 IOThread* io_thread,
1187 net::URLRequestContextGetter* getter) { 1195 net::URLRequestContextGetter* getter) {
1188 // Empty function for unittests. 1196 // Empty function for unittests.
1189 } 1197 }
1190 1198
1191 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { 1199 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) {
1192 SetShutdown(true); 1200 SetShutdown(true);
1193 } 1201 }
1194 1202
1195 } // namespace chrome_browser_net 1203 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698