diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-15 16:19:41 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-15 16:19:41 +0000 |
commit | 98cce3ae84da129cb7d44c63ac0c54bef2d11556 (patch) | |
tree | fd4b5ca2cfd58362d2d6bf07da4fd89e6b70074e /content/shell | |
parent | 3e4812802665a1794f5457e340e740ef1e690ff9 (diff) | |
download | chromium_src-98cce3ae84da129cb7d44c63ac0c54bef2d11556.zip chromium_src-98cce3ae84da129cb7d44c63ac0c54bef2d11556.tar.gz chromium_src-98cce3ae84da129cb7d44c63ac0c54bef2d11556.tar.bz2 |
Make content_shell not crash on startup.
BUG=100422
Review URL: http://codereview.chromium.org/8302018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r-- | content/shell/shell_url_request_context_getter.cc | 107 | ||||
-rw-r--r-- | content/shell/shell_url_request_context_getter.h | 22 |
2 files changed, 50 insertions, 79 deletions
diff --git a/content/shell/shell_url_request_context_getter.cc b/content/shell/shell_url_request_context_getter.cc index f3e1c99..a6ba692 100644 --- a/content/shell/shell_url_request_context_getter.cc +++ b/content/shell/shell_url_request_context_getter.cc @@ -13,12 +13,13 @@ #include "net/base/dnsrr_resolver.h" #include "net/base/host_resolver.h" #include "net/http/http_auth_handler_factory.h" +#include "net/http/http_server_properties_impl.h" #include "net/http/http_cache.h" #include "net/base/origin_bound_cert_service.h" #include "net/base/ssl_config_service_defaults.h" #include "net/proxy/proxy_service.h" #include "net/url_request/url_request_context.h" -#include "net/url_request/url_request_context_getter.h" +#include "net/url_request/url_request_context_storage.h" #include "net/url_request/url_request_job_factory.h" namespace content { @@ -38,80 +39,62 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!url_request_context_) { - FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache")); - net::HttpCache::DefaultBackend* main_backend = - new net::HttpCache::DefaultBackend( - net::DISK_CACHE, - cache_path, - 0, - BrowserThread::GetMessageLoopProxyForThread( - BrowserThread::CACHE)); - - net::NetLog* net_log = NULL; - host_resolver_.reset(net::CreateSystemHostResolver( - net::HostResolver::kDefaultParallelism, - net::HostResolver::kDefaultRetryAttempts, - net_log)); - - cert_verifier_.reset(new net::CertVerifier()); + url_request_context_ = new net::URLRequestContext(); + storage_.reset(new net::URLRequestContextStorage(url_request_context_)); - origin_bound_cert_service_.reset(new net::OriginBoundCertService( + storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); + storage_->set_origin_bound_cert_service(new net::OriginBoundCertService( new net::DefaultOriginBoundCertStore(NULL))); + url_request_context_->set_accept_language("en-us,en"); + url_request_context_->set_accept_charset("iso-8859-1,*,utf-8"); - dnsrr_resolver_.reset(new net::DnsRRResolver()); - - net::ProxyConfigService* proxy_config_service = + scoped_ptr<net::ProxyConfigService> proxy_config_service( net::ProxyService::CreateSystemProxyConfigService( - io_loop_, - file_loop_); - + io_loop_, file_loop_)); + storage_->set_host_resolver( + net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, + net::HostResolver::kDefaultRetryAttempts, + NULL)); + storage_->set_cert_verifier(new net::CertVerifier); // TODO(jam): use v8 if possible, look at chrome code. - proxy_service_.reset( + storage_->set_proxy_service( net::ProxyService::CreateUsingSystemProxyResolver( - proxy_config_service, + proxy_config_service.release(), 0, - net_log)); + NULL)); + storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); + storage_->set_http_auth_handler_factory( + net::HttpAuthHandlerFactory::CreateDefault( + url_request_context_->host_resolver())); + storage_->set_http_server_properties(new net::HttpServerPropertiesImpl); - url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL)); + FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache")); + net::HttpCache::DefaultBackend* main_backend = + new net::HttpCache::DefaultBackend( + net::DISK_CACHE, + cache_path, + 0, + BrowserThread::GetMessageLoopProxyForThread( + BrowserThread::CACHE)); - std::vector<std::string> supported_schemes; - base::SplitString("basic,digest,ntlm,negotiate", ',', &supported_schemes); - http_auth_handler_factory_.reset( - net::HttpAuthHandlerRegistryFactory::Create( - supported_schemes, - url_security_manager_.get(), - host_resolver_.get(), - std::string(), // gssapi_library_name - false, // negotiate_disable_cname_lookup - false)); // negotiate_enable_port + storage_->set_dnsrr_resolver(new net::DnsRRResolver()); net::HttpCache* main_cache = new net::HttpCache( - host_resolver_.get(), - cert_verifier_.get(), - origin_bound_cert_service_.get(), - dnsrr_resolver_.get(), + url_request_context_->host_resolver(), + url_request_context_->cert_verifier(), + url_request_context_->origin_bound_cert_service(), + url_request_context_->dnsrr_resolver(), NULL, //dns_cert_checker - proxy_service_.get(), - new net::SSLConfigServiceDefaults(), - http_auth_handler_factory_.get(), + url_request_context_->proxy_service(), + url_request_context_->ssl_config_service(), + url_request_context_->http_auth_handler_factory(), NULL, // network_delegate - NULL, // http_server_properties - net_log, + url_request_context_->http_server_properties(), + NULL, main_backend); - main_http_factory_.reset(main_cache); - - scoped_refptr<net::CookieStore> cookie_store = - new net::CookieMonster(NULL, NULL); + storage_->set_http_transaction_factory(main_cache); - url_request_context_ = new net::URLRequestContext(); - job_factory_.reset(new net::URLRequestJobFactory); - url_request_context_->set_job_factory(job_factory_.get()); - url_request_context_->set_http_transaction_factory(main_cache); - url_request_context_->set_origin_bound_cert_service( - origin_bound_cert_service_.get()); - url_request_context_->set_dnsrr_resolver(dnsrr_resolver_.get()); - url_request_context_->set_proxy_service(proxy_service_.get()); - url_request_context_->set_cookie_store(cookie_store); + storage_->set_job_factory(new net::URLRequestJobFactory); } return url_request_context_; @@ -129,4 +112,8 @@ scoped_refptr<base::MessageLoopProxy> return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } +net::HostResolver* ShellURLRequestContextGetter::host_resolver() { + return url_request_context_->host_resolver(); +} + } // namespace content diff --git a/content/shell/shell_url_request_context_getter.h b/content/shell/shell_url_request_context_getter.h index a4ba171..7db1dbe 100644 --- a/content/shell/shell_url_request_context_getter.h +++ b/content/shell/shell_url_request_context_getter.h @@ -15,15 +15,8 @@ class MessageLoop; namespace net { -class CertVerifier; -class DnsRRResolver; class HostResolver; -class HttpAuthHandlerFactory; -class HttpTransactionFactory; -class ProxyService; -class OriginBoundCertService; -class URLRequestJobFactory; -class URLSecurityManager; +class URLRequestContextStorage; } namespace content { @@ -42,24 +35,15 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter { virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const OVERRIDE; - net::HostResolver* host_resolver() { return host_resolver_.get(); } + net::HostResolver* host_resolver(); private: FilePath base_path_; MessageLoop* io_loop_; MessageLoop* file_loop_; - scoped_ptr<net::URLRequestJobFactory> job_factory_; scoped_refptr<net::URLRequestContext> url_request_context_; - - scoped_ptr<net::HttpTransactionFactory> main_http_factory_; - scoped_ptr<net::HostResolver> host_resolver_; - scoped_ptr<net::CertVerifier> cert_verifier_; - scoped_ptr<net::OriginBoundCertService> origin_bound_cert_service_; - scoped_ptr<net::DnsRRResolver> dnsrr_resolver_; - scoped_ptr<net::ProxyService> proxy_service_; - scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_; - scoped_ptr<net::URLSecurityManager> url_security_manager_; + scoped_ptr<net::URLRequestContextStorage> storage_; DISALLOW_COPY_AND_ASSIGN(ShellURLRequestContextGetter); }; |