Chromium Code Reviews| Index: android_webview/browser/net/aw_url_request_context_getter.cc |
| diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc |
| index f80f0c2450bee85895c77d5e100bf7427a7cbb0c..6d77989af5e5427fd18b69b20e6d3e6c59cef338 100644 |
| --- a/android_webview/browser/net/aw_url_request_context_getter.cc |
| +++ b/android_webview/browser/net/aw_url_request_context_getter.cc |
| @@ -11,7 +11,6 @@ |
| #include "android_webview/browser/net/init_native_callback.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/content_browser_client.h" |
| -#include "content/public/browser/resource_context.h" |
| #include "content/public/common/content_client.h" |
| #include "content/public/common/url_constants.h" |
| #include "net/http/http_cache.h" |
| @@ -26,40 +25,6 @@ using content::BrowserThread; |
| namespace android_webview { |
| -namespace { |
| - |
| -class AwResourceContext : public content::ResourceContext { |
| - public: |
| - AwResourceContext(net::URLRequestContext* getter); |
| - virtual ~AwResourceContext(); |
| - virtual net::HostResolver* GetHostResolver() OVERRIDE; |
| - virtual net::URLRequestContext* GetRequestContext() OVERRIDE; |
| - |
| - private: |
| - net::URLRequestContext* context_; // weak |
| - |
| - DISALLOW_COPY_AND_ASSIGN(AwResourceContext); |
| -}; |
| - |
| -AwResourceContext::AwResourceContext(net::URLRequestContext* context) |
| - : context_(context) { |
| -} |
| - |
| -AwResourceContext::~AwResourceContext() { |
| -} |
| - |
| -net::HostResolver* AwResourceContext::GetHostResolver() { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - return context_->host_resolver(); |
| -} |
| - |
| -net::URLRequestContext* AwResourceContext::GetRequestContext() { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - return context_; |
| -} |
| - |
| -} // namespace |
| - |
| AwURLRequestContextGetter::AwURLRequestContextGetter( |
| AwBrowserContext* browser_context) |
| : browser_context_(browser_context), |
| @@ -95,14 +60,6 @@ void AwURLRequestContextGetter::Init() { |
| url_request_context_.reset(builder.Build()); |
| - scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); |
| - bool set_protocol = job_factory->SetProtocolHandler( |
| - chrome::kFileScheme, new net::FileProtocolHandler()); |
| - DCHECK(set_protocol); |
| - set_protocol = job_factory->SetProtocolHandler( |
| - chrome::kDataScheme, new net::DataProtocolHandler()); |
| - DCHECK(set_protocol); |
| - |
| // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
| net::HttpNetworkSession::Params network_session_params; |
| PopulateNetworkSessionParams(&network_session_params); |
| @@ -115,14 +72,6 @@ void AwURLRequestContextGetter::Init() { |
| BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
| main_http_factory_.reset(main_cache); |
| url_request_context_->set_http_transaction_factory(main_cache); |
| - |
| - job_factory_ = CreateAndroidJobFactoryAndCookieMonster( |
| - url_request_context_.get(), job_factory.Pass()); |
| - job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| - job_factory_.Pass(), |
| - scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| - new AwRequestInterceptor()))); |
| - url_request_context_->set_job_factory(job_factory_.get()); |
| } |
| void AwURLRequestContextGetter::PopulateNetworkSessionParams( |
| @@ -140,15 +89,44 @@ void AwURLRequestContextGetter::PopulateNetworkSessionParams( |
| params->net_log = context->net_log(); |
| } |
| -content::ResourceContext* AwURLRequestContextGetter::GetResourceContext() { |
| - DCHECK(url_request_context_); |
| - if (!resource_context_) |
| - resource_context_.reset(new AwResourceContext(url_request_context_.get())); |
| - return resource_context_.get(); |
| -} |
| - |
| net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| + if (!job_factory_) { |
| + scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory); |
| + bool set_protocol = job_factory->SetProtocolHandler( |
| + chrome::kFileScheme, new net::FileProtocolHandler()); |
| + DCHECK(set_protocol); |
| + set_protocol = job_factory->SetProtocolHandler( |
| + chrome::kDataScheme, new net::DataProtocolHandler()); |
| + DCHECK(set_protocol); |
| + DCHECK(blob_protocol_handler_); |
| + set_protocol = job_factory->SetProtocolHandler( |
| + chrome::kBlobScheme, blob_protocol_handler_.release()); |
| + DCHECK(set_protocol); |
| + DCHECK(file_system_protocol_handler_); |
| + set_protocol = job_factory->SetProtocolHandler( |
| + chrome::kFileSystemScheme, file_system_protocol_handler_.release()); |
| + DCHECK(set_protocol); |
| + DCHECK(chrome_protocol_handler_); |
| + set_protocol = job_factory->SetProtocolHandler( |
| + chrome::kChromeUIScheme, chrome_protocol_handler_.release()); |
| + DCHECK(set_protocol); |
| + DCHECK(chrome_devtools_protocol_handler_); |
| + set_protocol = job_factory->SetProtocolHandler( |
| + chrome::kChromeDevToolsScheme, |
| + chrome_devtools_protocol_handler_.release()); |
| + DCHECK(set_protocol); |
| + job_factory_ = CreateAndroidJobFactoryAndCookieMonster( |
|
joth
2013/02/07 00:41:41
maybe a comment here explaining this creates a cha
pauljensen
2013/02/07 14:10:54
Done.
|
| + url_request_context_.get(), job_factory.Pass()); |
| + job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| + job_factory_.Pass(), |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
| + new AwRequestInterceptor()))); |
| + job_factory_.reset(new net::ProtocolInterceptJobFactory( |
| + job_factory_.Pass(), |
| + developer_protocol_handler_.Pass())); |
| + url_request_context_->set_job_factory(job_factory_.get()); |
| + } |
| return url_request_context_.get(); |
| } |
| @@ -157,4 +135,22 @@ AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
| return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| } |
| +void AwURLRequestContextGetter::SetProtocolHandlers( |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + blob_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + file_system_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + developer_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + chrome_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + chrome_devtools_protocol_handler) { |
| + blob_protocol_handler_ = blob_protocol_handler.Pass(); |
| + file_system_protocol_handler_ = file_system_protocol_handler.Pass(); |
| + developer_protocol_handler_ = developer_protocol_handler.Pass(); |
| + chrome_protocol_handler_ = chrome_protocol_handler.Pass(); |
| + chrome_devtools_protocol_handler_ = chrome_devtools_protocol_handler.Pass(); |
| +} |
| + |
| } // namespace android_webview |