Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: chrome/browser/io_thread.cc

Issue 4216001: Initial support for built-in DNS resolver/cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing files Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | net/base/host_resolver_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
24 #include "chrome/common/net/url_fetcher.h" 25 #include "chrome/common/net/url_fetcher.h"
25 #include "net/base/dnsrr_resolver.h" 26 #include "net/base/dnsrr_resolver.h"
26 #include "net/base/host_cache.h" 27 #include "net/base/host_cache.h"
27 #include "net/base/host_resolver.h" 28 #include "net/base/host_resolver.h"
28 #include "net/base/host_resolver_impl.h" 29 #include "net/base/host_resolver_impl.h"
29 #include "net/base/mapped_host_resolver.h" 30 #include "net/base/mapped_host_resolver.h"
30 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
31 #include "net/http/http_auth_filter.h" 32 #include "net/http/http_auth_filter.h"
32 #include "net/http/http_auth_handler_factory.h" 33 #include "net/http/http_auth_handler_factory.h"
33 #if defined(USE_NSS) 34 #if defined(USE_NSS)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 else if (trial->group() == parallel_8) 81 else if (trial->group() == parallel_8)
81 parallelism = 8; 82 parallelism = 8;
82 else if (trial->group() == parallel_10) 83 else if (trial->group() == parallel_10)
83 parallelism = 10; 84 parallelism = 10;
84 else if (trial->group() == parallel_14) 85 else if (trial->group() == parallel_14)
85 parallelism = 14; 86 parallelism = 14;
86 else if (trial->group() == parallel_20) 87 else if (trial->group() == parallel_20)
87 parallelism = 20; 88 parallelism = 20;
88 } 89 }
89 90
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
90 net::HostResolver* global_host_resolver = 107 net::HostResolver* global_host_resolver =
91 net::CreateSystemHostResolver(parallelism, net_log); 108 net::CreateSystemHostResolver(parallelism, resolver_proc.get(), net_log);
92 109
93 // Determine if we should disable IPv6 support. 110 // Determine if we should disable IPv6 support.
94 if (!command_line.HasSwitch(switches::kEnableIPv6)) { 111 if (!command_line.HasSwitch(switches::kEnableIPv6)) {
95 if (command_line.HasSwitch(switches::kDisableIPv6)) { 112 if (command_line.HasSwitch(switches::kDisableIPv6)) {
96 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); 113 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
97 } else { 114 } else {
98 net::HostResolverImpl* host_resolver_impl = 115 net::HostResolverImpl* host_resolver_impl =
99 global_host_resolver->GetAsHostResolverImpl(); 116 global_host_resolver->GetAsHostResolverImpl();
100 if (host_resolver_impl != NULL) { 117 if (host_resolver_impl != NULL) {
101 // Use probe to decide if support is warranted. 118 // Use probe to decide if support is warranted.
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 net::HostCache* host_cache = 428 net::HostCache* host_cache =
412 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); 429 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache();
413 if (host_cache) 430 if (host_cache)
414 host_cache->clear(); 431 host_cache->clear();
415 } 432 }
416 // Clear all of the passively logged data. 433 // Clear all of the passively logged data.
417 // TODO(eroman): this is a bit heavy handed, really all we need to do is 434 // TODO(eroman): this is a bit heavy handed, really all we need to do is
418 // clear the data pertaining to off the record context. 435 // clear the data pertaining to off the record context.
419 globals_->net_log->passive_collector()->Clear(); 436 globals_->net_log->passive_collector()->Clear();
420 } 437 }
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_common.gypi » ('j') | net/base/host_resolver_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698