OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/browser_thread.h" | 18 #include "chrome/browser/browser_thread.h" |
19 #include "chrome/browser/io_thread.h" | 19 #include "chrome/browser/io_thread.h" |
20 #include "chrome/browser/net/preconnect.h" | 20 #include "chrome/browser/net/preconnect.h" |
21 #include "chrome/browser/net/referrer.h" | 21 #include "chrome/browser/net/referrer.h" |
22 #include "chrome/browser/net/url_info.h" | 22 #include "chrome/browser/net/url_info.h" |
| 23 #include "chrome/browser/prefs/browser_prefs.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/browser/prefs/session_startup_pref.h" | 25 #include "chrome/browser/prefs/session_startup_pref.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/common/notification_registrar.h" | 28 #include "chrome/common/notification_registrar.h" |
28 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
30 #include "net/base/host_resolver.h" | 31 #include "net/base/host_resolver.h" |
31 #include "net/base/host_resolver_impl.h" | 32 #include "net/base/host_resolver_impl.h" |
32 | 33 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 388 |
388 // Gather the list of hostnames to prefetch on startup. | 389 // Gather the list of hostnames to prefetch on startup. |
389 UrlList urls = | 390 UrlList urls = |
390 GetPredictedUrlListAtStartup(user_prefs, local_state); | 391 GetPredictedUrlListAtStartup(user_prefs, local_state); |
391 | 392 |
392 ListValue* referral_list = | 393 ListValue* referral_list = |
393 static_cast<ListValue*>(user_prefs->GetMutableList( | 394 static_cast<ListValue*>(user_prefs->GetMutableList( |
394 prefs::kDnsPrefetchingHostReferralList)->DeepCopy()); | 395 prefs::kDnsPrefetchingHostReferralList)->DeepCopy()); |
395 | 396 |
396 // Remove obsolete preferences from local state if necessary. | 397 // Remove obsolete preferences from local state if necessary. |
397 int dns_prefs_version = | 398 int current_version = |
398 user_prefs->GetInteger(prefs::kMultipleProfilePrefMigration); | 399 local_state->GetInteger(prefs::kMultipleProfilePrefMigration); |
399 if (dns_prefs_version < 1) { | 400 if ((current_version & browser::DNS_PREFS) == 0) { |
400 // These prefs only need to be registered if they need to be cleared from | |
401 // local state. | |
402 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); | 401 local_state->RegisterListPref(prefs::kDnsStartupPrefetchList); |
403 local_state->RegisterListPref(prefs::kDnsHostReferralList); | 402 local_state->RegisterListPref(prefs::kDnsHostReferralList); |
404 local_state->ClearPref(prefs::kDnsStartupPrefetchList); | 403 local_state->ClearPref(prefs::kDnsStartupPrefetchList); |
405 local_state->ClearPref(prefs::kDnsHostReferralList); | 404 local_state->ClearPref(prefs::kDnsHostReferralList); |
406 user_prefs->SetInteger(prefs::kMultipleProfilePrefMigration, 1); | 405 local_state->SetInteger(prefs::kMultipleProfilePrefMigration, |
| 406 current_version | browser::DNS_PREFS); |
407 } | 407 } |
408 | 408 |
409 g_browser_process->io_thread()->InitNetworkPredictor( | 409 g_browser_process->io_thread()->InitNetworkPredictor( |
410 prefetching_enabled, max_dns_queue_delay, max_parallel_resolves, urls, | 410 prefetching_enabled, max_dns_queue_delay, max_parallel_resolves, urls, |
411 referral_list, preconnect_enabled); | 411 referral_list, preconnect_enabled); |
412 } | 412 } |
413 | 413 |
414 void FinalizePredictorInitialization( | 414 void FinalizePredictorInitialization( |
415 Predictor* global_predictor, | 415 Predictor* global_predictor, |
416 const UrlList& startup_urls, | 416 const UrlList& startup_urls, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 DCHECK(!g_predictor); | 624 DCHECK(!g_predictor); |
625 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, | 625 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, |
626 local_state, preconnect_enabled); | 626 local_state, preconnect_enabled); |
627 } | 627 } |
628 } | 628 } |
629 | 629 |
630 PredictorInit::~PredictorInit() { | 630 PredictorInit::~PredictorInit() { |
631 } | 631 } |
632 | 632 |
633 } // namespace chrome_browser_net | 633 } // namespace chrome_browser_net |
OLD | NEW |