Chromium Code Reviews| Index: content/shell/shell_browser_context.cc |
| diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc |
| index 9eaa6b220d44593ce7023c6c75acd574af5479bc..5662d3f29624263150924cf3f717f5a8db99c8bf 100644 |
| --- a/content/shell/shell_browser_context.cc |
| +++ b/content/shell/shell_browser_context.cc |
| @@ -12,11 +12,11 @@ |
| #include "base/path_service.h" |
| #include "base/threading/thread.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/resource_context.h" |
| +#include "content/public/common/content_switches.h" |
| #include "content/shell/shell_download_manager_delegate.h" |
| -#include "content/shell/shell_resource_context.h" |
| #include "content/shell/shell_switches.h" |
| #include "content/shell/shell_url_request_context_getter.h" |
| -#include "content/public/common/content_switches.h" |
| #if defined(OS_WIN) |
| #include "base/base_paths_win.h" |
| @@ -28,9 +28,33 @@ |
| namespace content { |
| +class ShellBrowserContext::ShellResourceContext : public ResourceContext { |
| + public: |
| + ShellResourceContext() : getter_(NULL) {} |
| + virtual ~ShellResourceContext() {} |
| + |
| + private: |
| + friend class ShellBrowserContext; |
| + |
| + // ResourceContext implementation: |
| + virtual net::HostResolver* GetHostResolver() OVERRIDE { |
| + CHECK(getter_); |
| + return getter_->host_resolver(); |
| + } |
| + virtual net::URLRequestContext* GetRequestContext() OVERRIDE { |
| + CHECK(getter_); |
| + return getter_->GetURLRequestContext(); |
| + } |
| + |
| + ShellURLRequestContextGetter* getter_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ShellResourceContext); |
| +}; |
| + |
| ShellBrowserContext::ShellBrowserContext(bool off_the_record) |
| : off_the_record_(off_the_record), |
| - ignore_certificate_errors_(false) { |
| + ignore_certificate_errors_(false), |
| + resource_context_(new ShellResourceContext()) { |
| InitWhileIOAllowed(); |
| } |
| @@ -95,14 +119,28 @@ DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() { |
| } |
| net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { |
| - if (!url_request_getter_) { |
| - url_request_getter_ = new ShellURLRequestContextGetter( |
| - ignore_certificate_errors_, |
| - GetPath(), |
| - BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), |
| - BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE)); |
| - } |
| - return url_request_getter_; |
| + CHECK(url_request_getter_.get()); |
|
mmenke
2013/01/08 17:19:26
Is there a reason this is a CHECK, but there's a D
mmenke
2013/01/08 17:19:26
The get() and the one in the DHCECK can be removed
pauljensen
2013/01/21 06:24:56
Done.
pauljensen
2013/01/21 06:24:56
I made this just go through the StoragePartition n
|
| + return url_request_getter_.get(); |
| +} |
| + |
| +net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + blob_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + file_system_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| + developer_protocol_handler) { |
| + DCHECK(!url_request_getter_.get()); |
| + url_request_getter_ = new ShellURLRequestContextGetter( |
| + ignore_certificate_errors_, |
| + GetPath(), |
| + BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), |
| + BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), |
| + blob_protocol_handler.Pass(), |
| + file_system_protocol_handler.Pass(), |
| + developer_protocol_handler.Pass()); |
| + resource_context_->getter_ = url_request_getter_.get(); |
|
mmenke
2013/01/08 17:19:26
I don't like digging into the guts of a class when
pauljensen
2013/01/21 06:24:56
This line of code is gone now that I made GetResou
|
| + return url_request_getter_.get(); |
| } |
| net::URLRequestContextGetter* |
| @@ -130,17 +168,19 @@ net::URLRequestContextGetter* |
| } |
| net::URLRequestContextGetter* |
| - ShellBrowserContext::GetRequestContextForStoragePartition( |
| + ShellBrowserContext::CreateRequestContextForStoragePartition( |
| const FilePath& partition_path, |
| - bool in_memory) { |
| + bool in_memory, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + blob_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| + file_system_protocol_handler, |
| + scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| + developer_protocol_handler) { |
| return NULL; |
| } |
| ResourceContext* ShellBrowserContext::GetResourceContext() { |
|
mmenke
2013/01/08 17:19:26
Suggest we go back to lazy init here, getting the
pauljensen
2013/01/21 06:24:56
Done. I had taken away the lazy init previously be
|
| - if (!resource_context_.get()) { |
| - resource_context_.reset(new ShellResourceContext( |
| - static_cast<ShellURLRequestContextGetter*>(GetRequestContext()))); |
| - } |
| return resource_context_.get(); |
| } |