Chromium Code Reviews| Index: content/browser/loader/buffered_resource_handler.cc |
| diff --git a/content/browser/loader/buffered_resource_handler.cc b/content/browser/loader/buffered_resource_handler.cc |
| index 69741423da156ba4563034f603d35d7a2657c0ed..ee74cdcfae0b4429f3ffae680bff2da9f956cc36 100644 |
| --- a/content/browser/loader/buffered_resource_handler.cc |
| +++ b/content/browser/loader/buffered_resource_handler.cc |
| @@ -15,12 +15,18 @@ |
| #include "content/browser/loader/certificate_resource_handler.h" |
| #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| #include "content/browser/loader/resource_request_info_impl.h" |
| +#include "content/browser/loader/stream_resource_handler.h" |
| #include "content/browser/plugin_service_impl.h" |
| +#include "content/browser/resource_context_impl.h" |
| +#include "content/browser/streams/stream.h" |
| +#include "content/browser/streams/stream_context.h" |
| +#include "content/browser/streams/stream_registry.h" |
| #include "content/public/browser/content_browser_client.h" |
| #include "content/public/browser/download_id.h" |
| #include "content/public/browser/download_save_info.h" |
| #include "content/public/browser/resource_context.h" |
| #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| +#include "content/public/browser/stream_handle.h" |
| #include "content/public/common/resource_response.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/mime_sniffer.h" |
| @@ -320,6 +326,10 @@ bool BufferedResourceHandler::SelectNextHandler(bool* defer) { |
| if (net::IsSupportedMimeType(mime_type)) |
| return true; |
| + scoped_ptr<ResourceHandler> handler(MaybeInterceptAsStream()); |
| + if (handler) |
| + return UseAlternateNextHandler(handler.Pass()); |
| + |
| #if defined(ENABLE_PLUGINS) |
| bool stale; |
| bool has_plugin = HasSupportingPlugin(&stale); |
| @@ -382,6 +392,41 @@ bool BufferedResourceHandler::UseAlternateNextHandler( |
| return CopyReadBufferToNextHandler(request_id); |
| } |
| +scoped_ptr<ResourceHandler> BufferedResourceHandler::MaybeInterceptAsStream() { |
| + ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_); |
| + const std::string& mime_type = response_->head.mime_type; |
| + |
| + GURL security_origin; |
| + std::string target_id; |
| + if (host_->delegate() && |
| + host_->delegate()->ShouldInterceptResourceAsStream(info->GetContext(), |
|
darin (slow to review)
2013/03/19 06:12:51
nit: return early to reduce overall indentation
Zachary Kuznia
2013/03/19 06:59:35
Done.
|
| + request_->url(), |
| + mime_type, |
| + &security_origin, |
| + &target_id)) { |
| + StreamContext* stream_context = |
|
darin (slow to review)
2013/03/19 06:12:51
you might consider modeling this code after Create
Zachary Kuznia
2013/03/19 06:59:35
Done.
|
| + GetStreamContextForResourceContext(info->GetContext()); |
| + |
| + |
| + scoped_ptr<StreamResourceHandler> handler( |
| + new StreamResourceHandler(request_, |
| + stream_context->registry(), |
| + security_origin)); |
| + |
| + info->set_is_stream(true); |
| + host_->delegate()->OnStreamCreated( |
| + info->GetContext(), |
| + info->GetChildID(), |
| + info->GetRouteID(), |
| + target_id, |
| + handler->stream()->CreateHandle(), |
| + mime_type, |
| + request_->url()); |
| + return (scoped_ptr<ResourceHandler>(handler.release())).Pass(); |
| + } |
| + return scoped_ptr<ResourceHandler>(); |
| +} |
| + |
| bool BufferedResourceHandler::ReplayReadCompleted(bool* defer) { |
| DCHECK(read_buffer_); |