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