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 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/leak_tracker.h" | 7 #include "base/leak_tracker.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
11 #include "chrome/browser/gpu_process_host.h" | 11 #include "chrome/browser/gpu_process_host.h" |
12 #include "chrome/browser/net/chrome_net_log.h" | 12 #include "chrome/browser/net/chrome_net_log.h" |
13 #include "chrome/browser/net/dns_global.h" | 13 #include "chrome/browser/net/dns_global.h" |
14 #include "chrome/browser/net/passive_log_collector.h" | 14 #include "chrome/browser/net/passive_log_collector.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/net/url_fetcher.h" | 16 #include "chrome/common/net/url_fetcher.h" |
17 #include "net/base/mapped_host_resolver.h" | 17 #include "net/base/mapped_host_resolver.h" |
18 #include "net/base/host_cache.h" | 18 #include "net/base/host_cache.h" |
19 #include "net/base/host_resolver.h" | 19 #include "net/base/host_resolver.h" |
20 #include "net/base/host_resolver_impl.h" | 20 #include "net/base/host_resolver_impl.h" |
21 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
22 #include "net/base/network_change_notifier.h" | |
23 #include "net/http/http_auth_filter.h" | 22 #include "net/http/http_auth_filter.h" |
24 #include "net/http/http_auth_handler_factory.h" | 23 #include "net/http/http_auth_handler_factory.h" |
25 #include "net/http/http_auth_handler_negotiate.h" | 24 #include "net/http/http_auth_handler_negotiate.h" |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 net::HostResolver* CreateGlobalHostResolver( | 28 net::HostResolver* CreateGlobalHostResolver() { |
30 net::NetworkChangeNotifier* network_change_notifier) { | |
31 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 29 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
32 net::HostResolver* global_host_resolver = | 30 net::HostResolver* global_host_resolver = net::CreateSystemHostResolver(); |
33 net::CreateSystemHostResolver(network_change_notifier); | |
34 | 31 |
35 // Determine if we should disable IPv6 support. | 32 // Determine if we should disable IPv6 support. |
36 if (!command_line.HasSwitch(switches::kEnableIPv6)) { | 33 if (!command_line.HasSwitch(switches::kEnableIPv6)) { |
37 if (command_line.HasSwitch(switches::kDisableIPv6)) { | 34 if (command_line.HasSwitch(switches::kDisableIPv6)) { |
38 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); | 35 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); |
39 } else { | 36 } else { |
40 net::HostResolverImpl* host_resolver_impl = | 37 net::HostResolverImpl* host_resolver_impl = |
41 global_host_resolver->GetAsHostResolverImpl(); | 38 global_host_resolver->GetAsHostResolverImpl(); |
42 if (host_resolver_impl != NULL) { | 39 if (host_resolver_impl != NULL) { |
43 // (optionally) Use probe to decide if support is warranted. | 40 // (optionally) Use probe to decide if support is warranted. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 &IOThread::ChangedToOnTheRecordOnIOThread)); | 125 &IOThread::ChangedToOnTheRecordOnIOThread)); |
129 } | 126 } |
130 | 127 |
131 void IOThread::Init() { | 128 void IOThread::Init() { |
132 BrowserProcessSubThread::Init(); | 129 BrowserProcessSubThread::Init(); |
133 | 130 |
134 DCHECK(!globals_); | 131 DCHECK(!globals_); |
135 globals_ = new Globals; | 132 globals_ = new Globals; |
136 | 133 |
137 globals_->net_log.reset(new ChromeNetLog()); | 134 globals_->net_log.reset(new ChromeNetLog()); |
138 globals_->network_change_notifier.reset( | 135 globals_->host_resolver = CreateGlobalHostResolver(); |
139 net::NetworkChangeNotifier::CreateDefaultNetworkChangeNotifier()); | |
140 globals_->host_resolver = | |
141 CreateGlobalHostResolver(globals_->network_change_notifier.get()); | |
142 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory()); | 136 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory()); |
143 } | 137 } |
144 | 138 |
145 void IOThread::CleanUp() { | 139 void IOThread::CleanUp() { |
146 // If any child processes are still running, terminate them and | 140 // If any child processes are still running, terminate them and |
147 // and delete the ChildProcessHost instances to release whatever | 141 // and delete the ChildProcessHost instances to release whatever |
148 // IO thread only resources they are referencing. | 142 // IO thread only resources they are referencing. |
149 ChildProcessHost::TerminateAll(); | 143 ChildProcessHost::TerminateAll(); |
150 | 144 |
151 // Not initialized in Init(). May not be initialized. | 145 // Not initialized in Init(). May not be initialized. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 net::HostCache* host_cache = | 283 net::HostCache* host_cache = |
290 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); | 284 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); |
291 if (host_cache) | 285 if (host_cache) |
292 host_cache->clear(); | 286 host_cache->clear(); |
293 } | 287 } |
294 // Clear all of the passively logged data. | 288 // Clear all of the passively logged data. |
295 // TODO(eroman): this is a bit heavy handed, really all we need to do is | 289 // TODO(eroman): this is a bit heavy handed, really all we need to do is |
296 // clear the data pertaining to off the record context. | 290 // clear the data pertaining to off the record context. |
297 globals_->net_log->passive_collector()->Clear(); | 291 globals_->net_log->passive_collector()->Clear(); |
298 } | 292 } |
OLD | NEW |