Chromium Code Reviews| Index: chrome/browser/io_thread.cc |
| diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc |
| index 1b1acf20296841c4760cb9dc697559a855bb859a..238121d9df23d72049378b228540a723107eb596 100644 |
| --- a/chrome/browser/io_thread.cc |
| +++ b/chrome/browser/io_thread.cc |
| @@ -37,6 +37,8 @@ |
| #include "net/base/net_util.h" |
| #include "net/http/http_auth_filter.h" |
| #include "net/http/http_auth_handler_factory.h" |
| +#include "net/http/http_cache.h" |
| +#include "net/http/http_network_layer.h" |
| #if defined(USE_NSS) |
| #include "net/ocsp/nss_ocsp.h" |
| #endif // defined(USE_NSS) |
| @@ -174,35 +176,33 @@ class LoggingNetworkChangeObserver |
| DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); |
| }; |
| -} // namespace |
| - |
| -// This is a wrapper class around ProxyScriptFetcherImpl that will |
| -// keep track of live instances. |
| -class IOThread::ManagedProxyScriptFetcher |
| - : public net::ProxyScriptFetcherImpl { |
| - public: |
| - ManagedProxyScriptFetcher(URLRequestContext* context, |
| - IOThread* io_thread) |
| - : net::ProxyScriptFetcherImpl(context), |
| - io_thread_(io_thread) { |
| - DCHECK(!ContainsKey(*fetchers(), this)); |
| - fetchers()->insert(this); |
| - } |
| - |
| - virtual ~ManagedProxyScriptFetcher() { |
| - DCHECK(ContainsKey(*fetchers(), this)); |
| - fetchers()->erase(this); |
| - } |
| - |
| - private: |
| - ProxyScriptFetchers* fetchers() { |
| - return &io_thread_->fetchers_; |
| - } |
| - |
| - IOThread* io_thread_; |
| +void InitializeProxyRequestContext(IOThread::Globals* globals, |
|
eroman
2010/12/22 01:27:56
See my naming comment.
willchan no longer on Chromium
2010/12/22 02:35:07
Done.
|
| + net::NetLog* net_log, |
| + URLRequestContext* context) { |
| + context->set_net_log(net_log); |
| + context->set_host_resolver(globals->host_resolver.get()); |
| + context->set_cert_verifier(globals->cert_verifier.get()); |
| + context->set_dnsrr_resolver(globals->dnsrr_resolver.get()); |
| + context->set_http_auth_handler_factory( |
| + globals->http_auth_handler_factory.get()); |
| + context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); |
| + context->set_http_transaction_factory( |
| + new net::HttpCache( |
|
eroman
2010/12/22 01:27:56
We don't need to use an HttpCache here, since the
willchan no longer on Chromium
2010/12/22 02:35:07
Done.
|
| + globals->host_resolver.get(), |
| + globals->cert_verifier.get(), |
| + globals->dnsrr_resolver.get(), |
| + NULL /* dns_cert_checker */, |
| + globals->proxy_script_fetcher_proxy_service.get(), |
| + globals->ssl_config_service.get(), |
| + globals->http_auth_handler_factory.get(), |
| + &globals->network_delegate, |
| + net_log, |
| + net::HttpCache::DefaultBackend::InMemory(0))); |
| + // In-memory cookie store. |
| + context->set_cookie_store(new net::CookieMonster(NULL, NULL)); |
|
eroman
2010/12/22 01:27:56
I wander if this might cause some subtle compat is
|
| +} |
| - DISALLOW_COPY_AND_ASSIGN(ManagedProxyScriptFetcher); |
| -}; |
| +} // namespace |
| // The IOThread object must outlive any tasks posted to the IO thread before the |
| // Quit task. |
| @@ -301,11 +301,6 @@ void IOThread::ChangedToOnTheRecord() { |
| &IOThread::ChangedToOnTheRecordOnIOThread)); |
| } |
| -net::ProxyScriptFetcher* IOThread::CreateAndRegisterProxyScriptFetcher( |
| - URLRequestContext* url_request_context) { |
| - return new ManagedProxyScriptFetcher(url_request_context, this); |
| -} |
| - |
| void IOThread::Init() { |
| #if !defined(OS_CHROMEOS) |
| // TODO(evan): test and enable this on all platforms. |
| @@ -335,8 +330,18 @@ void IOThread::Init() { |
| CreateGlobalHostResolver(net_log_)); |
| globals_->cert_verifier.reset(new net::CertVerifier); |
| globals_->dnsrr_resolver.reset(new net::DnsRRResolver); |
| + // TODO(willchan): Use the real SSLConfigService. |
| + globals_->ssl_config_service = |
| + net::SSLConfigService::CreateSystemSSLConfigService(); |
| globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
| globals_->host_resolver.get())); |
| + // For the ProxyScriptFetcher, we use a direct ProxyService. |
| + globals_->proxy_script_fetcher_proxy_service = |
| + net::ProxyService::CreateDirectWithNetLog(net_log_); |
| + |
| + URLRequestContext* proxy_request_context = new URLRequestContext; |
|
eroman
2010/12/22 01:27:56
See my naming suggestion.
willchan no longer on Chromium
2010/12/22 02:35:07
Done.
|
| + InitializeProxyRequestContext(globals_, net_log_, proxy_request_context); |
|
eroman
2010/12/22 01:27:56
How about making this a "Create()" method instead?
willchan no longer on Chromium
2010/12/22 02:35:07
Done.
|
| + globals_->proxy_request_context = proxy_request_context; |
| if (CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kEnablePagePrerender)) { |
| @@ -355,23 +360,6 @@ void IOThread::CleanUp() { |
| // Destroy all URLRequests started by URLFetchers. |
| URLFetcher::CancelAll(); |
| - // Break any cycles between the ProxyScriptFetcher and URLRequestContext. |
| - for (ProxyScriptFetchers::const_iterator it = fetchers_.begin(); |
| - it != fetchers_.end();) { |
| - ManagedProxyScriptFetcher* fetcher = *it; |
| - { |
| - // Hang on to the context while cancelling to avoid problems |
| - // with the cancellation causing the context to be destroyed |
| - // (see http://crbug.com/63796 ). Ideally, the IOThread would |
| - // own the URLRequestContexts. |
| - scoped_refptr<URLRequestContext> context(fetcher->GetRequestContext()); |
| - fetcher->Cancel(); |
| - } |
| - // Any number of fetchers may have been deleted at this point, so |
| - // use upper_bound instead of a simple increment. |
| - it = fetchers_.upper_bound(fetcher); |
| - } |
| - |
| // If any child processes are still running, terminate them and |
| // and delete the BrowserChildProcessHost instances to release whatever |
| // IO thread only resources they are referencing. |