Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: content/shell/shell_browser_context.cc

Issue 11308362: Add StoragePartition's ProtocolHandlers at URLRequestContext construction time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync (r181485) Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/shell_browser_context.h ('k') | content/shell/shell_content_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/shell_browser_context.cc
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
index b4644773a5534a4b32ba9419c090c12a5cffd584..1acfa79b297378001041673ce91c6628cb8c57ca 100644
--- a/content/shell/shell_browser_context.cc
+++ b/content/shell/shell_browser_context.cc
@@ -12,11 +12,12 @@
#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/browser/storage_partition.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 +29,35 @@
namespace content {
+class ShellBrowserContext::ShellResourceContext : public ResourceContext {
+ public:
+ ShellResourceContext() : getter_(NULL) {}
+ virtual ~ShellResourceContext() {}
+
+ // ResourceContext implementation:
+ virtual net::HostResolver* GetHostResolver() OVERRIDE {
+ CHECK(getter_);
+ return getter_->host_resolver();
+ }
+ virtual net::URLRequestContext* GetRequestContext() OVERRIDE {
+ CHECK(getter_);
+ return getter_->GetURLRequestContext();
+ }
+
+ void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
+ getter_ = getter;
+ }
+
+ private:
+ 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();
}
@@ -100,14 +127,33 @@ 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_;
+ return GetDefaultStoragePartition(this)->GetURLRequestContext();
+}
+
+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::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) {
+ DCHECK(!url_request_getter_);
+ 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(),
+ chrome_protocol_handler.Pass(),
+ chrome_devtools_protocol_handler.Pass());
+ resource_context_->set_url_request_context_getter(url_request_getter_.get());
+ return url_request_getter_.get();
}
net::URLRequestContextGetter*
@@ -135,17 +181,23 @@ net::URLRequestContextGetter*
}
net::URLRequestContextGetter*
- ShellBrowserContext::GetRequestContextForStoragePartition(
+ ShellBrowserContext::CreateRequestContextForStoragePartition(
const base::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::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) {
return NULL;
}
ResourceContext* ShellBrowserContext::GetResourceContext() {
- if (!resource_context_.get()) {
- resource_context_.reset(new ShellResourceContext(
- static_cast<ShellURLRequestContextGetter*>(GetRequestContext())));
- }
return resource_context_.get();
}
« no previous file with comments | « content/shell/shell_browser_context.h ('k') | content/shell/shell_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698