[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/io_thread.h" |
[email protected] | e83326f | 2010-07-31 17:29:25 | [diff] [blame] | 6 | |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 7 | #include <vector> |
| 8 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 9 | #include "base/command_line.h" |
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 10 | #include "base/debug/leak_tracker.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 11 | #include "base/logging.h" |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 12 | #include "base/metrics/field_trial.h" |
[email protected] | 8693361 | 2010-10-16 23:10:33 | [diff] [blame] | 13 | #include "base/stl_util-inl.h" |
[email protected] | e83326f | 2010-07-31 17:29:25 | [diff] [blame] | 14 | #include "base/string_number_conversions.h" |
[email protected] | 4e5ae20f | 2010-09-24 04:52:11 | [diff] [blame] | 15 | #include "base/string_split.h" |
[email protected] | f1d8192 | 2010-07-31 17:47:09 | [diff] [blame] | 16 | #include "base/string_util.h" |
[email protected] | 34b9963 | 2011-01-01 01:01:06 | [diff] [blame] | 17 | #include "base/threading/thread_restrictions.h" |
[email protected] | df2840d | 2011-02-20 16:32:32 | [diff] [blame] | 18 | #include "chrome/browser/browser_process.h" |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame^] | 19 | #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
| 20 | #include "chrome/browser/net/chrome_network_delegate.h" |
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 21 | #include "chrome/browser/net/chrome_net_log.h" |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 22 | #include "chrome/browser/net/chrome_url_request_context.h" |
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 23 | #include "chrome/browser/net/connect_interceptor.h" |
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 24 | #include "chrome/browser/net/passive_log_collector.h" |
[email protected] | 8693361 | 2010-10-16 23:10:33 | [diff] [blame] | 25 | #include "chrome/browser/net/predictor_api.h" |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 26 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 27 | #include "chrome/common/chrome_switches.h" |
[email protected] | 2258c1c9 | 2010-10-28 17:51:19 | [diff] [blame] | 28 | #include "chrome/common/net/raw_host_resolver_proc.h" |
[email protected] | 68d2a05f | 2010-05-07 21:39:55 | [diff] [blame] | 29 | #include "chrome/common/net/url_fetcher.h" |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 30 | #include "chrome/common/pref_names.h" |
[email protected] | 567812d | 2011-02-24 17:40:50 | [diff] [blame] | 31 | #include "content/browser/browser_thread.h" |
| 32 | #include "content/browser/gpu_process_host.h" |
| 33 | #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 34 | #include "net/base/cert_verifier.h" |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 35 | #include "net/base/cookie_monster.h" |
[email protected] | 2db58053 | 2010-10-08 14:32:37 | [diff] [blame] | 36 | #include "net/base/dnsrr_resolver.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 37 | #include "net/base/host_cache.h" |
| 38 | #include "net/base/host_resolver.h" |
[email protected] | f2d8c421 | 2010-02-02 00:56:35 | [diff] [blame] | 39 | #include "net/base/host_resolver_impl.h" |
[email protected] | 8693361 | 2010-10-16 23:10:33 | [diff] [blame] | 40 | #include "net/base/mapped_host_resolver.h" |
[email protected] | 32eaa33 | 2010-02-08 22:15:54 | [diff] [blame] | 41 | #include "net/base/net_util.h" |
[email protected] | eb3cac7 | 2010-02-26 21:07:45 | [diff] [blame] | 42 | #include "net/http/http_auth_filter.h" |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 43 | #include "net/http/http_auth_handler_factory.h" |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 44 | #include "net/http/http_network_layer.h" |
[email protected] | 57cb0f7 | 2011-01-28 06:33:58 | [diff] [blame] | 45 | #include "net/http/http_network_session.h" |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 46 | #if defined(USE_NSS) |
| 47 | #include "net/ocsp/nss_ocsp.h" |
| 48 | #endif // defined(USE_NSS) |
[email protected] | 8693361 | 2010-10-16 23:10:33 | [diff] [blame] | 49 | #include "net/proxy/proxy_script_fetcher_impl.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 50 | |
| 51 | namespace { |
| 52 | |
[email protected] | ee094b8 | 2010-08-24 15:55:51 | [diff] [blame] | 53 | net::HostResolver* CreateGlobalHostResolver(net::NetLog* net_log) { |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 54 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | 962b9821 | 2010-07-17 03:37:51 | [diff] [blame] | 55 | |
| 56 | size_t parallelism = net::HostResolver::kDefaultParallelism; |
| 57 | |
| 58 | // Use the concurrency override from the command-line, if any. |
| 59 | if (command_line.HasSwitch(switches::kHostResolverParallelism)) { |
| 60 | std::string s = |
| 61 | command_line.GetSwitchValueASCII(switches::kHostResolverParallelism); |
| 62 | |
| 63 | // Parse the switch (it should be a positive integer formatted as decimal). |
| 64 | int n; |
[email protected] | e83326f | 2010-07-31 17:29:25 | [diff] [blame] | 65 | if (base::StringToInt(s, &n) && n > 0) { |
[email protected] | 962b9821 | 2010-07-17 03:37:51 | [diff] [blame] | 66 | parallelism = static_cast<size_t>(n); |
| 67 | } else { |
| 68 | LOG(ERROR) << "Invalid switch for host resolver parallelism: " << s; |
| 69 | } |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 70 | } else { |
| 71 | // Set up a field trial to see what impact the total number of concurrent |
| 72 | // resolutions have on DNS resolutions. |
| 73 | base::FieldTrial::Probability kDivisor = 1000; |
| 74 | // For each option (i.e., non-default), we have a fixed probability. |
| 75 | base::FieldTrial::Probability kProbabilityPerGroup = 100; // 10%. |
| 76 | |
[email protected] | 933729bc | 2011-01-19 18:52:32 | [diff] [blame] | 77 | // After June 30, 2011 builds, it will always be in default group |
| 78 | // (parallel_default). |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 79 | scoped_refptr<base::FieldTrial> trial( |
[email protected] | 933729bc | 2011-01-19 18:52:32 | [diff] [blame] | 80 | new base::FieldTrial( |
| 81 | "DnsParallelism", kDivisor, "parallel_default", 2011, 6, 30)); |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 82 | |
| 83 | // List options with different counts. |
| 84 | // Firefox limits total to 8 in parallel, and default is currently 50. |
| 85 | int parallel_6 = trial->AppendGroup("parallel_6", kProbabilityPerGroup); |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 86 | int parallel_7 = trial->AppendGroup("parallel_7", kProbabilityPerGroup); |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 87 | int parallel_8 = trial->AppendGroup("parallel_8", kProbabilityPerGroup); |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 88 | int parallel_9 = trial->AppendGroup("parallel_9", kProbabilityPerGroup); |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 89 | int parallel_10 = trial->AppendGroup("parallel_10", kProbabilityPerGroup); |
| 90 | int parallel_14 = trial->AppendGroup("parallel_14", kProbabilityPerGroup); |
| 91 | int parallel_20 = trial->AppendGroup("parallel_20", kProbabilityPerGroup); |
| 92 | |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 93 | if (trial->group() == parallel_6) |
| 94 | parallelism = 6; |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 95 | else if (trial->group() == parallel_7) |
| 96 | parallelism = 7; |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 97 | else if (trial->group() == parallel_8) |
| 98 | parallelism = 8; |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 99 | else if (trial->group() == parallel_9) |
| 100 | parallelism = 9; |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 101 | else if (trial->group() == parallel_10) |
| 102 | parallelism = 10; |
| 103 | else if (trial->group() == parallel_14) |
| 104 | parallelism = 14; |
| 105 | else if (trial->group() == parallel_20) |
| 106 | parallelism = 20; |
[email protected] | 962b9821 | 2010-07-17 03:37:51 | [diff] [blame] | 107 | } |
| 108 | |
[email protected] | 2258c1c9 | 2010-10-28 17:51:19 | [diff] [blame] | 109 | // Use the specified DNS server for doing raw resolutions if requested |
| 110 | // from the command-line. |
| 111 | scoped_refptr<net::HostResolverProc> resolver_proc; |
| 112 | if (command_line.HasSwitch(switches::kDnsServer)) { |
| 113 | std::string dns_ip_string = |
| 114 | command_line.GetSwitchValueASCII(switches::kDnsServer); |
| 115 | net::IPAddressNumber dns_ip_number; |
| 116 | if (net::ParseIPLiteralToNumber(dns_ip_string, &dns_ip_number)) { |
| 117 | resolver_proc = |
| 118 | new chrome_common_net::RawHostResolverProc(dns_ip_number, NULL); |
| 119 | } else { |
| 120 | LOG(ERROR) << "Invalid IP address specified for --dns-server: " |
| 121 | << dns_ip_string; |
| 122 | } |
| 123 | } |
| 124 | |
[email protected] | 962b9821 | 2010-07-17 03:37:51 | [diff] [blame] | 125 | net::HostResolver* global_host_resolver = |
[email protected] | 2258c1c9 | 2010-10-28 17:51:19 | [diff] [blame] | 126 | net::CreateSystemHostResolver(parallelism, resolver_proc.get(), net_log); |
[email protected] | 9087aa3 | 2010-02-18 08:03:38 | [diff] [blame] | 127 | |
[email protected] | 0f8f1b43 | 2010-03-16 19:06:03 | [diff] [blame] | 128 | // Determine if we should disable IPv6 support. |
[email protected] | 9087aa3 | 2010-02-18 08:03:38 | [diff] [blame] | 129 | if (!command_line.HasSwitch(switches::kEnableIPv6)) { |
[email protected] | 0f8f1b43 | 2010-03-16 19:06:03 | [diff] [blame] | 130 | if (command_line.HasSwitch(switches::kDisableIPv6)) { |
[email protected] | 46f6e20 | 2010-02-26 06:07:25 | [diff] [blame] | 131 | global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); |
[email protected] | 0f8f1b43 | 2010-03-16 19:06:03 | [diff] [blame] | 132 | } else { |
| 133 | net::HostResolverImpl* host_resolver_impl = |
| 134 | global_host_resolver->GetAsHostResolverImpl(); |
| 135 | if (host_resolver_impl != NULL) { |
[email protected] | 780f849 | 2010-09-16 04:12:15 | [diff] [blame] | 136 | // Use probe to decide if support is warranted. |
| 137 | host_resolver_impl->ProbeIPv6Support(); |
[email protected] | 0f8f1b43 | 2010-03-16 19:06:03 | [diff] [blame] | 138 | } |
| 139 | } |
[email protected] | 9087aa3 | 2010-02-18 08:03:38 | [diff] [blame] | 140 | } |
| 141 | |
[email protected] | 9087aa3 | 2010-02-18 08:03:38 | [diff] [blame] | 142 | // If hostname remappings were specified on the command-line, layer these |
| 143 | // rules on top of the real host resolver. This allows forwarding all requests |
| 144 | // through a designated test server. |
[email protected] | 0f8f1b43 | 2010-03-16 19:06:03 | [diff] [blame] | 145 | if (!command_line.HasSwitch(switches::kHostResolverRules)) |
| 146 | return global_host_resolver; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 147 | |
[email protected] | 0f8f1b43 | 2010-03-16 19:06:03 | [diff] [blame] | 148 | net::MappedHostResolver* remapped_resolver = |
| 149 | new net::MappedHostResolver(global_host_resolver); |
| 150 | remapped_resolver->SetRulesFromString( |
| 151 | command_line.GetSwitchValueASCII(switches::kHostResolverRules)); |
| 152 | return remapped_resolver; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 153 | } |
| 154 | |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 155 | class LoggingNetworkChangeObserver |
| 156 | : public net::NetworkChangeNotifier::Observer { |
| 157 | public: |
| 158 | // |net_log| must remain valid throughout our lifetime. |
| 159 | explicit LoggingNetworkChangeObserver(net::NetLog* net_log) |
| 160 | : net_log_(net_log) { |
| 161 | net::NetworkChangeNotifier::AddObserver(this); |
| 162 | } |
| 163 | |
| 164 | ~LoggingNetworkChangeObserver() { |
| 165 | net::NetworkChangeNotifier::RemoveObserver(this); |
| 166 | } |
| 167 | |
| 168 | virtual void OnIPAddressChanged() { |
[email protected] | 8e96e50 | 2010-10-21 20:57:12 | [diff] [blame] | 169 | VLOG(1) << "Observed a change to the network IP addresses"; |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 170 | |
[email protected] | d3aaf3f | 2010-09-02 20:45:55 | [diff] [blame] | 171 | net_log_->AddEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED, |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 172 | base::TimeTicks::Now(), |
[email protected] | d2cbfbe | 2010-08-12 17:38:16 | [diff] [blame] | 173 | net::NetLog::Source(), |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 174 | net::NetLog::PHASE_NONE, |
| 175 | NULL); |
| 176 | } |
| 177 | |
| 178 | private: |
| 179 | net::NetLog* net_log_; |
| 180 | DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); |
| 181 | }; |
| 182 | |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 183 | scoped_refptr<net::URLRequestContext> |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 184 | ConstructProxyScriptFetcherContext(IOThread::Globals* globals, |
| 185 | net::NetLog* net_log) { |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 186 | scoped_refptr<net::URLRequestContext> context(new net::URLRequestContext); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 187 | context->set_net_log(net_log); |
| 188 | context->set_host_resolver(globals->host_resolver.get()); |
| 189 | context->set_cert_verifier(globals->cert_verifier.get()); |
| 190 | context->set_dnsrr_resolver(globals->dnsrr_resolver.get()); |
| 191 | context->set_http_auth_handler_factory( |
| 192 | globals->http_auth_handler_factory.get()); |
| 193 | context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); |
| 194 | context->set_http_transaction_factory( |
[email protected] | 52617df | 2010-12-24 07:30:01 | [diff] [blame] | 195 | globals->proxy_script_fetcher_http_transaction_factory.get()); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 196 | // In-memory cookie store. |
| 197 | context->set_cookie_store(new net::CookieMonster(NULL, NULL)); |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame^] | 198 | context->set_network_delegate(globals->system_network_delegate.get()); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 199 | return context; |
| 200 | } |
| 201 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 202 | } // namespace |
| 203 | |
| 204 | // The IOThread object must outlive any tasks posted to the IO thread before the |
| 205 | // Quit task. |
[email protected] | c56428f2 | 2010-06-16 02:17:23 | [diff] [blame] | 206 | DISABLE_RUNNABLE_METHOD_REFCOUNT(IOThread); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 207 | |
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 208 | IOThread::Globals::Globals() {} |
| 209 | |
| 210 | IOThread::Globals::~Globals() {} |
| 211 | |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 212 | // |local_state| is passed in explicitly in order to (1) reduce implicit |
| 213 | // dependencies and (2) make IOThread more flexible for testing. |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame^] | 214 | IOThread::IOThread( |
| 215 | PrefService* local_state, |
| 216 | ChromeNetLog* net_log, |
| 217 | ExtensionEventRouterForwarder* extension_event_router_forwarder) |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 218 | : BrowserProcessSubThread(BrowserThread::IO), |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 219 | net_log_(net_log), |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame^] | 220 | extension_event_router_forwarder_(extension_event_router_forwarder), |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 221 | globals_(NULL), |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 222 | speculative_interceptor_(NULL), |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 223 | predictor_(NULL) { |
| 224 | // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make |
| 225 | // sure that everything is initialized in the right order. |
| 226 | RegisterPrefs(local_state); |
| 227 | auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 228 | negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
| 229 | prefs::kDisableAuthNegotiateCnameLookup); |
| 230 | negotiate_enable_port_ = local_state->GetBoolean( |
| 231 | prefs::kEnableAuthNegotiatePort); |
| 232 | auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
| 233 | auth_delegate_whitelist_ = local_state->GetString( |
| 234 | prefs::kAuthNegotiateDelegateWhitelist); |
[email protected] | ac7f3fdb | 2010-11-12 12:47:05 | [diff] [blame] | 235 | gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 236 | } |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 237 | |
| 238 | IOThread::~IOThread() { |
| 239 | // We cannot rely on our base class to stop the thread since we want our |
| 240 | // CleanUp function to run. |
| 241 | Stop(); |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 242 | DCHECK(!globals_); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 243 | } |
| 244 | |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 245 | IOThread::Globals* IOThread::globals() { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 246 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 247 | return globals_; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 248 | } |
| 249 | |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 250 | ChromeNetLog* IOThread::net_log() { |
| 251 | return net_log_; |
| 252 | } |
| 253 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 254 | void IOThread::InitNetworkPredictor( |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 255 | bool prefetching_enabled, |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 256 | base::TimeDelta max_dns_queue_delay, |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 257 | size_t max_speculative_parallel_resolves, |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 258 | const chrome_common_net::UrlList& startup_urls, |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 259 | ListValue* referral_list, |
| 260 | bool preconnect_enabled) { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 261 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 262 | message_loop()->PostTask( |
| 263 | FROM_HERE, |
| 264 | NewRunnableMethod( |
| 265 | this, |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 266 | &IOThread::InitNetworkPredictorOnIOThread, |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 267 | prefetching_enabled, max_dns_queue_delay, |
| 268 | max_speculative_parallel_resolves, |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 269 | startup_urls, referral_list, preconnect_enabled)); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 270 | } |
| 271 | |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 272 | void IOThread::RegisterURLRequestContextGetter( |
| 273 | ChromeURLRequestContextGetter* url_request_context_getter) { |
| 274 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 275 | std::list<ChromeURLRequestContextGetter*>::const_iterator it = |
| 276 | std::find(url_request_context_getters_.begin(), |
| 277 | url_request_context_getters_.end(), |
| 278 | url_request_context_getter); |
| 279 | DCHECK(it == url_request_context_getters_.end()); |
| 280 | url_request_context_getters_.push_back(url_request_context_getter); |
| 281 | } |
| 282 | |
| 283 | void IOThread::UnregisterURLRequestContextGetter( |
| 284 | ChromeURLRequestContextGetter* url_request_context_getter) { |
| 285 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 286 | std::list<ChromeURLRequestContextGetter*>::iterator it = |
| 287 | std::find(url_request_context_getters_.begin(), |
| 288 | url_request_context_getters_.end(), |
| 289 | url_request_context_getter); |
| 290 | DCHECK(it != url_request_context_getters_.end()); |
| 291 | // This does not scale, but we shouldn't have many URLRequestContextGetters in |
| 292 | // the first place, so this should be fine. |
| 293 | url_request_context_getters_.erase(it); |
| 294 | } |
| 295 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 296 | void IOThread::ChangedToOnTheRecord() { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 297 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 298 | message_loop()->PostTask( |
| 299 | FROM_HERE, |
| 300 | NewRunnableMethod( |
| 301 | this, |
| 302 | &IOThread::ChangedToOnTheRecordOnIOThread)); |
| 303 | } |
| 304 | |
[email protected] | df2840d | 2011-02-20 16:32:32 | [diff] [blame] | 305 | void IOThread::ClearNetworkingHistory() { |
| 306 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 307 | ClearHostCache(); |
| 308 | // Discard acrued data used to speculate in the future. |
| 309 | chrome_browser_net::DiscardInitialNavigationHistory(); |
| 310 | if (predictor_) |
| 311 | predictor_->DiscardAllResults(); |
| 312 | } |
| 313 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 314 | void IOThread::Init() { |
[email protected] | ba74b0d2 | 2010-10-23 05:19:20 | [diff] [blame] | 315 | // Though this thread is called the "IO" thread, it actually just routes |
| 316 | // messages around; it shouldn't be allowed to perform any blocking disk I/O. |
| 317 | base::ThreadRestrictions::SetIOAllowed(false); |
[email protected] | ba74b0d2 | 2010-10-23 05:19:20 | [diff] [blame] | 318 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 319 | BrowserProcessSubThread::Init(); |
| 320 | |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 321 | DCHECK_EQ(MessageLoop::TYPE_IO, message_loop()->type()); |
| 322 | |
| 323 | #if defined(USE_NSS) |
| 324 | net::SetMessageLoopForOCSP(); |
[email protected] | ecd95ae | 2010-10-20 23:58:17 | [diff] [blame] | 325 | #endif // defined(USE_NSS) |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 326 | |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 327 | DCHECK(!globals_); |
| 328 | globals_ = new Globals; |
| 329 | |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 330 | // Add an observer that will emit network change events to the ChromeNetLog. |
| 331 | // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
| 332 | // logging the network change before other IO thread consumers respond to it. |
| 333 | network_change_observer_.reset( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 334 | new LoggingNetworkChangeObserver(net_log_)); |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 335 | |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame^] | 336 | globals_->extension_event_router_forwarder = |
| 337 | extension_event_router_forwarder_; |
| 338 | globals_->system_network_delegate.reset(new ChromeNetworkDelegate( |
| 339 | extension_event_router_forwarder_, Profile::kInvalidProfileId)); |
[email protected] | 73c4532 | 2010-10-01 23:57:54 | [diff] [blame] | 340 | globals_->host_resolver.reset( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 341 | CreateGlobalHostResolver(net_log_)); |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 342 | globals_->cert_verifier.reset(new net::CertVerifier); |
[email protected] | 2db58053 | 2010-10-08 14:32:37 | [diff] [blame] | 343 | globals_->dnsrr_resolver.reset(new net::DnsRRResolver); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 344 | // TODO(willchan): Use the real SSLConfigService. |
| 345 | globals_->ssl_config_service = |
| 346 | net::SSLConfigService::CreateSystemSSLConfigService(); |
[email protected] | 65d3438 | 2010-07-01 18:12:26 | [diff] [blame] | 347 | globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
[email protected] | 73c4532 | 2010-10-01 23:57:54 | [diff] [blame] | 348 | globals_->host_resolver.get())); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 349 | // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 350 | globals_->proxy_script_fetcher_proxy_service = |
| 351 | net::ProxyService::CreateDirectWithNetLog(net_log_); |
[email protected] | 9e1bdd3 | 2011-02-03 21:48:34 | [diff] [blame] | 352 | net::HttpNetworkSession::Params session_params; |
| 353 | session_params.host_resolver = globals_->host_resolver.get(); |
| 354 | session_params.cert_verifier = globals_->cert_verifier.get(); |
| 355 | session_params.proxy_service = |
| 356 | globals_->proxy_script_fetcher_proxy_service.get(); |
| 357 | session_params.http_auth_handler_factory = |
| 358 | globals_->http_auth_handler_factory.get(); |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 359 | session_params.network_delegate = globals_->system_network_delegate.get(); |
[email protected] | 9e1bdd3 | 2011-02-03 21:48:34 | [diff] [blame] | 360 | session_params.net_log = net_log_; |
| 361 | session_params.ssl_config_service = globals_->ssl_config_service; |
[email protected] | 57cb0f7 | 2011-01-28 06:33:58 | [diff] [blame] | 362 | scoped_refptr<net::HttpNetworkSession> network_session( |
[email protected] | 9e1bdd3 | 2011-02-03 21:48:34 | [diff] [blame] | 363 | new net::HttpNetworkSession(session_params)); |
[email protected] | 57cb0f7 | 2011-01-28 06:33:58 | [diff] [blame] | 364 | globals_->proxy_script_fetcher_http_transaction_factory.reset( |
| 365 | new net::HttpNetworkLayer(network_session)); |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 366 | |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 367 | scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context = |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 368 | ConstructProxyScriptFetcherContext(globals_, net_log_); |
| 369 | globals_->proxy_script_fetcher_context = proxy_script_fetcher_context; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 370 | } |
| 371 | |
[email protected] | 2a92cd9 | 2010-04-27 00:01:41 | [diff] [blame] | 372 | void IOThread::CleanUp() { |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 373 | // Step 1: Kill all things that might be holding onto |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 374 | // net::URLRequest/net::URLRequestContexts. |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 375 | |
[email protected] | 59a3b36 | 2010-10-21 21:52:41 | [diff] [blame] | 376 | #if defined(USE_NSS) |
| 377 | net::ShutdownOCSP(); |
| 378 | #endif // defined(USE_NSS) |
| 379 | |
[email protected] | 0b1ad31 | 2010-10-22 01:01:38 | [diff] [blame] | 380 | // Destroy all URLRequests started by URLFetchers. |
| 381 | URLFetcher::CancelAll(); |
| 382 | |
[email protected] | 5377d89 | 2011-01-21 18:25:43 | [diff] [blame] | 383 | IndexedDBKeyUtilityClient::Shutdown(); |
| 384 | |
[email protected] | 325a71f | 2010-05-21 23:05:27 | [diff] [blame] | 385 | // If any child processes are still running, terminate them and |
[email protected] | d27893f6 | 2010-07-03 05:47:42 | [diff] [blame] | 386 | // and delete the BrowserChildProcessHost instances to release whatever |
[email protected] | 325a71f | 2010-05-21 23:05:27 | [diff] [blame] | 387 | // IO thread only resources they are referencing. |
[email protected] | d27893f6 | 2010-07-03 05:47:42 | [diff] [blame] | 388 | BrowserChildProcessHost::TerminateAll(); |
[email protected] | 325a71f | 2010-05-21 23:05:27 | [diff] [blame] | 389 | |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 390 | std::list<ChromeURLRequestContextGetter*> url_request_context_getters; |
| 391 | url_request_context_getters.swap(url_request_context_getters_); |
| 392 | for (std::list<ChromeURLRequestContextGetter*>::iterator it = |
| 393 | url_request_context_getters.begin(); |
| 394 | it != url_request_context_getters.end(); ++it) { |
| 395 | ChromeURLRequestContextGetter* getter = *it; |
[email protected] | 361fe8a | 2010-11-24 17:20:49 | [diff] [blame] | 396 | // Stop all pending certificate provenance check uploads |
| 397 | net::DnsCertProvenanceChecker* checker = |
| 398 | getter->GetURLRequestContext()->dns_cert_checker(); |
| 399 | if (checker) |
| 400 | checker->Shutdown(); |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 401 | getter->ReleaseURLRequestContext(); |
| 402 | } |
| 403 | |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 404 | // Step 2: Release objects that the net::URLRequestContext could have been |
| 405 | // pointing to. |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 406 | |
| 407 | // This must be reset before the ChromeNetLog is destroyed. |
| 408 | network_change_observer_.reset(); |
| 409 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 410 | // Not initialized in Init(). May not be initialized. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 411 | if (predictor_) { |
| 412 | predictor_->Shutdown(); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 413 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 414 | // TODO(willchan): Stop reference counting Predictor. It's owned by |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 415 | // IOThread now. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 416 | predictor_->Release(); |
| 417 | predictor_ = NULL; |
| 418 | chrome_browser_net::FreePredictorResources(); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 419 | } |
| 420 | |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 421 | // Deletion will unregister this interceptor. |
| 422 | delete speculative_interceptor_; |
| 423 | speculative_interceptor_ = NULL; |
| 424 | |
[email protected] | e4d2dd82 | 2010-02-05 20:57:33 | [diff] [blame] | 425 | // TODO(eroman): hack for http://crbug.com/15513 |
[email protected] | 970210c | 2010-02-19 20:27:02 | [diff] [blame] | 426 | if (globals_->host_resolver->GetAsHostResolverImpl()) { |
| 427 | globals_->host_resolver.get()->GetAsHostResolverImpl()->Shutdown(); |
[email protected] | e4d2dd82 | 2010-02-05 20:57:33 | [diff] [blame] | 428 | } |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 429 | |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 430 | delete globals_; |
| 431 | globals_ = NULL; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 432 | |
[email protected] | 2a92cd9 | 2010-04-27 00:01:41 | [diff] [blame] | 433 | BrowserProcessSubThread::CleanUp(); |
| 434 | } |
| 435 | |
| 436 | void IOThread::CleanUpAfterMessageLoopDestruction() { |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 437 | // This will delete the |notification_service_|. Make sure it's done after |
| 438 | // anything else can reference it. |
[email protected] | 9aa33e8 | 2010-04-15 00:15:39 | [diff] [blame] | 439 | BrowserProcessSubThread::CleanUpAfterMessageLoopDestruction(); |
[email protected] | 4411da94 | 2010-10-25 15:06:02 | [diff] [blame] | 440 | |
[email protected] | 6981d963 | 2010-11-30 21:34:02 | [diff] [blame] | 441 | // net::URLRequest instances must NOT outlive the IO thread. |
[email protected] | 4411da94 | 2010-10-25 15:06:02 | [diff] [blame] | 442 | // |
| 443 | // To allow for URLRequests to be deleted from |
| 444 | // MessageLoop::DestructionObserver this check has to happen after CleanUp |
| 445 | // (which runs before DestructionObservers). |
[email protected] | 6981d963 | 2010-11-30 21:34:02 | [diff] [blame] | 446 | base::debug::LeakTracker<net::URLRequest>::CheckForLeaks(); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 447 | } |
| 448 | |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 449 | // static |
| 450 | void IOThread::RegisterPrefs(PrefService* local_state) { |
| 451 | local_state->RegisterStringPref(prefs::kAuthSchemes, |
| 452 | "basic,digest,ntlm,negotiate"); |
| 453 | local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, |
| 454 | false); |
| 455 | local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); |
| 456 | local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); |
| 457 | local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); |
[email protected] | ac7f3fdb | 2010-11-12 12:47:05 | [diff] [blame] | 458 | local_state->RegisterStringPref(prefs::kGSSAPILibraryName, ""); |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 459 | } |
| 460 | |
[email protected] | 65d3438 | 2010-07-01 18:12:26 | [diff] [blame] | 461 | net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( |
| 462 | net::HostResolver* resolver) { |
[email protected] | 9030a63 | 2010-11-19 20:12:09 | [diff] [blame] | 463 | net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; |
| 464 | if (!auth_server_whitelist_.empty()) { |
| 465 | auth_filter_default_credentials = |
| 466 | new net::HttpAuthFilterWhitelist(auth_server_whitelist_); |
| 467 | } |
| 468 | net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; |
| 469 | if (!auth_delegate_whitelist_.empty()) { |
| 470 | auth_filter_delegate = |
| 471 | new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); |
| 472 | } |
[email protected] | b4955e7d | 2010-04-16 20:22:30 | [diff] [blame] | 473 | globals_->url_security_manager.reset( |
[email protected] | d201b200e | 2010-08-27 17:35:02 | [diff] [blame] | 474 | net::URLSecurityManager::Create(auth_filter_default_credentials, |
| 475 | auth_filter_delegate)); |
[email protected] | b730416 | 2010-08-23 17:42:29 | [diff] [blame] | 476 | std::vector<std::string> supported_schemes; |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 477 | base::SplitString(auth_schemes_, ',', &supported_schemes); |
[email protected] | b730416 | 2010-08-23 17:42:29 | [diff] [blame] | 478 | |
| 479 | return net::HttpAuthHandlerRegistryFactory::Create( |
| 480 | supported_schemes, |
| 481 | globals_->url_security_manager.get(), |
| 482 | resolver, |
[email protected] | ac7f3fdb | 2010-11-12 12:47:05 | [diff] [blame] | 483 | gssapi_library_name_, |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 484 | negotiate_disable_cname_lookup_, |
| 485 | negotiate_enable_port_); |
[email protected] | eb3cac7 | 2010-02-26 21:07:45 | [diff] [blame] | 486 | } |
| 487 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 488 | void IOThread::InitNetworkPredictorOnIOThread( |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 489 | bool prefetching_enabled, |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 490 | base::TimeDelta max_dns_queue_delay, |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 491 | size_t max_speculative_parallel_resolves, |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 492 | const chrome_common_net::UrlList& startup_urls, |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 493 | ListValue* referral_list, |
| 494 | bool preconnect_enabled) { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 495 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 496 | CHECK(!predictor_); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 497 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 498 | chrome_browser_net::EnablePredictor(prefetching_enabled); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 499 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 500 | predictor_ = new chrome_browser_net::Predictor( |
[email protected] | 73c4532 | 2010-10-01 23:57:54 | [diff] [blame] | 501 | globals_->host_resolver.get(), |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 502 | max_dns_queue_delay, |
[email protected] | 755a9335 | 2010-10-29 06:33:59 | [diff] [blame] | 503 | max_speculative_parallel_resolves, |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 504 | preconnect_enabled); |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 505 | predictor_->AddRef(); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 506 | |
[email protected] | f4ef861ba | 2010-07-28 22:37:23 | [diff] [blame] | 507 | // Speculative_interceptor_ is used to predict subresource usage. |
| 508 | DCHECK(!speculative_interceptor_); |
| 509 | speculative_interceptor_ = new chrome_browser_net::ConnectInterceptor; |
| 510 | |
[email protected] | bff1f51 | 2010-08-15 15:13:49 | [diff] [blame] | 511 | FinalizePredictorInitialization(predictor_, startup_urls, referral_list); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | void IOThread::ChangedToOnTheRecordOnIOThread() { |
[email protected] | f8b3ef8 | 2010-10-11 02:45:52 | [diff] [blame] | 515 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 516 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 517 | if (predictor_) { |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 518 | // Destroy all evidence of our OTR session. |
[email protected] | df2840d | 2011-02-20 16:32:32 | [diff] [blame] | 519 | // Note: OTR mode never saves InitialNavigationHistory data. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 520 | predictor_->Predictor::DiscardAllResults(); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | // Clear the host cache to avoid showing entries from the OTR session |
| 524 | // in about:net-internals. |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 525 | ClearHostCache(); |
| 526 | |
| 527 | // Clear all of the passively logged data. |
| 528 | // TODO(eroman): this is a bit heavy handed, really all we need to do is |
| 529 | // clear the data pertaining to off the record context. |
| 530 | net_log_->ClearAllPassivelyCapturedEvents(); |
| 531 | } |
| 532 | |
| 533 | void IOThread::ClearHostCache() { |
| 534 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 535 | |
[email protected] | 970210c | 2010-02-19 20:27:02 | [diff] [blame] | 536 | if (globals_->host_resolver->GetAsHostResolverImpl()) { |
| 537 | net::HostCache* host_cache = |
| 538 | globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); |
[email protected] | f2d8c421 | 2010-02-02 00:56:35 | [diff] [blame] | 539 | if (host_cache) |
| 540 | host_cache->clear(); |
| 541 | } |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 542 | } |