| OLD | NEW |
| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 459 |
| 460 // Prepare for any static home page(s) the user has in prefs. The user may | 460 // Prepare for any static home page(s) the user has in prefs. The user may |
| 461 // have a LOT of tab's specified, so we may as well try to warm them all. | 461 // have a LOT of tab's specified, so we may as well try to warm them all. |
| 462 SessionStartupPref tab_start_pref = | 462 SessionStartupPref tab_start_pref = |
| 463 SessionStartupPref::GetStartupPref(user_prefs); | 463 SessionStartupPref::GetStartupPref(user_prefs); |
| 464 if (SessionStartupPref::URLS == tab_start_pref.type) { | 464 if (SessionStartupPref::URLS == tab_start_pref.type) { |
| 465 for (size_t i = 0; i < tab_start_pref.urls.size(); i++) { | 465 for (size_t i = 0; i < tab_start_pref.urls.size(); i++) { |
| 466 GURL gurl = tab_start_pref.urls[i]; | 466 GURL gurl = tab_start_pref.urls[i]; |
| 467 if (!gurl.is_valid() || gurl.SchemeIsFile() || gurl.host().empty()) | 467 if (!gurl.is_valid() || gurl.SchemeIsFile() || gurl.host().empty()) |
| 468 continue; | 468 continue; |
| 469 if (gurl.SchemeIs("http") || gurl.SchemeIs("https")) | 469 if (gurl.SchemeIsHttp()) |
| 470 urls.push_back(gurl.GetWithEmptyPath()); | 470 urls.push_back(gurl.GetWithEmptyPath()); |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 if (urls.empty()) | 474 if (urls.empty()) |
| 475 urls.push_back(GURL("http://www.google.com:80")); | 475 urls.push_back(GURL("http://www.google.com:80")); |
| 476 | 476 |
| 477 return urls; | 477 return urls; |
| 478 } | 478 } |
| 479 | 479 |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 void Predictor::InitialObserver::Append(const GURL& url, | 1293 void Predictor::InitialObserver::Append(const GURL& url, |
| 1294 Predictor* predictor) { | 1294 Predictor* predictor) { |
| 1295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1296 | 1296 |
| 1297 // TODO(rlp): Do we really need the predictor check here? | 1297 // TODO(rlp): Do we really need the predictor check here? |
| 1298 if (NULL == predictor) | 1298 if (NULL == predictor) |
| 1299 return; | 1299 return; |
| 1300 if (kStartupResolutionCount <= first_navigations_.size()) | 1300 if (kStartupResolutionCount <= first_navigations_.size()) |
| 1301 return; | 1301 return; |
| 1302 | 1302 |
| 1303 DCHECK(url.SchemeIs("http") || url.SchemeIs("https")); | 1303 DCHECK(url.SchemeIsHttp()); |
| 1304 DCHECK_EQ(url, Predictor::CanonicalizeUrl(url)); | 1304 DCHECK_EQ(url, Predictor::CanonicalizeUrl(url)); |
| 1305 if (first_navigations_.find(url) == first_navigations_.end()) | 1305 if (first_navigations_.find(url) == first_navigations_.end()) |
| 1306 first_navigations_[url] = base::TimeTicks::Now(); | 1306 first_navigations_[url] = base::TimeTicks::Now(); |
| 1307 } | 1307 } |
| 1308 | 1308 |
| 1309 void Predictor::InitialObserver::GetInitialDnsResolutionList( | 1309 void Predictor::InitialObserver::GetInitialDnsResolutionList( |
| 1310 base::ListValue* startup_list) { | 1310 base::ListValue* startup_list) { |
| 1311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1312 DCHECK(startup_list); | 1312 DCHECK(startup_list); |
| 1313 startup_list->Clear(); | 1313 startup_list->Clear(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 IOThread* io_thread, | 1375 IOThread* io_thread, |
| 1376 net::URLRequestContextGetter* getter) { | 1376 net::URLRequestContextGetter* getter) { |
| 1377 // Empty function for unittests. | 1377 // Empty function for unittests. |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { | 1380 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { |
| 1381 SetShutdown(true); | 1381 SetShutdown(true); |
| 1382 } | 1382 } |
| 1383 | 1383 |
| 1384 } // namespace chrome_browser_net | 1384 } // namespace chrome_browser_net |
| OLD | NEW |