| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_api.h" | 5 #include "chrome/browser/net/predictor_api.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 void DiscardInitialNavigationHistory() { | 141 void DiscardInitialNavigationHistory() { |
| 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 143 if (g_initial_observer) | 143 if (g_initial_observer) |
| 144 g_initial_observer->DiscardInitialNavigationHistory(); | 144 g_initial_observer->DiscardInitialNavigationHistory(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void RegisterUserPrefs(PrefService* user_prefs) { | 147 void RegisterUserPrefs(PrefService* user_prefs) { |
| 148 user_prefs->RegisterListPref(prefs::kDnsPrefetchingStartupList); | 148 user_prefs->RegisterListPref(prefs::kDnsPrefetchingStartupList); |
| 149 user_prefs->RegisterListPref(prefs::kDnsPrefetchingHostReferralList); | 149 user_prefs->RegisterListPref(prefs::kDnsPrefetchingHostReferralList); |
| 150 user_prefs->RegisterBooleanPref(prefs::kDnsPrefetchingEnabled, true); | |
| 151 } | 150 } |
| 152 | 151 |
| 153 // When enabled, we use the following instance to service all requests in the | 152 // When enabled, we use the following instance to service all requests in the |
| 154 // browser process. | 153 // browser process. |
| 155 // TODO(willchan): Look at killing this. | 154 // TODO(willchan): Look at killing this. |
| 156 static Predictor* g_predictor = NULL; | 155 static Predictor* g_predictor = NULL; |
| 157 | 156 |
| 158 // This API is only used in the browser process. | 157 // This API is only used in the browser process. |
| 159 // It is called from an IPC message originating in the renderer. It currently | 158 // It is called from an IPC message originating in the renderer. It currently |
| 160 // includes both Page-Scan, and Link-Hover prefetching. | 159 // includes both Page-Scan, and Link-Hover prefetching. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 //------------------------------------------------------------------------------ | 393 //------------------------------------------------------------------------------ |
| 395 | 394 |
| 396 static void InitNetworkPredictor(TimeDelta max_dns_queue_delay, | 395 static void InitNetworkPredictor(TimeDelta max_dns_queue_delay, |
| 397 size_t max_parallel_resolves, | 396 size_t max_parallel_resolves, |
| 398 PrefService* user_prefs, | 397 PrefService* user_prefs, |
| 399 PrefService* local_state, | 398 PrefService* local_state, |
| 400 bool preconnect_enabled) { | 399 bool preconnect_enabled) { |
| 401 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 402 | 401 |
| 403 bool prefetching_enabled = | 402 bool prefetching_enabled = |
| 404 user_prefs->GetBoolean(prefs::kDnsPrefetchingEnabled); | 403 user_prefs->GetBoolean(prefs::kNetworkPredictionEnabled); |
| 405 | 404 |
| 406 // Gather the list of hostnames to prefetch on startup. | 405 // Gather the list of hostnames to prefetch on startup. |
| 407 UrlList urls = | 406 UrlList urls = |
| 408 GetPredictedUrlListAtStartup(user_prefs, local_state); | 407 GetPredictedUrlListAtStartup(user_prefs, local_state); |
| 409 | 408 |
| 410 ListValue* referral_list = | 409 ListValue* referral_list = |
| 411 static_cast<ListValue*>(user_prefs->GetList( | 410 static_cast<ListValue*>(user_prefs->GetList( |
| 412 prefs::kDnsPrefetchingHostReferralList)->DeepCopy()); | 411 prefs::kDnsPrefetchingHostReferralList)->DeepCopy()); |
| 413 | 412 |
| 414 // Remove obsolete preferences from local state if necessary. | 413 // Remove obsolete preferences from local state if necessary. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 DCHECK(!g_predictor); | 642 DCHECK(!g_predictor); |
| 644 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, | 643 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, |
| 645 local_state, preconnect_enabled); | 644 local_state, preconnect_enabled); |
| 646 } | 645 } |
| 647 } | 646 } |
| 648 | 647 |
| 649 PredictorInit::~PredictorInit() { | 648 PredictorInit::~PredictorInit() { |
| 650 } | 649 } |
| 651 | 650 |
| 652 } // namespace chrome_browser_net | 651 } // namespace chrome_browser_net |
| OLD | NEW |