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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 12645004: Add Resource Handler for creating Streams to forward to extensions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Disable Stream Resource Throttle Created 7 years, 9 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/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index d90794dd367a0dd7acc88106f2d2cdfec06ca8ce..4c4f86c88bba0ba09fa1f6e67dc14f4dad2c7d82 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -36,6 +36,7 @@
#include "content/browser/loader/redirect_to_file_resource_handler.h"
#include "content/browser/loader/resource_message_filter.h"
#include "content/browser/loader/resource_request_info_impl.h"
+#include "content/browser/loader/stream_resource_handler.h"
#include "content/browser/loader/sync_resource_handler.h"
#include "content/browser/loader/throttling_resource_handler.h"
#include "content/browser/loader/transfer_navigation_resource_throttle.h"
@@ -43,6 +44,9 @@
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_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/browser/worker_host/worker_service_impl.h"
#include "content/common/resource_messages.h"
#include "content/common/ssl_status_serialization.h"
@@ -55,6 +59,7 @@
#include "content/public/browser/resource_dispatcher_host_delegate.h"
#include "content/public/browser/resource_request_details.h"
#include "content/public/browser/resource_throttle.h"
+#include "content/public/browser/stream_handle.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/process_type.h"
@@ -553,6 +558,42 @@ ResourceDispatcherHostImpl::CreateResourceHandlerForDownload(
return handler.Pass();
}
+scoped_ptr<ResourceHandler>
+ResourceDispatcherHostImpl::MaybeInterceptAsStream(net::URLRequest* request,
+ ResourceResponse* response) {
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
+ const std::string& mime_type = response->head.mime_type;
+
+ GURL security_origin;
+ std::string target_id;
+ if (!delegate_ ||
+ !delegate_->ShouldInterceptResourceAsStream(info->GetContext(),
+ request->url(),
+ mime_type,
+ &security_origin,
+ &target_id)) {
+ return scoped_ptr<ResourceHandler>();
+ }
+
+ StreamContext* stream_context =
+ GetStreamContextForResourceContext(info->GetContext());
+
+
+ scoped_ptr<StreamResourceHandler> handler(
+ new StreamResourceHandler(request,
+ stream_context->registry(),
+ security_origin));
+
+ info->set_is_stream(true);
+ delegate_->OnStreamCreated(
+ info->GetContext(),
+ info->GetChildID(),
+ info->GetRouteID(),
+ target_id,
+ handler->stream()->CreateHandle(request->url(), mime_type));
+ return (scoped_ptr<ResourceHandler>(handler.release())).Pass();
+}
+
void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest(
net::URLRequest* request) {
ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
@@ -951,6 +992,7 @@ void ResourceDispatcherHostImpl::BeginRequest(
request_data.resource_type,
request_data.transition_type,
false, // is download
+ false, // is stream
allow_download,
request_data.has_user_gesture,
request_data.referrer_policy,
@@ -1119,6 +1161,7 @@ ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
ResourceType::SUB_RESOURCE,
PAGE_TRANSITION_LINK,
download, // is_download
+ false, // is_stream
download, // allow_download
false, // has_user_gesture
WebKit::WebReferrerPolicyDefault,
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698