| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/dns_global.h" | 5 #include "chrome/browser/net/dns_global.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| 11 #include "base/stats_counters.h" | 11 #include "base/stats_counters.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/thread.h" | 13 #include "base/thread.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser.h" | 15 #include "chrome/browser/browser.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/net/dns_host_info.h" | 17 #include "chrome/browser/net/dns_host_info.h" |
| 18 #include "chrome/browser/net/referrer.h" | 18 #include "chrome/browser/net/referrer.h" |
| 19 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 20 #include "chrome/browser/session_startup_pref.h" | 20 #include "chrome/browser/session_startup_pref.h" |
| 21 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
| 22 #include "chrome/common/notification_service.h" | 22 #include "chrome/common/notification_service.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/pref_service.h" | 24 #include "chrome/common/pref_service.h" |
| 25 #include "chrome/common/chrome_switches.h" |
| 25 #include "net/base/host_resolver.h" | 26 #include "net/base/host_resolver.h" |
| 27 #include "net/base/host_resolver_impl.h" |
| 26 | 28 |
| 27 using base::Time; | 29 using base::Time; |
| 28 using base::TimeDelta; | 30 using base::TimeDelta; |
| 29 | 31 |
| 30 namespace chrome_browser_net { | 32 namespace chrome_browser_net { |
| 31 | 33 |
| 32 static void DiscardAllPrefetchState(); | 34 static void DiscardAllPrefetchState(); |
| 33 static void DnsMotivatedPrefetch(const std::string& hostname, | 35 static void DnsMotivatedPrefetch(const std::string& hostname, |
| 34 DnsHostInfo::ResolutionMotivation motivation); | 36 DnsHostInfo::ResolutionMotivation motivation); |
| 35 static void DnsPrefetchMotivatedList( | 37 static void DnsPrefetchMotivatedList( |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return; | 472 return; |
| 471 dns_master->DiscardAllResults(); | 473 dns_master->DiscardAllResults(); |
| 472 } | 474 } |
| 473 | 475 |
| 474 //------------------------------------------------------------------------------ | 476 //------------------------------------------------------------------------------ |
| 475 | 477 |
| 476 net::HostResolver* GetGlobalHostResolver() { | 478 net::HostResolver* GetGlobalHostResolver() { |
| 477 // Called from UI thread. | 479 // Called from UI thread. |
| 478 if (!global_host_resolver) { | 480 if (!global_host_resolver) { |
| 479 global_host_resolver = net::CreateSystemHostResolver(); | 481 global_host_resolver = net::CreateSystemHostResolver(); |
| 482 |
| 483 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableIPv6)) |
| 484 global_host_resolver->DisableIPv6(true); |
| 480 } | 485 } |
| 481 return global_host_resolver; | 486 return global_host_resolver; |
| 482 } | 487 } |
| 483 | 488 |
| 484 //------------------------------------------------------------------------------ | 489 //------------------------------------------------------------------------------ |
| 485 // Functions to handle saving of hostnames from one session to the next, to | 490 // Functions to handle saving of hostnames from one session to the next, to |
| 486 // expedite startup times. | 491 // expedite startup times. |
| 487 | 492 |
| 488 void SaveHostNamesForNextStartup(PrefService* local_state) { | 493 void SaveHostNamesForNextStartup(PrefService* local_state) { |
| 489 if (!dns_prefetch_enabled) | 494 if (!dns_prefetch_enabled) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 620 } |
| 616 } | 621 } |
| 617 | 622 |
| 618 DnsPrefetcherInit::~DnsPrefetcherInit() { | 623 DnsPrefetcherInit::~DnsPrefetcherInit() { |
| 619 if (dns_master) | 624 if (dns_master) |
| 620 FreeDnsPrefetchResources(); | 625 FreeDnsPrefetchResources(); |
| 621 } | 626 } |
| 622 | 627 |
| 623 } // namespace chrome_browser_net | 628 } // namespace chrome_browser_net |
| 624 | 629 |
| OLD | NEW |