| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 138 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
| 139 } | 139 } |
| 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 PrefService::UNSYNCABLE_PREF); |
| 150 user_prefs->RegisterListPref(prefs::kDnsPrefetchingHostReferralList, |
| 151 PrefService::UNSYNCABLE_PREF); |
| 150 } | 152 } |
| 151 | 153 |
| 152 // When enabled, we use the following instance to service all requests in the | 154 // When enabled, we use the following instance to service all requests in the |
| 153 // browser process. | 155 // browser process. |
| 154 // TODO(willchan): Look at killing this. | 156 // TODO(willchan): Look at killing this. |
| 155 static Predictor* g_predictor = NULL; | 157 static Predictor* g_predictor = NULL; |
| 156 | 158 |
| 157 // This API is only used in the browser process. | 159 // This API is only used in the browser process. |
| 158 // It is called from an IPC message originating in the renderer. It currently | 160 // It is called from an IPC message originating in the renderer. It currently |
| 159 // includes both Page-Scan, and Link-Hover prefetching. | 161 // includes both Page-Scan, and Link-Hover prefetching. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 GetPredictedUrlListAtStartup(user_prefs, local_state); | 409 GetPredictedUrlListAtStartup(user_prefs, local_state); |
| 408 | 410 |
| 409 ListValue* referral_list = | 411 ListValue* referral_list = |
| 410 static_cast<ListValue*>(user_prefs->GetList( | 412 static_cast<ListValue*>(user_prefs->GetList( |
| 411 prefs::kDnsPrefetchingHostReferralList)->DeepCopy()); | 413 prefs::kDnsPrefetchingHostReferralList)->DeepCopy()); |
| 412 | 414 |
| 413 // Remove obsolete preferences from local state if necessary. | 415 // Remove obsolete preferences from local state if necessary. |
| 414 int current_version = | 416 int current_version = |
| 415 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); | 417 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
| 416 if ((current_version & browser::DNS_PREFS) == 0) { | 418 if ((current_version & browser::DNS_PREFS) == 0) { |
| 417 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); | 419 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList, |
| 418 local_state->RegisterListPref(prefs::kDnsHostReferralList); | 420 PrefService::UNSYNCABLE_PREF); |
| 421 local_state->RegisterListPref(prefs::kDnsHostReferralList, |
| 422 PrefService::UNSYNCABLE_PREF); |
| 419 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | 423 local_state->ClearPref(prefs::kDnsStartupPrefetchList); |
| 420 local_state->ClearPref(prefs::kDnsHostReferralList); | 424 local_state->ClearPref(prefs::kDnsHostReferralList); |
| 421 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, | 425 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
| 422 current_version | browser::DNS_PREFS); | 426 current_version | browser::DNS_PREFS); |
| 423 } | 427 } |
| 424 | 428 |
| 425 g_browser_process->io_thread()->InitNetworkPredictor( | 429 g_browser_process->io_thread()->InitNetworkPredictor( |
| 426 prefetching_enabled, max_dns_queue_delay, max_parallel_resolves, urls, | 430 prefetching_enabled, max_dns_queue_delay, max_parallel_resolves, urls, |
| 427 referral_list, preconnect_enabled); | 431 referral_list, preconnect_enabled); |
| 428 } | 432 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 DCHECK(!g_predictor); | 646 DCHECK(!g_predictor); |
| 643 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, | 647 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, |
| 644 local_state, preconnect_enabled); | 648 local_state, preconnect_enabled); |
| 645 } | 649 } |
| 646 } | 650 } |
| 647 | 651 |
| 648 PredictorInit::~PredictorInit() { | 652 PredictorInit::~PredictorInit() { |
| 649 } | 653 } |
| 650 | 654 |
| 651 } // namespace chrome_browser_net | 655 } // namespace chrome_browser_net |
| OLD | NEW |