| 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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/leak_tracker.h" | 8 #include "base/debug/leak_tracker.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/string_split.h" | 13 #include "base/string_split.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/thread_restrictions.h" | 15 #include "base/thread_restrictions.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browser_thread.h" | 17 #include "chrome/browser/browser_thread.h" |
| 18 #include "chrome/browser/gpu_process_host.h" | 18 #include "chrome/browser/gpu_process_host.h" |
| 19 #include "chrome/browser/net/chrome_net_log.h" | 19 #include "chrome/browser/net/chrome_net_log.h" |
| 20 #include "chrome/browser/net/connect_interceptor.h" | 20 #include "chrome/browser/net/connect_interceptor.h" |
| 21 #include "chrome/browser/net/passive_log_collector.h" | 21 #include "chrome/browser/net/passive_log_collector.h" |
| 22 #include "chrome/browser/net/predictor_api.h" | 22 #include "chrome/browser/net/predictor_api.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/net/raw_host_resolver_proc.h" | |
| 25 #include "chrome/common/net/url_fetcher.h" | 24 #include "chrome/common/net/url_fetcher.h" |
| 26 #include "net/base/dnsrr_resolver.h" | 25 #include "net/base/dnsrr_resolver.h" |
| 27 #include "net/base/host_cache.h" | 26 #include "net/base/host_cache.h" |
| 28 #include "net/base/host_resolver.h" | 27 #include "net/base/host_resolver.h" |
| 29 #include "net/base/host_resolver_impl.h" | 28 #include "net/base/host_resolver_impl.h" |
| 30 #include "net/base/mapped_host_resolver.h" | 29 #include "net/base/mapped_host_resolver.h" |
| 31 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
| 32 #include "net/http/http_auth_filter.h" | 31 #include "net/http/http_auth_filter.h" |
| 33 #include "net/http/http_auth_handler_factory.h" | 32 #include "net/http/http_auth_handler_factory.h" |
| 34 #if defined(USE_NSS) | 33 #if defined(USE_NSS) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 else if (trial->group() == parallel_8) | 80 else if (trial->group() == parallel_8) |
| 82 parallelism = 8; | 81 parallelism = 8; |
| 83 else if (trial->group() == parallel_10) | 82 else if (trial->group() == parallel_10) |
| 84 parallelism = 10; | 83 parallelism = 10; |
| 85 else if (trial->group() == parallel_14) | 84 else if (trial->group() == parallel_14) |
| 86 parallelism = 14; | 85 parallelism = 14; |
| 87 else if (trial->group() == parallel_20) | 86 else if (trial->group() == parallel_20) |
| 88 parallelism = 20; | 87 parallelism = 20; |
| 89 } | 88 } |
| 90 | 89 |
| 91 // Use the specified DNS server for doing raw resolutions if requested | |
| 92 // from the command-line. | |
| 93 scoped_refptr<net::HostResolverProc> resolver_proc; | |
| 94 if (command_line.HasSwitch(switches::kDnsServer)) { | |
| 95 std::string dns_ip_string = | |
| 96 command_line.GetSwitchValueASCII(switches::kDnsServer); | |
| 97 net::IPAddressNumber dns_ip_number; | |
| 98 if (net::ParseIPLiteralToNumber(dns_ip_string, &dns_ip_number)) { | |
| 99 resolver_proc = | |
| 100 new chrome_common_net::RawHostResolverProc(dns_ip_number, NULL); | |
| 101 } else { | |
| 102 LOG(ERROR) << "Invalid IP address specified for --dns-server: " | |
| 103 << dns_ip_string; | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 net::HostResolver* global_host_resolver = | 90 net::HostResolver* global_host_resolver = |
| 108 net::CreateSystemHostResolver(parallelism, resolver_proc.get(), net_log); | 91 net::CreateSystemHostResolver(parallelism, net_log); |
| 109 | 92 |
| 110 // Determine if we should disable IPv6 support. | 93 // Determine if we should disable IPv6 support. |
| 111 if (!command_line.HasSwitch(switches::kEnableIPv6)) { | 94 if (!command_line.HasSwitch(switches::kEnableIPv6)) { |
| 112 if (command_line.HasSwitch(switches::kDisableIPv6)) { | 95 if (command_line.HasSwitch(switches::kDisableIPv6)) { |
| 113 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); | 96 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); |
| 114 } else { | 97 } else { |
| 115 net::HostResolverImpl* host_resolver_impl = | 98 net::HostResolverImpl* host_resolver_impl = |
| 116 global_host_resolver->GetAsHostResolverImpl(); | 99 global_host_resolver->GetAsHostResolverImpl(); |
| 117 if (host_resolver_impl != NULL) { | 100 if (host_resolver_impl != NULL) { |
| 118 // Use probe to decide if support is warranted. | 101 // Use probe to decide if support is warranted. |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 net::HostCache* host_cache = | 411 net::HostCache* host_cache = |
| 429 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); | 412 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); |
| 430 if (host_cache) | 413 if (host_cache) |
| 431 host_cache->clear(); | 414 host_cache->clear(); |
| 432 } | 415 } |
| 433 // Clear all of the passively logged data. | 416 // Clear all of the passively logged data. |
| 434 // TODO(eroman): this is a bit heavy handed, really all we need to do is | 417 // TODO(eroman): this is a bit heavy handed, really all we need to do is |
| 435 // clear the data pertaining to off the record context. | 418 // clear the data pertaining to off the record context. |
| 436 globals_->net_log->passive_collector()->Clear(); | 419 globals_->net_log->passive_collector()->Clear(); |
| 437 } | 420 } |
| OLD | NEW |