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

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: Fix ShellContentBrowserClient off-the-record-profile Created 8 years 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
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..ccd119755e71493ebe28e2895c702f7ae3d447f9 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 ShellResourceContext : public ResourceContext {
awong 2012/12/13 23:53:08 I see what you mean by it being referenced. In th
pauljensen 2012/12/14 16:16:20 Well if I move it into its own file then I think I
awong 2012/12/14 16:44:24 I don't feel too strongly about having keeping fri
+ 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());
+ 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 +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() {
- if (!resource_context_.get()) {
- resource_context_.reset(new ShellResourceContext(
- static_cast<ShellURLRequestContextGetter*>(GetRequestContext())));
- }
return resource_context_.get();
}

Powered by Google App Engine
This is Rietveld 408576698