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

Unified Diff: content/browser/storage_partition_impl_map.cc

Issue 12212031: Add support for redirecting ResourceHandlers to a blob: URL (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Code review fixes 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/browser/resource_context_impl.cc ('k') | content/browser/streams/stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/storage_partition_impl_map.cc
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index 75c4898d2504db1abe565af9349c8e15c9544bd7..9bcfe4f4cc8055f3331e3e58d09f9222e7d037c3 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -22,6 +22,9 @@
#include "content/browser/net/view_http_cache_job_factory.h"
#include "content/browser/resource_context_impl.h"
#include "content/browser/storage_partition_impl.h"
+#include "content/browser/streams/stream_context.h"
+#include "content/browser/streams/stream_registry.h"
+#include "content/browser/streams/stream_url_request_job.h"
#include "content/browser/webui/url_data_manager_backend.h"
#include "content/browser/tcmalloc_internals_request_job.h"
#include "content/public/browser/browser_context.h"
@@ -49,8 +52,10 @@ namespace {
class BlobProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
public:
BlobProtocolHandler(ChromeBlobStorageContext* blob_storage_context,
+ StreamContext* stream_context,
fileapi::FileSystemContext* file_system_context)
: blob_storage_context_(blob_storage_context),
+ stream_context_(stream_context),
file_system_context_(file_system_context) {}
virtual ~BlobProtocolHandler() {}
@@ -62,6 +67,7 @@ class BlobProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
if (!webkit_blob_protocol_handler_impl_) {
webkit_blob_protocol_handler_impl_.reset(
new WebKitBlobProtocolHandlerImpl(blob_storage_context_->controller(),
+ stream_context_,
file_system_context_));
}
return webkit_blob_protocol_handler_impl_->MaybeCreateJob(request,
@@ -76,14 +82,28 @@ class BlobProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
public:
WebKitBlobProtocolHandlerImpl(
webkit_blob::BlobStorageController* blob_storage_controller,
+ StreamContext* stream_context,
fileapi::FileSystemContext* file_system_context)
: webkit_blob::BlobProtocolHandler(
blob_storage_controller, file_system_context,
BrowserThread::GetMessageLoopProxyForThread(
- BrowserThread::FILE)) {}
+ BrowserThread::FILE)),
+ stream_context_(stream_context) {}
virtual ~WebKitBlobProtocolHandlerImpl() {}
+ virtual net::URLRequestJob* MaybeCreateJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
+ scoped_refptr<Stream> stream =
+ stream_context_->registry()->GetStream(request->url());
+ if (stream)
+ return new StreamURLRequestJob(request, network_delegate, stream);
+
+ return webkit_blob::BlobProtocolHandler::MaybeCreateJob(
+ request, network_delegate);
+ }
+
private:
// webkit_blob::BlobProtocolHandler implementation.
virtual scoped_refptr<webkit_blob::BlobData>
@@ -95,10 +115,12 @@ class BlobProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
return info->requested_blob_data();
}
+ const scoped_refptr<StreamContext> stream_context_;
DISALLOW_COPY_AND_ASSIGN(WebKitBlobProtocolHandlerImpl);
};
const scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
+ const scoped_refptr<StreamContext> stream_context_;
const scoped_refptr<fileapi::FileSystemContext> file_system_context_;
mutable scoped_ptr<WebKitBlobProtocolHandlerImpl>
@@ -447,9 +469,12 @@ StoragePartitionImpl* StoragePartitionImplMap::Get(
ChromeBlobStorageContext* blob_storage_context =
ChromeBlobStorageContext::GetFor(browser_context_);
+ StreamContext* stream_context = StreamContext::GetFor(browser_context_);
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> blob_protocol_handler(
- new BlobProtocolHandler(blob_storage_context,
- partition->GetFileSystemContext()));
+ new BlobProtocolHandler(
+ blob_storage_context,
+ stream_context,
+ partition->GetFileSystemContext()));
scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
file_system_protocol_handler(
CreateFileSystemProtocolHandler(partition->GetFileSystemContext()));
« no previous file with comments | « content/browser/resource_context_impl.cc ('k') | content/browser/streams/stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698