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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 18 matching lines...) Expand all
29 #include "content/browser/download/save_file_manager.h" 29 #include "content/browser/download/save_file_manager.h"
30 #include "content/browser/download/save_file_resource_handler.h" 30 #include "content/browser/download/save_file_resource_handler.h"
31 #include "content/browser/fileapi/chrome_blob_storage_context.h" 31 #include "content/browser/fileapi/chrome_blob_storage_context.h"
32 #include "content/browser/loader/async_resource_handler.h" 32 #include "content/browser/loader/async_resource_handler.h"
33 #include "content/browser/loader/buffered_resource_handler.h" 33 #include "content/browser/loader/buffered_resource_handler.h"
34 #include "content/browser/loader/cross_site_resource_handler.h" 34 #include "content/browser/loader/cross_site_resource_handler.h"
35 #include "content/browser/loader/power_save_block_resource_throttle.h" 35 #include "content/browser/loader/power_save_block_resource_throttle.h"
36 #include "content/browser/loader/redirect_to_file_resource_handler.h" 36 #include "content/browser/loader/redirect_to_file_resource_handler.h"
37 #include "content/browser/loader/resource_message_filter.h" 37 #include "content/browser/loader/resource_message_filter.h"
38 #include "content/browser/loader/resource_request_info_impl.h" 38 #include "content/browser/loader/resource_request_info_impl.h"
39 #include "content/browser/loader/stream_resource_handler.h"
39 #include "content/browser/loader/sync_resource_handler.h" 40 #include "content/browser/loader/sync_resource_handler.h"
40 #include "content/browser/loader/throttling_resource_handler.h" 41 #include "content/browser/loader/throttling_resource_handler.h"
41 #include "content/browser/loader/transfer_navigation_resource_throttle.h" 42 #include "content/browser/loader/transfer_navigation_resource_throttle.h"
42 #include "content/browser/plugin_service_impl.h" 43 #include "content/browser/plugin_service_impl.h"
43 #include "content/browser/renderer_host/render_view_host_delegate.h" 44 #include "content/browser/renderer_host/render_view_host_delegate.h"
44 #include "content/browser/renderer_host/render_view_host_impl.h" 45 #include "content/browser/renderer_host/render_view_host_impl.h"
45 #include "content/browser/resource_context_impl.h" 46 #include "content/browser/resource_context_impl.h"
47 #include "content/browser/streams/stream.h"
48 #include "content/browser/streams/stream_context.h"
49 #include "content/browser/streams/stream_registry.h"
46 #include "content/browser/worker_host/worker_service_impl.h" 50 #include "content/browser/worker_host/worker_service_impl.h"
47 #include "content/common/resource_messages.h" 51 #include "content/common/resource_messages.h"
48 #include "content/common/ssl_status_serialization.h" 52 #include "content/common/ssl_status_serialization.h"
49 #include "content/common/view_messages.h" 53 #include "content/common/view_messages.h"
50 #include "content/public/browser/browser_thread.h" 54 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/content_browser_client.h" 55 #include "content/public/browser/content_browser_client.h"
52 #include "content/public/browser/download_manager.h" 56 #include "content/public/browser/download_manager.h"
53 #include "content/public/browser/global_request_id.h" 57 #include "content/public/browser/global_request_id.h"
54 #include "content/public/browser/notification_service.h" 58 #include "content/public/browser/notification_service.h"
55 #include "content/public/browser/resource_dispatcher_host_delegate.h" 59 #include "content/public/browser/resource_dispatcher_host_delegate.h"
56 #include "content/public/browser/resource_request_details.h" 60 #include "content/public/browser/resource_request_details.h"
57 #include "content/public/browser/resource_throttle.h" 61 #include "content/public/browser/resource_throttle.h"
62 #include "content/public/browser/stream_handle.h"
58 #include "content/public/browser/user_metrics.h" 63 #include "content/public/browser/user_metrics.h"
59 #include "content/public/common/content_switches.h" 64 #include "content/public/common/content_switches.h"
60 #include "content/public/common/process_type.h" 65 #include "content/public/common/process_type.h"
61 #include "content/public/common/url_constants.h" 66 #include "content/public/common/url_constants.h"
62 #include "ipc/ipc_message_macros.h" 67 #include "ipc/ipc_message_macros.h"
63 #include "ipc/ipc_message_start.h" 68 #include "ipc/ipc_message_start.h"
64 #include "net/base/auth.h" 69 #include "net/base/auth.h"
65 #include "net/base/cert_status_flags.h" 70 #include "net/base/cert_status_flags.h"
66 #include "net/base/load_flags.h" 71 #include "net/base/load_flags.h"
67 #include "net/base/mime_util.h" 72 #include "net/base/mime_util.h"
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 if (!throttles.empty()) { 551 if (!throttles.empty()) {
547 handler.reset( 552 handler.reset(
548 new ThrottlingResourceHandler( 553 new ThrottlingResourceHandler(
549 handler.Pass(), request_info->GetChildID(), 554 handler.Pass(), request_info->GetChildID(),
550 request_info->GetRequestID(), throttles.Pass())); 555 request_info->GetRequestID(), throttles.Pass()));
551 } 556 }
552 } 557 }
553 return handler.Pass(); 558 return handler.Pass();
554 } 559 }
555 560
561 scoped_ptr<ResourceHandler>
562 ResourceDispatcherHostImpl::MaybeInterceptAsStream(net::URLRequest* request,
563 ResourceResponse* response) {
564 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
565 const std::string& mime_type = response->head.mime_type;
566
567 GURL security_origin;
568 std::string target_id;
569 if (!delegate_ ||
570 !delegate_->ShouldInterceptResourceAsStream(info->GetContext(),
571 request->url(),
572 mime_type,
573 &security_origin,
574 &target_id)) {
575 return scoped_ptr<ResourceHandler>();
576 }
577
578 StreamContext* stream_context =
579 GetStreamContextForResourceContext(info->GetContext());
580
581
582 scoped_ptr<StreamResourceHandler> handler(
583 new StreamResourceHandler(request,
584 stream_context->registry(),
585 security_origin));
586
587 info->set_is_stream(true);
588 delegate_->OnStreamCreated(
589 info->GetContext(),
590 info->GetChildID(),
591 info->GetRouteID(),
592 target_id,
593 handler->stream()->CreateHandle(request->url(), mime_type));
594 return (scoped_ptr<ResourceHandler>(handler.release())).Pass();
595 }
596
556 void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest( 597 void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest(
557 net::URLRequest* request) { 598 net::URLRequest* request) {
558 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 599 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
559 if (info) { 600 if (info) {
560 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); 601 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID());
561 if (loader) 602 if (loader)
562 loader->ClearSSLClientAuthHandler(); 603 loader->ClearSSLClientAuthHandler();
563 } 604 }
564 } 605 }
565 606
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 route_id, 985 route_id,
945 request_data.origin_pid, 986 request_data.origin_pid,
946 request_id, 987 request_id,
947 request_data.is_main_frame, 988 request_data.is_main_frame,
948 request_data.frame_id, 989 request_data.frame_id,
949 request_data.parent_is_main_frame, 990 request_data.parent_is_main_frame,
950 request_data.parent_frame_id, 991 request_data.parent_frame_id,
951 request_data.resource_type, 992 request_data.resource_type,
952 request_data.transition_type, 993 request_data.transition_type,
953 false, // is download 994 false, // is download
995 false, // is stream
954 allow_download, 996 allow_download,
955 request_data.has_user_gesture, 997 request_data.has_user_gesture,
956 request_data.referrer_policy, 998 request_data.referrer_policy,
957 resource_context, 999 resource_context,
958 !is_sync_load); 1000 !is_sync_load);
959 extra_info->AssociateWithRequest(request); // Request takes ownership. 1001 extra_info->AssociateWithRequest(request); // Request takes ownership.
960 1002
961 if (request->url().SchemeIs(chrome::kBlobScheme)) { 1003 if (request->url().SchemeIs(chrome::kBlobScheme)) {
962 // Hang on to a reference to ensure the blob is not released prior 1004 // Hang on to a reference to ensure the blob is not released prior
963 // to the job being started. 1005 // to the job being started.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 route_id, 1154 route_id,
1113 0, 1155 0,
1114 request_id_, 1156 request_id_,
1115 false, // is_main_frame 1157 false, // is_main_frame
1116 -1, // frame_id 1158 -1, // frame_id
1117 false, // parent_is_main_frame 1159 false, // parent_is_main_frame
1118 -1, // parent_frame_id 1160 -1, // parent_frame_id
1119 ResourceType::SUB_RESOURCE, 1161 ResourceType::SUB_RESOURCE,
1120 PAGE_TRANSITION_LINK, 1162 PAGE_TRANSITION_LINK,
1121 download, // is_download 1163 download, // is_download
1164 false, // is_stream
1122 download, // allow_download 1165 download, // allow_download
1123 false, // has_user_gesture 1166 false, // has_user_gesture
1124 WebKit::WebReferrerPolicyDefault, 1167 WebKit::WebReferrerPolicyDefault,
1125 context, 1168 context,
1126 true); // is_async 1169 true); // is_async
1127 } 1170 }
1128 1171
1129 1172
1130 void ResourceDispatcherHostImpl::OnSwapOutACK( 1173 void ResourceDispatcherHostImpl::OnSwapOutACK(
1131 const ViewMsg_SwapOut_Params& params) { 1174 const ViewMsg_SwapOut_Params& params) {
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 DelegateMap::iterator it = delegate_map_.find(id); 1753 DelegateMap::iterator it = delegate_map_.find(id);
1711 DCHECK(it->second->HasObserver(delegate)); 1754 DCHECK(it->second->HasObserver(delegate));
1712 it->second->RemoveObserver(delegate); 1755 it->second->RemoveObserver(delegate);
1713 if (it->second->size() == 0) { 1756 if (it->second->size() == 0) {
1714 delete it->second; 1757 delete it->second;
1715 delegate_map_.erase(it); 1758 delegate_map_.erase(it);
1716 } 1759 }
1717 } 1760 }
1718 1761
1719 } // namespace content 1762 } // namespace content
OLDNEW
« 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