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..7c55968635ee8e0a0191b3b71816f2059692151e 100644 |
--- a/content/shell/shell_browser_context.cc |
+++ b/content/shell/shell_browser_context.cc |
@@ -13,7 +13,6 @@ |
#include "base/threading/thread.h" |
#include "content/public/browser/browser_thread.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" |
@@ -28,9 +27,33 @@ |
namespace content { |
+class ShellResourceContext : public ResourceContext { |
awong
2012/12/13 01:06:15
Dunk this in an anonymous namespace to be safe.
pauljensen
2012/12/13 17:58:44
I don't think I can do that because it's declared
|
+ 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 +118,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()); |
+ 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(); |
+ return url_request_getter_.get(); |
} |
net::URLRequestContextGetter* |
@@ -130,17 +167,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() { |
- if (!resource_context_.get()) { |
- resource_context_.reset(new ShellResourceContext( |
- static_cast<ShellURLRequestContextGetter*>(GetRequestContext()))); |
- } |
return resource_context_.get(); |
} |