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

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: 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 uint32_t motivationVariationId) {
280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
281 BrowserThread::CurrentlyOn(BrowserThread::IO));
jar (doing other things) 2013/05/04 00:32:05 I need to check... but the old assertion suggests
278 if (!predictor_enabled_) 282 if (!predictor_enabled_)
jar (doing other things) 2013/05/04 00:32:05 This is vaguely thread safe (it is "only" a bool :
kouhei (in TOK) 2013/05/07 09:16:12 Actually, some methods on this class is already ca
279 return; 283 return;
280 if (!url.is_valid() || !url.has_host()) 284 if (!url.is_valid() || !url.has_host())
281 return; 285 return;
282 if (preconnect_enabled()) { 286 if (preconnect_enabled()) {
283 std::string host = url.HostNoBrackets(); 287 std::string host = url.HostNoBrackets();
284 UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED);
285 const int kConnectionsNeeded = 1; 288 const int kConnectionsNeeded = 1;
286 PreconnectOnUIThread(CanonicalizeUrl(url), motivation, 289 // TODO(kouhei): pass motivationVariationId
287 kConnectionsNeeded, 290 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
288 url_request_context_getter_); 291 PreconnectOnUIThread(CanonicalizeUrl(url), motivation,
292 kConnectionsNeeded,
293 url_request_context_getter_);
jar (doing other things) 2013/05/04 00:32:05 I have to read the code more to see that your acce
294 } else {
295 PreconnectOnIOThread(CanonicalizeUrl(url), motivation,
296 kConnectionsNeeded,
297 url_request_context_getter_);
298 }
289 PredictFrameSubresources(url.GetWithEmptyPath()); 299 PredictFrameSubresources(url.GetWithEmptyPath());
290 } 300 }
291 } 301 }
292 302
293 UrlList Predictor::GetPredictedUrlListAtStartup( 303 UrlList Predictor::GetPredictedUrlListAtStartup(
294 PrefService* user_prefs, 304 PrefService* user_prefs,
295 PrefService* local_state) { 305 PrefService* local_state) {
296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
297 UrlList urls; 307 UrlList urls;
298 // Recall list of URLs we learned about during last session. 308 // 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, 1196 IOThread* io_thread,
1187 net::URLRequestContextGetter* getter) { 1197 net::URLRequestContextGetter* getter) {
1188 // Empty function for unittests. 1198 // Empty function for unittests.
1189 } 1199 }
1190 1200
1191 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { 1201 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) {
1192 SetShutdown(true); 1202 SetShutdown(true);
1193 } 1203 }
1194 1204
1195 } // namespace chrome_browser_net 1205 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698