diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 01:08:03 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 01:08:03 +0000 |
commit | c5f1e3380f1e1b904420d6072f92484daf497a65 (patch) | |
tree | fd41400cc8ac32b90d1817bcd36cb6aa47842af7 /content/shell/shell_browser_context.cc | |
parent | 5a3432f63636a3d05d73da60c54e83d2c77b57a3 (diff) | |
download | chromium_src-c5f1e3380f1e1b904420d6072f92484daf497a65.zip chromium_src-c5f1e3380f1e1b904420d6072f92484daf497a65.tar.gz chromium_src-c5f1e3380f1e1b904420d6072f92484daf497a65.tar.bz2 |
Split off content_shell's ResourceContext and URLRequestContextGetter implementations into separate files to improve readability.BUG=90445
Review URL: http://codereview.chromium.org/8037037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell/shell_browser_context.cc')
-rw-r--r-- | content/shell/shell_browser_context.cc | 165 |
1 files changed, 2 insertions, 163 deletions
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index b49f758..91c51c8 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -7,7 +7,6 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/string_split.h" #include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/browser_thread.h" #include "content/browser/chrome_blob_storage_context.h" @@ -18,22 +17,10 @@ #include "content/browser/geolocation/geolocation_permission_context.h" #include "content/browser/host_zoom_map.h" #include "content/browser/in_process_webkit/webkit_context.h" -#include "content/browser/resource_context.h" #include "content/browser/ssl/ssl_host_state.h" #include "content/shell/shell_browser_main.h" -#include "net/base/cert_verifier.h" -#include "net/base/cookie_monster.h" -#include "net/base/default_origin_bound_cert_store.h" -#include "net/base/dnsrr_resolver.h" -#include "net/base/host_resolver.h" -#include "net/http/http_auth_handler_factory.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_job_factory.h" +#include "content/shell/shell_resource_context.h" +#include "content/shell/shell_url_request_context_getter.h" #include "webkit/database/database_tracker.h" #include "webkit/quota/quota_manager.h" @@ -43,154 +30,6 @@ namespace { -class ShellURLRequestContextGetter : public net::URLRequestContextGetter { - public: - ShellURLRequestContextGetter( - const FilePath& base_path_, - MessageLoop* io_loop, - MessageLoop* file_loop) - : io_loop_(io_loop), - file_loop_(file_loop) { - } - - // net::URLRequestContextGetter implementation. - virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE { - 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()); - - origin_bound_cert_service_.reset(new net::OriginBoundCertService( - new net::DefaultOriginBoundCertStore(NULL))); - - dnsrr_resolver_.reset(new net::DnsRRResolver()); - - net::ProxyConfigService* proxy_config_service = - net::ProxyService::CreateSystemProxyConfigService( - io_loop_, - file_loop_); - - // TODO(jam): use v8 if possible, look at chrome code. - proxy_service_.reset( - net::ProxyService::CreateUsingSystemProxyResolver( - proxy_config_service, - 0, - net_log)); - - url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL)); - - 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 - - net::HttpCache* main_cache = new net::HttpCache( - host_resolver_.get(), - cert_verifier_.get(), - origin_bound_cert_service_.get(), - dnsrr_resolver_.get(), - NULL, //dns_cert_checker - proxy_service_.get(), - new net::SSLConfigServiceDefaults(), - http_auth_handler_factory_.get(), - NULL, // network_delegate - net_log, - main_backend); - main_http_factory_.reset(main_cache); - - scoped_refptr<net::CookieStore> cookie_store = - new net::CookieMonster(NULL, NULL); - - 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); - } - - return url_request_context_; - } - - virtual net::CookieStore* DONTUSEME_GetCookieStore() OVERRIDE { - if (BrowserThread::CurrentlyOn(BrowserThread::IO)) - return GetURLRequestContext()->cookie_store(); - NOTIMPLEMENTED(); - return NULL; - } - - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const OVERRIDE { - return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); - } - - net::HostResolver* host_resolver() { return host_resolver_.get(); } - - 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_; -}; - -class ShellResourceContext : public content::ResourceContext { - public: - ShellResourceContext(ShellURLRequestContextGetter* getter, - ChromeBlobStorageContext* blob_storage_context) - : getter_(getter), - blob_storage_context_(blob_storage_context) { - } - - private: - virtual void EnsureInitialized() const OVERRIDE { - const_cast<ShellResourceContext*>(this)->InitializeInternal(); - } - - void InitializeInternal() { - set_request_context(getter_->GetURLRequestContext()); - set_host_resolver(getter_->host_resolver()); - set_blob_storage_context(blob_storage_context_); - } - - scoped_refptr<ShellURLRequestContextGetter> getter_; - scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; -}; - class ShellGeolocationPermissionContext : public GeolocationPermissionContext { public: ShellGeolocationPermissionContext() { |