OLD | NEW |
---|---|
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 <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "content/browser/loader/mime_sniffing_resource_handler.h" | 50 #include "content/browser/loader/mime_sniffing_resource_handler.h" |
51 #include "content/browser/loader/mojo_async_resource_handler.h" | 51 #include "content/browser/loader/mojo_async_resource_handler.h" |
52 #include "content/browser/loader/navigation_resource_handler.h" | 52 #include "content/browser/loader/navigation_resource_handler.h" |
53 #include "content/browser/loader/navigation_resource_throttle.h" | 53 #include "content/browser/loader/navigation_resource_throttle.h" |
54 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 54 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
55 #include "content/browser/loader/power_save_block_resource_throttle.h" | 55 #include "content/browser/loader/power_save_block_resource_throttle.h" |
56 #include "content/browser/loader/redirect_to_file_resource_handler.h" | 56 #include "content/browser/loader/redirect_to_file_resource_handler.h" |
57 #include "content/browser/loader/resource_loader.h" | 57 #include "content/browser/loader/resource_loader.h" |
58 #include "content/browser/loader/resource_message_filter.h" | 58 #include "content/browser/loader/resource_message_filter.h" |
59 #include "content/browser/loader/resource_request_info_impl.h" | 59 #include "content/browser/loader/resource_request_info_impl.h" |
60 #include "content/browser/loader/resource_requester_info.h" | |
60 #include "content/browser/loader/resource_scheduler.h" | 61 #include "content/browser/loader/resource_scheduler.h" |
61 #include "content/browser/loader/stream_resource_handler.h" | 62 #include "content/browser/loader/stream_resource_handler.h" |
62 #include "content/browser/loader/sync_resource_handler.h" | 63 #include "content/browser/loader/sync_resource_handler.h" |
63 #include "content/browser/loader/throttling_resource_handler.h" | 64 #include "content/browser/loader/throttling_resource_handler.h" |
64 #include "content/browser/loader/upload_data_stream_builder.h" | 65 #include "content/browser/loader/upload_data_stream_builder.h" |
65 #include "content/browser/resource_context_impl.h" | 66 #include "content/browser/resource_context_impl.h" |
66 #include "content/browser/service_worker/foreign_fetch_request_handler.h" | 67 #include "content/browser/service_worker/foreign_fetch_request_handler.h" |
67 #include "content/browser/service_worker/link_header_support.h" | 68 #include "content/browser/service_worker/link_header_support.h" |
69 #include "content/browser/service_worker/service_worker_context_wrapper.h" | |
68 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " | 70 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " |
69 #include "content/browser/service_worker/service_worker_request_handler.h" | 71 #include "content/browser/service_worker/service_worker_request_handler.h" |
70 #include "content/browser/streams/stream.h" | 72 #include "content/browser/streams/stream.h" |
71 #include "content/browser/streams/stream_context.h" | 73 #include "content/browser/streams/stream_context.h" |
72 #include "content/browser/streams/stream_registry.h" | 74 #include "content/browser/streams/stream_registry.h" |
73 #include "content/common/navigation_params.h" | 75 #include "content/common/navigation_params.h" |
74 #include "content/common/net/url_request_service_worker_data.h" | 76 #include "content/common/net/url_request_service_worker_data.h" |
75 #include "content/common/resource_messages.h" | 77 #include "content/common/resource_messages.h" |
76 #include "content/common/resource_request.h" | 78 #include "content/common/resource_request.h" |
77 #include "content/common/resource_request_body_impl.h" | 79 #include "content/common/resource_request_body_impl.h" |
78 #include "content/common/resource_request_completion_status.h" | 80 #include "content/common/resource_request_completion_status.h" |
79 #include "content/common/site_isolation_policy.h" | 81 #include "content/common/site_isolation_policy.h" |
80 #include "content/common/view_messages.h" | 82 #include "content/common/view_messages.h" |
81 #include "content/public/browser/browser_thread.h" | 83 #include "content/public/browser/browser_thread.h" |
82 #include "content/public/browser/global_request_id.h" | 84 #include "content/public/browser/global_request_id.h" |
83 #include "content/public/browser/navigation_ui_data.h" | 85 #include "content/public/browser/navigation_ui_data.h" |
84 #include "content/public/browser/plugin_service.h" | 86 #include "content/public/browser/plugin_service.h" |
85 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 87 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
86 #include "content/public/browser/resource_request_details.h" | 88 #include "content/public/browser/resource_request_details.h" |
87 #include "content/public/browser/resource_throttle.h" | 89 #include "content/public/browser/resource_throttle.h" |
88 #include "content/public/browser/stream_handle.h" | 90 #include "content/public/browser/stream_handle.h" |
89 #include "content/public/browser/stream_info.h" | 91 #include "content/public/browser/stream_info.h" |
90 #include "content/public/common/browser_side_navigation_policy.h" | 92 #include "content/public/common/browser_side_navigation_policy.h" |
91 #include "content/public/common/content_features.h" | 93 #include "content/public/common/content_features.h" |
92 #include "content/public/common/content_switches.h" | 94 #include "content/public/common/content_switches.h" |
93 #include "content/public/common/process_type.h" | |
94 #include "ipc/ipc_message_macros.h" | 95 #include "ipc/ipc_message_macros.h" |
95 #include "ipc/ipc_message_start.h" | 96 #include "ipc/ipc_message_start.h" |
96 #include "net/base/auth.h" | 97 #include "net/base/auth.h" |
97 #include "net/base/load_flags.h" | 98 #include "net/base/load_flags.h" |
98 #include "net/base/mime_util.h" | 99 #include "net/base/mime_util.h" |
99 #include "net/base/net_errors.h" | 100 #include "net/base/net_errors.h" |
100 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 101 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
101 #include "net/base/upload_data_stream.h" | 102 #include "net/base/upload_data_stream.h" |
102 #include "net/cert/cert_status_flags.h" | 103 #include "net/cert/cert_status_flags.h" |
103 #include "net/cookies/cookie_monster.h" | 104 #include "net/cookies/cookie_monster.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 case RESOURCE_TYPE_PING: | 221 case RESOURCE_TYPE_PING: |
221 case RESOURCE_TYPE_CSP_REPORT: | 222 case RESOURCE_TYPE_CSP_REPORT: |
222 return true; | 223 return true; |
223 default: | 224 default: |
224 return false; | 225 return false; |
225 } | 226 } |
226 } | 227 } |
227 | 228 |
228 // Aborts a request before an URLRequest has actually been created. | 229 // Aborts a request before an URLRequest has actually been created. |
229 void AbortRequestBeforeItStarts( | 230 void AbortRequestBeforeItStarts( |
230 ResourceMessageFilter* filter, | 231 BrowserMessageFilter* filter, |
231 const SyncLoadResultCallback& sync_result_handler, | 232 const SyncLoadResultCallback& sync_result_handler, |
232 int request_id, | 233 int request_id, |
233 mojom::URLLoaderClientAssociatedPtr url_loader_client) { | 234 mojom::URLLoaderClientAssociatedPtr url_loader_client) { |
234 if (sync_result_handler) { | 235 if (sync_result_handler) { |
235 SyncLoadResult result; | 236 SyncLoadResult result; |
236 result.error_code = net::ERR_ABORTED; | 237 result.error_code = net::ERR_ABORTED; |
237 sync_result_handler.Run(&result); | 238 sync_result_handler.Run(&result); |
238 } else { | 239 } else { |
239 // Tell the renderer that this request was disallowed. | 240 // Tell the renderer that this request was disallowed. |
240 ResourceRequestCompletionStatus request_complete_data; | 241 ResourceRequestCompletionStatus request_complete_data; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl( | 461 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl( |
461 CreateDownloadHandlerIntercept download_handler_intercept) | 462 CreateDownloadHandlerIntercept download_handler_intercept) |
462 : request_id_(-1), | 463 : request_id_(-1), |
463 is_shutdown_(false), | 464 is_shutdown_(false), |
464 num_in_flight_requests_(0), | 465 num_in_flight_requests_(0), |
465 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), | 466 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), |
466 max_num_in_flight_requests_per_process_(static_cast<int>( | 467 max_num_in_flight_requests_per_process_(static_cast<int>( |
467 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), | 468 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), |
468 max_outstanding_requests_cost_per_process_( | 469 max_outstanding_requests_cost_per_process_( |
469 kMaxOutstandingRequestsCostPerProcess), | 470 kMaxOutstandingRequestsCostPerProcess), |
470 filter_(nullptr), | |
471 delegate_(nullptr), | 471 delegate_(nullptr), |
472 loader_delegate_(nullptr), | 472 loader_delegate_(nullptr), |
473 allow_cross_origin_auth_prompt_(false), | 473 allow_cross_origin_auth_prompt_(false), |
474 create_download_handler_intercept_(download_handler_intercept) { | 474 create_download_handler_intercept_(download_handler_intercept) { |
475 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 475 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
476 DCHECK(!g_resource_dispatcher_host); | 476 DCHECK(!g_resource_dispatcher_host); |
477 g_resource_dispatcher_host = this; | 477 g_resource_dispatcher_host = this; |
478 | 478 |
479 ANNOTATE_BENIGN_RACE( | 479 ANNOTATE_BENIGN_RACE( |
480 &last_user_gesture_time_, | 480 &last_user_gesture_time_, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 } | 610 } |
611 | 611 |
612 #ifndef NDEBUG | 612 #ifndef NDEBUG |
613 for (const auto& loader : loaders_to_cancel) { | 613 for (const auto& loader : loaders_to_cancel) { |
614 // There is no strict requirement that this be the case, but currently | 614 // There is no strict requirement that this be the case, but currently |
615 // downloads, streams, detachable requests, transferred requests, and | 615 // downloads, streams, detachable requests, transferred requests, and |
616 // browser-owned requests are the only requests that aren't cancelled when | 616 // browser-owned requests are the only requests that aren't cancelled when |
617 // the associated processes go away. It may be OK for this invariant to | 617 // the associated processes go away. It may be OK for this invariant to |
618 // change in the future, but if this assertion fires without the invariant | 618 // change in the future, but if this assertion fires without the invariant |
619 // changing, then it's indicative of a leak. | 619 // changing, then it's indicative of a leak. |
620 DCHECK(loader->GetRequestInfo()->IsDownload() || | 620 DCHECK( |
621 loader->GetRequestInfo()->is_stream() || | 621 loader->GetRequestInfo()->IsDownload() || |
622 (loader->GetRequestInfo()->detachable_handler() && | 622 loader->GetRequestInfo()->is_stream() || |
623 loader->GetRequestInfo()->detachable_handler()->is_detached()) || | 623 (loader->GetRequestInfo()->detachable_handler() && |
624 loader->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER || | 624 loader->GetRequestInfo()->detachable_handler()->is_detached()) || |
625 loader->is_transferring()); | 625 loader->GetRequestInfo()->requester_info().IsBrowserSideNavigation() || |
626 loader->is_transferring()); | |
626 } | 627 } |
627 #endif | 628 #endif |
628 | 629 |
629 loaders_to_cancel.clear(); | 630 loaders_to_cancel.clear(); |
630 | 631 |
631 if (async_revalidation_manager_) { | 632 if (async_revalidation_manager_) { |
632 // Cancelling async revalidations should not result in the creation of new | 633 // Cancelling async revalidations should not result in the creation of new |
633 // requests. Do it before the CHECKs to ensure this does not happen. | 634 // requests. Do it before the CHECKs to ensure this does not happen. |
634 async_revalidation_manager_->CancelAsyncRevalidationsForResourceContext( | 635 async_revalidation_manager_->CancelAsyncRevalidationsForResourceContext( |
635 context); | 636 context); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1001 } | 1002 } |
1002 for (const auto& routing_id : ids) { | 1003 for (const auto& routing_id : ids) { |
1003 CancelBlockedRequestsForRoute(routing_id); | 1004 CancelBlockedRequestsForRoute(routing_id); |
1004 } | 1005 } |
1005 | 1006 |
1006 scheduler_.reset(); | 1007 scheduler_.reset(); |
1007 } | 1008 } |
1008 | 1009 |
1009 bool ResourceDispatcherHostImpl::OnMessageReceived( | 1010 bool ResourceDispatcherHostImpl::OnMessageReceived( |
1010 const IPC::Message& message, | 1011 const IPC::Message& message, |
1011 ResourceMessageFilter* filter) { | 1012 const ResourceRequesterInfo* requester_info) { |
1012 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1013 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1013 filter_ = filter; | 1014 |
1014 bool handled = true; | 1015 bool handled = true; |
1015 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcherHostImpl, message) | 1016 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ResourceDispatcherHostImpl, message, |
1017 requester_info) | |
1016 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) | 1018 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) |
1017 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) | 1019 IPC_MESSAGE_HANDLER_WITH_PARAM_DELAY_REPLY(ResourceHostMsg_SyncLoad, |
1020 OnSyncLoad) | |
1018 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, | 1021 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, |
1019 OnReleaseDownloadedFile) | 1022 OnReleaseDownloadedFile) |
1020 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) | 1023 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
1021 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, OnDidChangePriority) | 1024 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, OnDidChangePriority) |
1022 IPC_MESSAGE_UNHANDLED(handled = false) | 1025 IPC_MESSAGE_UNHANDLED(handled = false) |
1023 IPC_END_MESSAGE_MAP() | 1026 IPC_END_MESSAGE_MAP() |
1024 | 1027 |
1025 if (!handled && IPC_MESSAGE_ID_CLASS(message.type()) == ResourceMsgStart) { | 1028 if (!handled && IPC_MESSAGE_ID_CLASS(message.type()) == ResourceMsgStart) { |
1026 base::PickleIterator iter(message); | 1029 base::PickleIterator iter(message); |
1027 int request_id = -1; | 1030 int request_id = -1; |
1028 bool ok = iter.ReadInt(&request_id); | 1031 bool ok = iter.ReadInt(&request_id); |
1029 DCHECK(ok); | 1032 DCHECK(ok); |
1030 GlobalRequestID id(filter_->child_id(), request_id); | 1033 GlobalRequestID id(requester_info->child_id(), request_id); |
1031 DelegateMap::iterator it = delegate_map_.find(id); | 1034 DelegateMap::iterator it = delegate_map_.find(id); |
1032 if (it != delegate_map_.end()) { | 1035 if (it != delegate_map_.end()) { |
1033 for (auto& delegate : *it->second) { | 1036 for (auto& delegate : *it->second) { |
1034 if (delegate.OnMessageReceived(message)) { | 1037 if (delegate.OnMessageReceived(message)) { |
1035 handled = true; | 1038 handled = true; |
1036 break; | 1039 break; |
1037 } | 1040 } |
1038 } | 1041 } |
1039 } | 1042 } |
1040 | 1043 |
1041 // As the unhandled resource message effectively has no consumer, mark it as | 1044 // As the unhandled resource message effectively has no consumer, mark it as |
1042 // handled to prevent needless propagation through the filter pipeline. | 1045 // handled to prevent needless propagation through the filter pipeline. |
1043 handled = true; | 1046 handled = true; |
1044 } | 1047 } |
1045 | 1048 |
1046 filter_ = NULL; | |
1047 return handled; | 1049 return handled; |
1048 } | 1050 } |
1049 | 1051 |
1050 void ResourceDispatcherHostImpl::OnRequestResource( | 1052 void ResourceDispatcherHostImpl::OnRequestResource( |
1053 const ResourceRequesterInfo* requester_info, | |
1051 int routing_id, | 1054 int routing_id, |
1052 int request_id, | 1055 int request_id, |
1053 const ResourceRequest& request_data) { | 1056 const ResourceRequest& request_data) { |
1054 OnRequestResourceInternal(routing_id, request_id, request_data, nullptr, | 1057 OnRequestResourceInternal(requester_info, routing_id, request_id, |
1055 nullptr); | 1058 request_data, nullptr, nullptr); |
1056 } | 1059 } |
1057 | 1060 |
1058 void ResourceDispatcherHostImpl::OnRequestResourceInternal( | 1061 void ResourceDispatcherHostImpl::OnRequestResourceInternal( |
1062 const ResourceRequesterInfo* requester_info, | |
1059 int routing_id, | 1063 int routing_id, |
1060 int request_id, | 1064 int request_id, |
1061 const ResourceRequest& request_data, | 1065 const ResourceRequest& request_data, |
1062 mojom::URLLoaderAssociatedRequest mojo_request, | 1066 mojom::URLLoaderAssociatedRequest mojo_request, |
1063 mojom::URLLoaderClientAssociatedPtr url_loader_client) { | 1067 mojom::URLLoaderClientAssociatedPtr url_loader_client) { |
1068 DCHECK(requester_info->IsRenderer()); | |
1064 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 1069 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
1065 tracked_objects::ScopedTracker tracking_profile( | 1070 tracked_objects::ScopedTracker tracking_profile( |
1066 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1071 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
1067 "477117 ResourceDispatcherHostImpl::OnRequestResource")); | 1072 "477117 ResourceDispatcherHostImpl::OnRequestResource")); |
1068 // When logging time-to-network only care about main frame and non-transfer | 1073 // When logging time-to-network only care about main frame and non-transfer |
1069 // navigations. | 1074 // navigations. |
1070 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted | 1075 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted |
1071 // instead. | 1076 // instead. |
1072 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && | 1077 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && |
1073 request_data.transferred_request_request_id == -1 && | 1078 request_data.transferred_request_request_id == -1 && |
1074 !IsBrowserSideNavigationEnabled()) { | 1079 !IsBrowserSideNavigationEnabled()) { |
1075 BrowserThread::PostTask( | 1080 BrowserThread::PostTask( |
1076 BrowserThread::UI, | 1081 BrowserThread::UI, FROM_HERE, |
1077 FROM_HERE, | 1082 base::Bind(&LogResourceRequestTimeOnUI, TimeTicks::Now(), |
1078 base::Bind(&LogResourceRequestTimeOnUI, | 1083 requester_info->child_id(), request_data.render_frame_id, |
1079 TimeTicks::Now(), | |
1080 filter_->child_id(), | |
1081 request_data.render_frame_id, | |
1082 request_data.url)); | 1084 request_data.url)); |
1083 } | 1085 } |
1084 BeginRequest(request_id, request_data, SyncLoadResultCallback(), routing_id, | 1086 BeginRequest(requester_info, request_id, request_data, |
1085 std::move(mojo_request), std::move(url_loader_client)); | 1087 SyncLoadResultCallback(), routing_id, std::move(mojo_request), |
1088 std::move(url_loader_client)); | |
1086 } | 1089 } |
1087 | 1090 |
1088 // Begins a resource request with the given params on behalf of the specified | 1091 // Begins a resource request with the given params on behalf of the specified |
1089 // child process. Responses will be dispatched through the given receiver. The | 1092 // child process. Responses will be dispatched through the given receiver. The |
1090 // process ID is used to lookup WebContentsImpl from routing_id's in the case of | 1093 // process ID is used to lookup WebContentsImpl from routing_id's in the case of |
1091 // a request from a renderer. request_context is the cookie/cache context to be | 1094 // a request from a renderer. request_context is the cookie/cache context to be |
1092 // used for this request. | 1095 // used for this request. |
1093 // | 1096 // |
1094 // If sync_result is non-null, then a SyncLoad reply will be generated, else | 1097 // If sync_result is non-null, then a SyncLoad reply will be generated, else |
1095 // a normal asynchronous set of response messages will be generated. | 1098 // a normal asynchronous set of response messages will be generated. |
1096 void ResourceDispatcherHostImpl::OnSyncLoad(int request_id, | 1099 void ResourceDispatcherHostImpl::OnSyncLoad( |
1097 const ResourceRequest& request_data, | 1100 const ResourceRequesterInfo* requester_info, |
1098 IPC::Message* sync_result) { | 1101 int request_id, |
1099 SyncLoadResultCallback callback = base::Bind( | 1102 const ResourceRequest& request_data, |
1100 &HandleSyncLoadResult, filter_->GetWeakPtr(), | 1103 IPC::Message* sync_result) { |
1101 base::Passed(WrapUnique(sync_result))); | 1104 SyncLoadResultCallback callback = |
1102 BeginRequest(request_id, request_data, callback, sync_result->routing_id(), | 1105 base::Bind(&HandleSyncLoadResult, requester_info->filter()->GetWeakPtr(), |
1103 nullptr, nullptr); | 1106 base::Passed(WrapUnique(sync_result))); |
1107 BeginRequest(requester_info, request_id, request_data, callback, | |
1108 sync_result->routing_id(), nullptr, nullptr); | |
1104 } | 1109 } |
1105 | 1110 |
1106 bool ResourceDispatcherHostImpl::IsRequestIDInUse( | 1111 bool ResourceDispatcherHostImpl::IsRequestIDInUse( |
1107 const GlobalRequestID& id) const { | 1112 const GlobalRequestID& id) const { |
1108 if (pending_loaders_.find(id) != pending_loaders_.end()) | 1113 if (pending_loaders_.find(id) != pending_loaders_.end()) |
1109 return true; | 1114 return true; |
1110 for (const auto& blocked_loaders : blocked_loaders_map_) { | 1115 for (const auto& blocked_loaders : blocked_loaders_map_) { |
1111 for (const auto& loader : *blocked_loaders.second.get()) { | 1116 for (const auto& loader : *blocked_loaders.second.get()) { |
1112 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 1117 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
1113 if (info->GetGlobalRequestID() == id) | 1118 if (info->GetGlobalRequestID() == id) |
1114 return true; | 1119 return true; |
1115 } | 1120 } |
1116 } | 1121 } |
1117 return false; | 1122 return false; |
1118 } | 1123 } |
1119 | 1124 |
1120 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( | 1125 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( |
1121 int child_id, | 1126 const ResourceRequesterInfo* requester_info, |
1122 int route_id, | 1127 int route_id, |
1123 int request_id, | 1128 int request_id, |
1124 const ResourceRequest& request_data, | 1129 const ResourceRequest& request_data, |
1125 LoaderMap::iterator iter) { | 1130 LoaderMap::iterator iter) { |
1131 DCHECK(requester_info->IsRenderer()); | |
1132 const int child_id = requester_info->child_id(); | |
1126 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo(); | 1133 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo(); |
1127 GlobalFrameRoutingId old_routing_id(request_data.transferred_request_child_id, | 1134 GlobalFrameRoutingId old_routing_id(request_data.transferred_request_child_id, |
1128 info->GetRenderFrameID()); | 1135 info->GetRenderFrameID()); |
1129 GlobalRequestID old_request_id(request_data.transferred_request_child_id, | 1136 GlobalRequestID old_request_id(request_data.transferred_request_child_id, |
1130 request_data.transferred_request_request_id); | 1137 request_data.transferred_request_request_id); |
1131 GlobalFrameRoutingId new_routing_id(child_id, request_data.render_frame_id); | 1138 GlobalFrameRoutingId new_routing_id(child_id, request_data.render_frame_id); |
1132 GlobalRequestID new_request_id(child_id, request_id); | 1139 GlobalRequestID new_request_id(child_id, request_id); |
1133 | 1140 |
1134 // Clear out data that depends on |info| before updating it. | 1141 // Clear out data that depends on |info| before updating it. |
1135 // We always need to move the memory stats to the new process. In contrast, | 1142 // We always need to move the memory stats to the new process. In contrast, |
1136 // stats.num_requests is only tracked for some requests (those that require | 1143 // stats.num_requests is only tracked for some requests (those that require |
1137 // file descriptors for their shared memory buffer). | 1144 // file descriptors for their shared memory buffer). |
1138 IncrementOutstandingRequestsMemory(-1, *info); | 1145 IncrementOutstandingRequestsMemory(-1, *info); |
1139 bool should_update_count = info->counted_as_in_flight_request(); | 1146 bool should_update_count = info->counted_as_in_flight_request(); |
1140 if (should_update_count) | 1147 if (should_update_count) |
1141 IncrementOutstandingRequestsCount(-1, info); | 1148 IncrementOutstandingRequestsCount(-1, info); |
1142 | 1149 |
1143 DCHECK(pending_loaders_.find(old_request_id) == iter); | 1150 DCHECK(pending_loaders_.find(old_request_id) == iter); |
1144 std::unique_ptr<ResourceLoader> loader = std::move(iter->second); | 1151 std::unique_ptr<ResourceLoader> loader = std::move(iter->second); |
1145 ResourceLoader* loader_ptr = loader.get(); | 1152 ResourceLoader* loader_ptr = loader.get(); |
1146 pending_loaders_.erase(iter); | 1153 pending_loaders_.erase(iter); |
1147 | 1154 |
1148 // ResourceHandlers should always get state related to the request from the | 1155 // ResourceHandlers should always get state related to the request from the |
1149 // ResourceRequestInfo rather than caching it locally. This lets us update | 1156 // ResourceRequestInfo rather than caching it locally. This lets us update |
1150 // the info object when a transfer occurs. | 1157 // the info object when a transfer occurs. |
1151 info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id, | 1158 info->UpdateForTransfer(route_id, request_data.render_frame_id, |
1152 request_data.origin_pid, request_id, | 1159 request_data.origin_pid, request_id, |
1153 filter_->GetWeakPtr()); | 1160 requester_info->clone()); |
1154 | 1161 |
1155 // Update maps that used the old IDs, if necessary. Some transfers in tests | 1162 // Update maps that used the old IDs, if necessary. Some transfers in tests |
1156 // do not actually use a different ID, so not all maps need to be updated. | 1163 // do not actually use a different ID, so not all maps need to be updated. |
1157 pending_loaders_[new_request_id] = std::move(loader); | 1164 pending_loaders_[new_request_id] = std::move(loader); |
1158 IncrementOutstandingRequestsMemory(1, *info); | 1165 IncrementOutstandingRequestsMemory(1, *info); |
1159 if (should_update_count) | 1166 if (should_update_count) |
1160 IncrementOutstandingRequestsCount(1, info); | 1167 IncrementOutstandingRequestsCount(1, info); |
1161 if (old_routing_id != new_routing_id) { | 1168 if (old_routing_id != new_routing_id) { |
1162 if (blocked_loaders_map_.find(old_routing_id) != | 1169 if (blocked_loaders_map_.find(old_routing_id) != |
1163 blocked_loaders_map_.end()) { | 1170 blocked_loaders_map_.end()) { |
1164 blocked_loaders_map_[new_routing_id] = | 1171 blocked_loaders_map_[new_routing_id] = |
1165 std::move(blocked_loaders_map_[old_routing_id]); | 1172 std::move(blocked_loaders_map_[old_routing_id]); |
1166 blocked_loaders_map_.erase(old_routing_id); | 1173 blocked_loaders_map_.erase(old_routing_id); |
1167 } | 1174 } |
1168 } | 1175 } |
1169 if (old_request_id != new_request_id) { | 1176 if (old_request_id != new_request_id) { |
1170 DelegateMap::iterator it = delegate_map_.find(old_request_id); | 1177 DelegateMap::iterator it = delegate_map_.find(old_request_id); |
1171 if (it != delegate_map_.end()) { | 1178 if (it != delegate_map_.end()) { |
1172 // Tell each delegate that the request ID has changed. | 1179 // Tell each delegate that the request ID has changed. |
1173 for (auto& delegate : *it->second) | 1180 for (auto& delegate : *it->second) |
1174 delegate.set_request_id(new_request_id); | 1181 delegate.set_request_id(new_request_id); |
1175 // Now store the observer list under the new request ID. | 1182 // Now store the observer list under the new request ID. |
1176 delegate_map_[new_request_id] = delegate_map_[old_request_id]; | 1183 delegate_map_[new_request_id] = delegate_map_[old_request_id]; |
1177 delegate_map_.erase(old_request_id); | 1184 delegate_map_.erase(old_request_id); |
1178 } | 1185 } |
1179 } | 1186 } |
1180 | 1187 |
1181 AppCacheInterceptor::CompleteCrossSiteTransfer( | 1188 AppCacheInterceptor::CompleteCrossSiteTransfer( |
1182 loader_ptr->request(), | 1189 loader_ptr->request(), child_id, request_data.appcache_host_id, |
1183 child_id, | 1190 requester_info); |
1184 request_data.appcache_host_id, | |
1185 filter_); | |
1186 | 1191 |
1187 ServiceWorkerRequestHandler* handler = | 1192 ServiceWorkerRequestHandler* handler = |
1188 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); | 1193 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); |
1189 if (handler) { | 1194 if (handler) { |
1190 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { | 1195 if (!handler->SanityCheckIsSameContext( |
1196 requester_info->service_worker_context())) { | |
1191 bad_message::ReceivedBadMessage( | 1197 bad_message::ReceivedBadMessage( |
1192 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); | 1198 requester_info->filter(), bad_message::RDHI_WRONG_STORAGE_PARTITION); |
1193 } else { | 1199 } else { |
1194 handler->CompleteCrossSiteTransfer( | 1200 handler->CompleteCrossSiteTransfer( |
1195 child_id, request_data.service_worker_provider_id); | 1201 child_id, request_data.service_worker_provider_id); |
1196 } | 1202 } |
1197 } | 1203 } |
1198 } | 1204 } |
1199 | 1205 |
1200 void ResourceDispatcherHostImpl::CompleteTransfer( | 1206 void ResourceDispatcherHostImpl::CompleteTransfer( |
1207 const ResourceRequesterInfo* requester_info, | |
1201 int request_id, | 1208 int request_id, |
1202 const ResourceRequest& request_data, | 1209 const ResourceRequest& request_data, |
1203 int route_id) { | 1210 int route_id) { |
1211 DCHECK(requester_info->IsRenderer()); | |
1204 // Caller should ensure that |request_data| is associated with a transfer. | 1212 // Caller should ensure that |request_data| is associated with a transfer. |
1205 DCHECK(request_data.transferred_request_child_id != -1 || | 1213 DCHECK(request_data.transferred_request_child_id != -1 || |
1206 request_data.transferred_request_request_id != -1); | 1214 request_data.transferred_request_request_id != -1); |
1207 | 1215 |
1208 bool is_navigational_request = | 1216 bool is_navigational_request = |
1209 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME || | 1217 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME || |
1210 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | 1218 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; |
1211 if (!is_navigational_request) { | 1219 if (!is_navigational_request) { |
1212 // Transfers apply only to navigational requests - the renderer seems to | 1220 // Transfers apply only to navigational requests - the renderer seems to |
1213 // have sent bogus IPC data. | 1221 // have sent bogus IPC data. |
1214 bad_message::ReceivedBadMessage( | 1222 bad_message::ReceivedBadMessage( |
1215 filter_, bad_message::RDH_TRANSFERRING_NONNAVIGATIONAL_REQUEST); | 1223 requester_info->filter(), |
1224 bad_message::RDH_TRANSFERRING_NONNAVIGATIONAL_REQUEST); | |
1216 return; | 1225 return; |
1217 } | 1226 } |
1218 | 1227 |
1219 // Attempt to find a loader associated with the deferred transfer request. | 1228 // Attempt to find a loader associated with the deferred transfer request. |
1220 LoaderMap::iterator it = pending_loaders_.find( | 1229 LoaderMap::iterator it = pending_loaders_.find( |
1221 GlobalRequestID(request_data.transferred_request_child_id, | 1230 GlobalRequestID(request_data.transferred_request_child_id, |
1222 request_data.transferred_request_request_id)); | 1231 request_data.transferred_request_request_id)); |
1223 if (it == pending_loaders_.end()) { | 1232 if (it == pending_loaders_.end()) { |
1224 // Renderer sent transferred_request_request_id and/or | 1233 // Renderer sent transferred_request_request_id and/or |
1225 // transferred_request_child_id that doesn't have a corresponding entry on | 1234 // transferred_request_child_id that doesn't have a corresponding entry on |
1226 // the browser side. | 1235 // the browser side. |
1227 // TODO(lukasza): https://crbug.com/659613: Need to understand the scenario | 1236 // TODO(lukasza): https://crbug.com/659613: Need to understand the scenario |
1228 // that can lead here (and then attempt to reintroduce a renderer kill | 1237 // that can lead here (and then attempt to reintroduce a renderer kill |
1229 // below). | 1238 // below). |
1230 return; | 1239 return; |
1231 } | 1240 } |
1232 ResourceLoader* pending_loader = it->second.get(); | 1241 ResourceLoader* pending_loader = it->second.get(); |
1233 | 1242 |
1234 if (!pending_loader->is_transferring()) { | 1243 if (!pending_loader->is_transferring()) { |
1235 // Renderer sent transferred_request_request_id and/or | 1244 // Renderer sent transferred_request_request_id and/or |
1236 // transferred_request_child_id that doesn't correspond to an actually | 1245 // transferred_request_child_id that doesn't correspond to an actually |
1237 // transferring loader on the browser side. | 1246 // transferring loader on the browser side. |
1238 base::debug::Alias(pending_loader); | 1247 base::debug::Alias(pending_loader); |
1239 bad_message::ReceivedBadMessage(filter_, | 1248 bad_message::ReceivedBadMessage(requester_info->filter(), |
1240 bad_message::RDH_REQUEST_NOT_TRANSFERRING); | 1249 bad_message::RDH_REQUEST_NOT_TRANSFERRING); |
1241 return; | 1250 return; |
1242 } | 1251 } |
1243 | 1252 |
1244 // If the request is transferring to a new process, we can update our | 1253 // If the request is transferring to a new process, we can update our |
1245 // state and let it resume with its existing ResourceHandlers. | 1254 // state and let it resume with its existing ResourceHandlers. |
1246 UpdateRequestForTransfer(filter_->child_id(), route_id, request_id, | 1255 UpdateRequestForTransfer(requester_info, route_id, request_id, request_data, |
1247 request_data, it); | 1256 it); |
1248 pending_loader->CompleteTransfer(); | 1257 pending_loader->CompleteTransfer(); |
1249 } | 1258 } |
1250 | 1259 |
1251 void ResourceDispatcherHostImpl::BeginRequest( | 1260 void ResourceDispatcherHostImpl::BeginRequest( |
1261 const ResourceRequesterInfo* requester_info, | |
1252 int request_id, | 1262 int request_id, |
1253 const ResourceRequest& request_data, | 1263 const ResourceRequest& request_data, |
1254 const SyncLoadResultCallback& sync_result_handler, // only valid for sync | 1264 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
1255 int route_id, | 1265 int route_id, |
1256 mojom::URLLoaderAssociatedRequest mojo_request, | 1266 mojom::URLLoaderAssociatedRequest mojo_request, |
1257 mojom::URLLoaderClientAssociatedPtr url_loader_client) { | 1267 mojom::URLLoaderClientAssociatedPtr url_loader_client) { |
1258 int process_type = filter_->process_type(); | 1268 DCHECK(requester_info->IsRenderer()); |
1259 int child_id = filter_->child_id(); | 1269 int child_id = requester_info->child_id(); |
1260 | 1270 |
1261 // Reject request id that's currently in use. | 1271 // Reject request id that's currently in use. |
1262 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { | 1272 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { |
1263 bad_message::ReceivedBadMessage(filter_, | 1273 bad_message::ReceivedBadMessage(requester_info->filter(), |
1264 bad_message::RDH_INVALID_REQUEST_ID); | 1274 bad_message::RDH_INVALID_REQUEST_ID); |
1265 return; | 1275 return; |
1266 } | 1276 } |
1267 | 1277 |
1268 // PlzNavigate: reject invalid renderer main resource request. | 1278 // PlzNavigate: reject invalid renderer main resource request. |
1269 bool is_navigation_stream_request = | 1279 bool is_navigation_stream_request = |
1270 IsBrowserSideNavigationEnabled() && | 1280 IsBrowserSideNavigationEnabled() && |
1271 IsResourceTypeFrame(request_data.resource_type); | 1281 IsResourceTypeFrame(request_data.resource_type); |
1272 // The process_type check is to ensure that unittests are not blocked from | 1282 if (is_navigation_stream_request && |
1273 // issuing http requests. | 1283 !request_data.resource_body_stream_url.SchemeIs(url::kBlobScheme)) { |
1274 if ((process_type == PROCESS_TYPE_RENDERER) && is_navigation_stream_request | 1284 bad_message::ReceivedBadMessage(requester_info->filter(), |
1275 && !request_data.resource_body_stream_url.SchemeIs(url::kBlobScheme)) { | 1285 bad_message::RDH_INVALID_URL); |
1276 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_INVALID_URL); | |
1277 return; | 1286 return; |
1278 } | 1287 } |
1279 | 1288 |
1280 // Reject invalid priority. | 1289 // Reject invalid priority. |
1281 if (request_data.priority < net::MINIMUM_PRIORITY || | 1290 if (request_data.priority < net::MINIMUM_PRIORITY || |
1282 request_data.priority > net::MAXIMUM_PRIORITY) { | 1291 request_data.priority > net::MAXIMUM_PRIORITY) { |
1283 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_INVALID_PRIORITY); | 1292 bad_message::ReceivedBadMessage(requester_info->filter(), |
1293 bad_message::RDH_INVALID_PRIORITY); | |
1284 return; | 1294 return; |
1285 } | 1295 } |
1286 | 1296 |
1287 // If we crash here, figure out what URL the renderer was requesting. | 1297 // If we crash here, figure out what URL the renderer was requesting. |
1288 // http://crbug.com/91398 | 1298 // http://crbug.com/91398 |
1289 char url_buf[128]; | 1299 char url_buf[128]; |
1290 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); | 1300 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); |
1291 base::debug::Alias(url_buf); | 1301 base::debug::Alias(url_buf); |
1292 | 1302 |
1293 // If the request that's coming in is being transferred from another process, | 1303 // If the request that's coming in is being transferred from another process, |
1294 // we want to reuse and resume the old loader rather than start a new one. | 1304 // we want to reuse and resume the old loader rather than start a new one. |
1295 if (request_data.transferred_request_child_id != -1 || | 1305 if (request_data.transferred_request_child_id != -1 || |
1296 request_data.transferred_request_request_id != -1) { | 1306 request_data.transferred_request_request_id != -1) { |
1297 // TODO(yhirano): Make mojo work for this case. | 1307 // TODO(yhirano): Make mojo work for this case. |
1298 DCHECK(!url_loader_client); | 1308 DCHECK(!url_loader_client); |
1299 | 1309 |
1300 CompleteTransfer(request_id, request_data, route_id); | 1310 CompleteTransfer(requester_info, request_id, request_data, route_id); |
1301 return; | 1311 return; |
1302 } | 1312 } |
1303 | 1313 |
1304 ResourceContext* resource_context = NULL; | 1314 ResourceContext* resource_context = NULL; |
1305 net::URLRequestContext* request_context = NULL; | 1315 net::URLRequestContext* request_context = NULL; |
1306 filter_->GetContexts(request_data.resource_type, &resource_context, | 1316 requester_info->GetContexts(request_data.resource_type, &resource_context, |
1307 &request_context); | 1317 &request_context); |
1308 | 1318 |
1309 // Parse the headers before calling ShouldServiceRequest, so that they are | 1319 // Parse the headers before calling ShouldServiceRequest, so that they are |
1310 // available to be validated. | 1320 // available to be validated. |
1311 net::HttpRequestHeaders headers; | 1321 net::HttpRequestHeaders headers; |
1312 headers.AddHeadersFromString(request_data.headers); | 1322 headers.AddHeadersFromString(request_data.headers); |
1313 | 1323 |
1314 if (is_shutdown_ || | 1324 if (is_shutdown_ || |
1315 !ShouldServiceRequest(process_type, child_id, request_data, headers, | 1325 !ShouldServiceRequest(child_id, request_data, headers, requester_info, |
1316 filter_, resource_context)) { | 1326 resource_context)) { |
1317 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, | 1327 AbortRequestBeforeItStarts(requester_info->filter(), sync_result_handler, |
1318 std::move(url_loader_client)); | 1328 request_id, std::move(url_loader_client)); |
1319 return; | 1329 return; |
1320 } | 1330 } |
1321 // Check if we have a registered interceptor for the headers passed in. If | 1331 // Check if we have a registered interceptor for the headers passed in. If |
1322 // yes then we need to mark the current request as pending and wait for the | 1332 // yes then we need to mark the current request as pending and wait for the |
1323 // interceptor to invoke the callback with a status code indicating whether | 1333 // interceptor to invoke the callback with a status code indicating whether |
1324 // the request needs to be aborted or continued. | 1334 // the request needs to be aborted or continued. |
1325 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { | 1335 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { |
1326 HeaderInterceptorMap::iterator index = | 1336 HeaderInterceptorMap::iterator index = |
1327 http_header_interceptor_map_.find(it.name()); | 1337 http_header_interceptor_map_.find(it.name()); |
1328 if (index != http_header_interceptor_map_.end()) { | 1338 if (index != http_header_interceptor_map_.end()) { |
1329 HeaderInterceptorInfo& interceptor_info = index->second; | 1339 HeaderInterceptorInfo& interceptor_info = index->second; |
1330 | 1340 |
1331 bool call_interceptor = true; | 1341 bool call_interceptor = true; |
1332 if (!interceptor_info.starts_with.empty()) { | 1342 if (!interceptor_info.starts_with.empty()) { |
1333 call_interceptor = | 1343 call_interceptor = |
1334 base::StartsWith(it.value(), interceptor_info.starts_with, | 1344 base::StartsWith(it.value(), interceptor_info.starts_with, |
1335 base::CompareCase::INSENSITIVE_ASCII); | 1345 base::CompareCase::INSENSITIVE_ASCII); |
1336 } | 1346 } |
1337 if (call_interceptor) { | 1347 if (call_interceptor) { |
1338 interceptor_info.interceptor.Run( | 1348 interceptor_info.interceptor.Run( |
1339 it.name(), it.value(), child_id, resource_context, | 1349 it.name(), it.value(), child_id, resource_context, |
1340 base::Bind(&ResourceDispatcherHostImpl::ContinuePendingBeginRequest, | 1350 base::Bind(&ResourceDispatcherHostImpl::ContinuePendingBeginRequest, |
1341 base::Unretained(this), request_id, request_data, | 1351 base::Unretained(this), |
1342 sync_result_handler, route_id, headers, | 1352 base::Passed(requester_info->clone()), request_id, |
1353 request_data, sync_result_handler, route_id, headers, | |
1343 base::Passed(std::move(mojo_request)), | 1354 base::Passed(std::move(mojo_request)), |
1344 base::Passed(std::move(url_loader_client)))); | 1355 base::Passed(std::move(url_loader_client)))); |
1345 return; | 1356 return; |
1346 } | 1357 } |
1347 } | 1358 } |
1348 } | 1359 } |
1349 ContinuePendingBeginRequest(request_id, request_data, sync_result_handler, | 1360 ContinuePendingBeginRequest(requester_info->clone(), request_id, request_data, |
mmenke
2016/11/17 16:27:19
Should we make requester_info refcounted, and pass
horo
2016/11/17 17:50:27
Done.
| |
1350 route_id, headers, std::move(mojo_request), | 1361 sync_result_handler, route_id, headers, |
1362 std::move(mojo_request), | |
1351 std::move(url_loader_client), true, 0); | 1363 std::move(url_loader_client), true, 0); |
1352 } | 1364 } |
1353 | 1365 |
1354 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( | 1366 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( |
1367 std::unique_ptr<ResourceRequesterInfo> requester_info, | |
1355 int request_id, | 1368 int request_id, |
1356 const ResourceRequest& request_data, | 1369 const ResourceRequest& request_data, |
1357 const SyncLoadResultCallback& sync_result_handler, // only valid for sync | 1370 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
1358 int route_id, | 1371 int route_id, |
1359 const net::HttpRequestHeaders& headers, | 1372 const net::HttpRequestHeaders& headers, |
1360 mojom::URLLoaderAssociatedRequest mojo_request, | 1373 mojom::URLLoaderAssociatedRequest mojo_request, |
1361 mojom::URLLoaderClientAssociatedPtr url_loader_client, | 1374 mojom::URLLoaderClientAssociatedPtr url_loader_client, |
1362 bool continue_request, | 1375 bool continue_request, |
1363 int error_code) { | 1376 int error_code) { |
1377 DCHECK(requester_info->IsRenderer()); | |
1364 if (!continue_request) { | 1378 if (!continue_request) { |
1365 // TODO(ananta): Find a way to specify the right error code here. Passing | 1379 // TODO(ananta): Find a way to specify the right error code here. Passing |
1366 // in a non-content error code is not safe. | 1380 // in a non-content error code is not safe. |
1367 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_ILLEGAL_ORIGIN); | 1381 bad_message::ReceivedBadMessage(requester_info->filter(), |
1368 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, | 1382 bad_message::RDH_ILLEGAL_ORIGIN); |
1369 std::move(url_loader_client)); | 1383 AbortRequestBeforeItStarts(requester_info->filter(), sync_result_handler, |
1384 request_id, std::move(url_loader_client)); | |
1370 return; | 1385 return; |
1371 } | 1386 } |
1372 | 1387 int child_id = requester_info->child_id(); |
1373 int process_type = filter_->process_type(); | |
1374 int child_id = filter_->child_id(); | |
1375 | 1388 |
1376 bool is_navigation_stream_request = | 1389 bool is_navigation_stream_request = |
1377 IsBrowserSideNavigationEnabled() && | 1390 IsBrowserSideNavigationEnabled() && |
1378 IsResourceTypeFrame(request_data.resource_type) && | 1391 IsResourceTypeFrame(request_data.resource_type); |
1379 process_type == PROCESS_TYPE_RENDERER; | |
1380 | 1392 |
1381 ResourceContext* resource_context = NULL; | 1393 ResourceContext* resource_context = NULL; |
1382 net::URLRequestContext* request_context = NULL; | 1394 net::URLRequestContext* request_context = NULL; |
1383 filter_->GetContexts(request_data.resource_type, &resource_context, | 1395 requester_info->GetContexts(request_data.resource_type, &resource_context, |
1384 &request_context); | 1396 &request_context); |
1385 | 1397 |
1386 // Allow the observer to block/handle the request. | 1398 // Allow the observer to block/handle the request. |
1387 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, | 1399 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, |
1388 request_data.url, | 1400 request_data.url, |
1389 request_data.resource_type, | 1401 request_data.resource_type, |
1390 resource_context)) { | 1402 resource_context)) { |
1391 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, | 1403 AbortRequestBeforeItStarts(requester_info->filter(), sync_result_handler, |
1392 std::move(url_loader_client)); | 1404 request_id, std::move(url_loader_client)); |
1393 return; | 1405 return; |
1394 } | 1406 } |
1395 | 1407 |
1396 // Construct the request. | 1408 // Construct the request. |
1397 std::unique_ptr<net::URLRequest> new_request = request_context->CreateRequest( | 1409 std::unique_ptr<net::URLRequest> new_request = request_context->CreateRequest( |
1398 is_navigation_stream_request ? request_data.resource_body_stream_url | 1410 is_navigation_stream_request ? request_data.resource_body_stream_url |
1399 : request_data.url, | 1411 : request_data.url, |
1400 request_data.priority, nullptr); | 1412 request_data.priority, nullptr); |
1401 | 1413 |
1402 // PlzNavigate: Always set the method to GET when gaining access to the | 1414 // PlzNavigate: Always set the method to GET when gaining access to the |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1437 // ComputeReferrerForRedirect). | 1449 // ComputeReferrerForRedirect). |
1438 if (!is_navigation_stream_request) { | 1450 if (!is_navigation_stream_request) { |
1439 const Referrer referrer( | 1451 const Referrer referrer( |
1440 request_data.referrer, request_data.referrer_policy); | 1452 request_data.referrer, request_data.referrer_policy); |
1441 SetReferrerForRequest(new_request.get(), referrer); | 1453 SetReferrerForRequest(new_request.get(), referrer); |
1442 } | 1454 } |
1443 | 1455 |
1444 new_request->SetExtraRequestHeaders(headers); | 1456 new_request->SetExtraRequestHeaders(headers); |
1445 | 1457 |
1446 storage::BlobStorageContext* blob_context = | 1458 storage::BlobStorageContext* blob_context = |
1447 GetBlobStorageContext(filter_->blob_storage_context()); | 1459 GetBlobStorageContext(requester_info->blob_storage_context()); |
1448 // Resolve elements from request_body and prepare upload data. | 1460 // Resolve elements from request_body and prepare upload data. |
1449 if (request_data.request_body.get()) { | 1461 if (request_data.request_body.get()) { |
1450 // |blob_context| could be null when the request is from the plugins because | 1462 // |blob_context| could be null when the request is from the plugins because |
1451 // ResourceMessageFilters created in PluginProcessHost don't have the blob | 1463 // ResourceMessageFilters created in PluginProcessHost don't have the blob |
1452 // context. | 1464 // context. |
1453 if (blob_context) { | 1465 if (blob_context) { |
1454 // Attaches the BlobDataHandles to request_body not to free the blobs and | 1466 // Attaches the BlobDataHandles to request_body not to free the blobs and |
1455 // any attached shareable files until upload completion. These data will | 1467 // any attached shareable files until upload completion. These data will |
1456 // be used in UploadDataStream and ServiceWorkerURLRequestJob. | 1468 // be used in UploadDataStream and ServiceWorkerURLRequestJob. |
1457 AttachRequestBodyBlobDataHandles( | 1469 AttachRequestBodyBlobDataHandles( |
1458 request_data.request_body.get(), | 1470 request_data.request_body.get(), |
1459 blob_context); | 1471 blob_context); |
1460 } | 1472 } |
1461 new_request->set_upload(UploadDataStreamBuilder::Build( | 1473 new_request->set_upload(UploadDataStreamBuilder::Build( |
1462 request_data.request_body.get(), blob_context, | 1474 request_data.request_body.get(), blob_context, |
1463 filter_->file_system_context(), | 1475 requester_info->file_system_context(), |
1464 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); | 1476 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); |
1465 } | 1477 } |
1466 | 1478 |
1467 bool allow_download = request_data.allow_download && | 1479 bool allow_download = request_data.allow_download && |
1468 IsResourceTypeFrame(request_data.resource_type); | 1480 IsResourceTypeFrame(request_data.resource_type); |
1469 bool do_not_prompt_for_login = request_data.do_not_prompt_for_login; | 1481 bool do_not_prompt_for_login = request_data.do_not_prompt_for_login; |
1470 bool is_sync_load = !!sync_result_handler; | 1482 bool is_sync_load = !!sync_result_handler; |
1471 | 1483 |
1472 // Raw headers are sensitive, as they include Cookie/Set-Cookie, so only | 1484 // Raw headers are sensitive, as they include Cookie/Set-Cookie, so only |
1473 // allow requesting them if requester has ReadRawCookies permission. | 1485 // allow requesting them if requester has ReadRawCookies permission. |
1474 ChildProcessSecurityPolicyImpl* policy = | 1486 ChildProcessSecurityPolicyImpl* policy = |
1475 ChildProcessSecurityPolicyImpl::GetInstance(); | 1487 ChildProcessSecurityPolicyImpl::GetInstance(); |
1476 bool report_raw_headers = request_data.report_raw_headers; | 1488 bool report_raw_headers = request_data.report_raw_headers; |
1477 if (report_raw_headers && !policy->CanReadRawCookies(child_id)) { | 1489 if (report_raw_headers && !policy->CanReadRawCookies(child_id)) { |
1478 // TODO: crbug.com/523063 can we call bad_message::ReceivedBadMessage here? | 1490 // TODO: crbug.com/523063 can we call bad_message::ReceivedBadMessage here? |
1479 VLOG(1) << "Denied unauthorized request for raw headers"; | 1491 VLOG(1) << "Denied unauthorized request for raw headers"; |
1480 report_raw_headers = false; | 1492 report_raw_headers = false; |
1481 } | 1493 } |
1482 int load_flags = | 1494 int load_flags = BuildLoadFlagsForRequest(request_data, is_sync_load); |
1483 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load); | |
1484 if (request_data.resource_type == RESOURCE_TYPE_PREFETCH || | 1495 if (request_data.resource_type == RESOURCE_TYPE_PREFETCH || |
1485 request_data.resource_type == RESOURCE_TYPE_FAVICON) { | 1496 request_data.resource_type == RESOURCE_TYPE_FAVICON) { |
1486 do_not_prompt_for_login = true; | 1497 do_not_prompt_for_login = true; |
1487 } | 1498 } |
1488 if (request_data.resource_type == RESOURCE_TYPE_IMAGE && | 1499 if (request_data.resource_type == RESOURCE_TYPE_IMAGE && |
1489 HTTP_AUTH_RELATION_BLOCKED_CROSS == | 1500 HTTP_AUTH_RELATION_BLOCKED_CROSS == |
1490 HttpAuthRelationTypeOf(request_data.url, | 1501 HttpAuthRelationTypeOf(request_data.url, |
1491 request_data.first_party_for_cookies)) { | 1502 request_data.first_party_for_cookies)) { |
1492 // Prevent third-party image content from prompting for login, as this | 1503 // Prevent third-party image content from prompting for login, as this |
1493 // is often a scam to extract credentials for another domain from the user. | 1504 // is often a scam to extract credentials for another domain from the user. |
(...skipping 19 matching lines...) Expand all Loading... | |
1513 if (is_sync_load) { | 1524 if (is_sync_load) { |
1514 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY); | 1525 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY); |
1515 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0); | 1526 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0); |
1516 } else { | 1527 } else { |
1517 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); | 1528 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); |
1518 } | 1529 } |
1519 new_request->SetLoadFlags(load_flags); | 1530 new_request->SetLoadFlags(load_flags); |
1520 | 1531 |
1521 // Make extra info and read footer (contains request ID). | 1532 // Make extra info and read footer (contains request ID). |
1522 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( | 1533 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( |
1523 process_type, child_id, route_id, | 1534 requester_info->clone(), route_id, |
1524 -1, // frame_tree_node_id | 1535 -1, // frame_tree_node_id |
1525 request_data.origin_pid, request_id, request_data.render_frame_id, | 1536 request_data.origin_pid, request_id, request_data.render_frame_id, |
1526 request_data.is_main_frame, request_data.parent_is_main_frame, | 1537 request_data.is_main_frame, request_data.parent_is_main_frame, |
1527 request_data.resource_type, request_data.transition_type, | 1538 request_data.resource_type, request_data.transition_type, |
1528 request_data.should_replace_current_entry, | 1539 request_data.should_replace_current_entry, |
1529 false, // is download | 1540 false, // is download |
1530 false, // is stream | 1541 false, // is stream |
1531 allow_download, request_data.has_user_gesture, | 1542 allow_download, request_data.has_user_gesture, |
1532 request_data.enable_load_timing, request_data.enable_upload_progress, | 1543 request_data.enable_load_timing, request_data.enable_upload_progress, |
1533 do_not_prompt_for_login, request_data.referrer_policy, | 1544 do_not_prompt_for_login, request_data.referrer_policy, |
1534 request_data.visibility_state, resource_context, filter_->GetWeakPtr(), | 1545 request_data.visibility_state, resource_context, report_raw_headers, |
1535 report_raw_headers, !is_sync_load, | 1546 !is_sync_load, |
1536 IsUsingLoFi(request_data.lofi_state, delegate_, *new_request, | 1547 IsUsingLoFi(request_data.lofi_state, delegate_, *new_request, |
1537 resource_context, | 1548 resource_context, |
1538 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME), | 1549 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME), |
1539 support_async_revalidation ? request_data.headers : std::string(), | 1550 support_async_revalidation ? request_data.headers : std::string(), |
1540 request_data.request_body, request_data.initiated_in_secure_context); | 1551 request_data.request_body, request_data.initiated_in_secure_context); |
1541 // Request takes ownership. | 1552 // Request takes ownership. |
1542 extra_info->AssociateWithRequest(new_request.get()); | 1553 extra_info->AssociateWithRequest(new_request.get()); |
1543 | 1554 |
1544 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 1555 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
1545 // Hang on to a reference to ensure the blob is not released prior | 1556 // Hang on to a reference to ensure the blob is not released prior |
1546 // to the job being started. | 1557 // to the job being started. |
1547 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 1558 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
1548 new_request.get(), | 1559 new_request.get(), requester_info->blob_storage_context() |
1549 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( | 1560 ->context() |
1550 new_request->url())); | 1561 ->GetBlobDataFromPublicURL(new_request->url())); |
1551 } | 1562 } |
1552 | 1563 |
1553 // Initialize the service worker handler for the request. We don't use | 1564 // Initialize the service worker handler for the request. We don't use |
1554 // ServiceWorker for synchronous loads to avoid renderer deadlocks. | 1565 // ServiceWorker for synchronous loads to avoid renderer deadlocks. |
1555 const SkipServiceWorker should_skip_service_worker = | 1566 const SkipServiceWorker should_skip_service_worker = |
1556 is_sync_load ? SkipServiceWorker::ALL : request_data.skip_service_worker; | 1567 is_sync_load ? SkipServiceWorker::ALL : request_data.skip_service_worker; |
1557 ServiceWorkerRequestHandler::InitializeHandler( | 1568 ServiceWorkerRequestHandler::InitializeHandler( |
1558 new_request.get(), filter_->service_worker_context(), blob_context, | 1569 new_request.get(), requester_info->service_worker_context(), blob_context, |
1559 child_id, request_data.service_worker_provider_id, | 1570 child_id, request_data.service_worker_provider_id, |
1560 should_skip_service_worker != SkipServiceWorker::NONE, | 1571 should_skip_service_worker != SkipServiceWorker::NONE, |
1561 request_data.fetch_request_mode, request_data.fetch_credentials_mode, | 1572 request_data.fetch_request_mode, request_data.fetch_credentials_mode, |
1562 request_data.fetch_redirect_mode, request_data.resource_type, | 1573 request_data.fetch_redirect_mode, request_data.resource_type, |
1563 request_data.fetch_request_context_type, request_data.fetch_frame_type, | 1574 request_data.fetch_request_context_type, request_data.fetch_frame_type, |
1564 request_data.request_body); | 1575 request_data.request_body); |
1565 | 1576 |
1566 ForeignFetchRequestHandler::InitializeHandler( | 1577 ForeignFetchRequestHandler::InitializeHandler( |
1567 new_request.get(), filter_->service_worker_context(), blob_context, | 1578 new_request.get(), requester_info->service_worker_context(), blob_context, |
1568 child_id, request_data.service_worker_provider_id, | 1579 child_id, request_data.service_worker_provider_id, |
1569 should_skip_service_worker, request_data.fetch_request_mode, | 1580 should_skip_service_worker, request_data.fetch_request_mode, |
1570 request_data.fetch_credentials_mode, request_data.fetch_redirect_mode, | 1581 request_data.fetch_credentials_mode, request_data.fetch_redirect_mode, |
1571 request_data.resource_type, request_data.fetch_request_context_type, | 1582 request_data.resource_type, request_data.fetch_request_context_type, |
1572 request_data.fetch_frame_type, request_data.request_body, | 1583 request_data.fetch_frame_type, request_data.request_body, |
1573 request_data.initiated_in_secure_context); | 1584 request_data.initiated_in_secure_context); |
1574 | 1585 |
1575 // Have the appcache associate its extra info with the request. | 1586 // Have the appcache associate its extra info with the request. |
1576 AppCacheInterceptor::SetExtraRequestInfo( | 1587 AppCacheInterceptor::SetExtraRequestInfo( |
1577 new_request.get(), filter_->appcache_service(), child_id, | 1588 new_request.get(), requester_info->appcache_service(), child_id, |
1578 request_data.appcache_host_id, request_data.resource_type, | 1589 request_data.appcache_host_id, request_data.resource_type, |
1579 request_data.should_reset_appcache); | 1590 request_data.should_reset_appcache); |
1580 | 1591 |
1581 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler( | 1592 std::unique_ptr<ResourceHandler> handler(CreateResourceHandler( |
1582 new_request.get(), request_data, sync_result_handler, route_id, | 1593 requester_info.get(), new_request.get(), request_data, |
1583 process_type, child_id, resource_context, std::move(mojo_request), | 1594 sync_result_handler, route_id, child_id, resource_context, |
1584 std::move(url_loader_client))); | 1595 std::move(mojo_request), std::move(url_loader_client))); |
1585 | 1596 |
1586 if (handler) | 1597 if (handler) |
1587 BeginRequestInternal(std::move(new_request), std::move(handler)); | 1598 BeginRequestInternal(std::move(new_request), std::move(handler)); |
1588 } | 1599 } |
1589 | 1600 |
1590 std::unique_ptr<ResourceHandler> | 1601 std::unique_ptr<ResourceHandler> |
1591 ResourceDispatcherHostImpl::CreateResourceHandler( | 1602 ResourceDispatcherHostImpl::CreateResourceHandler( |
1603 const ResourceRequesterInfo* requester_info, | |
1592 net::URLRequest* request, | 1604 net::URLRequest* request, |
1593 const ResourceRequest& request_data, | 1605 const ResourceRequest& request_data, |
1594 const SyncLoadResultCallback& sync_result_handler, | 1606 const SyncLoadResultCallback& sync_result_handler, |
1595 int route_id, | 1607 int route_id, |
1596 int process_type, | |
1597 int child_id, | 1608 int child_id, |
1598 ResourceContext* resource_context, | 1609 ResourceContext* resource_context, |
1599 mojom::URLLoaderAssociatedRequest mojo_request, | 1610 mojom::URLLoaderAssociatedRequest mojo_request, |
1600 mojom::URLLoaderClientAssociatedPtr url_loader_client) { | 1611 mojom::URLLoaderClientAssociatedPtr url_loader_client) { |
1612 DCHECK(requester_info->IsRenderer()); | |
1601 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. | 1613 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. |
1602 tracked_objects::ScopedTracker tracking_profile( | 1614 tracked_objects::ScopedTracker tracking_profile( |
1603 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1615 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
1604 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); | 1616 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); |
1605 // Construct the IPC resource handler. | 1617 // Construct the IPC resource handler. |
1606 std::unique_ptr<ResourceHandler> handler; | 1618 std::unique_ptr<ResourceHandler> handler; |
1607 if (sync_result_handler) { | 1619 if (sync_result_handler) { |
1608 // download_to_file is not supported for synchronous requests. | 1620 // download_to_file is not supported for synchronous requests. |
1609 if (request_data.download_to_file) { | 1621 if (request_data.download_to_file) { |
1610 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD); | 1622 bad_message::ReceivedBadMessage(requester_info->filter(), |
1623 bad_message::RDH_BAD_DOWNLOAD); | |
1611 return std::unique_ptr<ResourceHandler>(); | 1624 return std::unique_ptr<ResourceHandler>(); |
1612 } | 1625 } |
1613 | 1626 |
1614 DCHECK(!mojo_request.is_pending()); | 1627 DCHECK(!mojo_request.is_pending()); |
1615 DCHECK(!url_loader_client); | 1628 DCHECK(!url_loader_client); |
1616 handler.reset(new SyncResourceHandler(request, sync_result_handler, this)); | 1629 handler.reset(new SyncResourceHandler(request, sync_result_handler, this)); |
1617 } else { | 1630 } else { |
1618 if (mojo_request.is_pending()) { | 1631 if (mojo_request.is_pending()) { |
1619 handler.reset(new MojoAsyncResourceHandler(request, this, | 1632 handler.reset(new MojoAsyncResourceHandler(request, this, |
1620 std::move(mojo_request), | 1633 std::move(mojo_request), |
(...skipping 18 matching lines...) Expand all Loading... | |
1639 std::unique_ptr<DetachableResourceHandler> detachable_handler = | 1652 std::unique_ptr<DetachableResourceHandler> detachable_handler = |
1640 base::MakeUnique<DetachableResourceHandler>( | 1653 base::MakeUnique<DetachableResourceHandler>( |
1641 request, | 1654 request, |
1642 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1655 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
1643 std::move(handler)); | 1656 std::move(handler)); |
1644 if (start_detached) | 1657 if (start_detached) |
1645 detachable_handler->Detach(); | 1658 detachable_handler->Detach(); |
1646 handler = std::move(detachable_handler); | 1659 handler = std::move(detachable_handler); |
1647 } | 1660 } |
1648 | 1661 |
1649 return AddStandardHandlers( | 1662 // PlzNavigate: do not add ResourceThrottles for main resource requests from |
1650 request, request_data.resource_type, resource_context, | 1663 // the renderer. Decisions about the navigation should have been done in the |
1651 request_data.fetch_request_context_type, filter_->appcache_service(), | 1664 // initial request. |
1652 child_id, route_id, std::move(handler)); | 1665 if (IsBrowserSideNavigationEnabled() && |
1666 IsResourceTypeFrame(request_data.resource_type)) { | |
1667 DCHECK(request->url().SchemeIs(url::kBlobScheme)); | |
1668 return handler; | |
1669 } | |
1670 | |
1671 return AddStandardHandlers(request, request_data.resource_type, | |
1672 resource_context, | |
1673 request_data.fetch_request_context_type, | |
1674 requester_info->appcache_service(), child_id, | |
1675 route_id, std::move(handler)); | |
1653 } | 1676 } |
1654 | 1677 |
1655 std::unique_ptr<ResourceHandler> | 1678 std::unique_ptr<ResourceHandler> |
1656 ResourceDispatcherHostImpl::AddStandardHandlers( | 1679 ResourceDispatcherHostImpl::AddStandardHandlers( |
1657 net::URLRequest* request, | 1680 net::URLRequest* request, |
1658 ResourceType resource_type, | 1681 ResourceType resource_type, |
1659 ResourceContext* resource_context, | 1682 ResourceContext* resource_context, |
1660 RequestContextType fetch_request_context_type, | 1683 RequestContextType fetch_request_context_type, |
1661 AppCacheService* appcache_service, | 1684 AppCacheService* appcache_service, |
1662 int child_id, | 1685 int child_id, |
1663 int route_id, | 1686 int route_id, |
1664 std::unique_ptr<ResourceHandler> handler) { | 1687 std::unique_ptr<ResourceHandler> handler) { |
1665 // PlzNavigate: do not add ResourceThrottles for main resource requests from | |
1666 // the renderer. Decisions about the navigation should have been done in the | |
1667 // initial request. | |
1668 bool is_renderer = | |
1669 filter_ ? (filter_->process_type() == PROCESS_TYPE_RENDERER) : false; | |
1670 if (is_renderer && IsBrowserSideNavigationEnabled() && | |
1671 IsResourceTypeFrame(resource_type)) { | |
1672 DCHECK(request->url().SchemeIs(url::kBlobScheme)); | |
1673 return handler; | |
1674 } | |
1675 | |
1676 // The InterceptingResourceHandler will replace its next handler with an | 1688 // The InterceptingResourceHandler will replace its next handler with an |
1677 // appropriate one based on the MIME type of the response if needed. It | 1689 // appropriate one based on the MIME type of the response if needed. It |
1678 // should be placed at the end of the chain, just before |handler|. | 1690 // should be placed at the end of the chain, just before |handler|. |
1679 handler.reset(new InterceptingResourceHandler(std::move(handler), request)); | 1691 handler.reset(new InterceptingResourceHandler(std::move(handler), request)); |
1680 InterceptingResourceHandler* intercepting_handler = | 1692 InterceptingResourceHandler* intercepting_handler = |
1681 static_cast<InterceptingResourceHandler*>(handler.get()); | 1693 static_cast<InterceptingResourceHandler*>(handler.get()); |
1682 | 1694 |
1683 ScopedVector<ResourceThrottle> throttles; | 1695 ScopedVector<ResourceThrottle> throttles; |
1684 | 1696 |
1685 // Add a NavigationResourceThrottle for navigations. | 1697 // Add a NavigationResourceThrottle for navigations. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1743 std::move(handler), this, plugin_service, intercepting_handler, request, | 1755 std::move(handler), this, plugin_service, intercepting_handler, request, |
1744 fetch_request_context_type)); | 1756 fetch_request_context_type)); |
1745 | 1757 |
1746 // Add the pre mime sniffing throttles. | 1758 // Add the pre mime sniffing throttles. |
1747 handler.reset(new ThrottlingResourceHandler( | 1759 handler.reset(new ThrottlingResourceHandler( |
1748 std::move(handler), request, std::move(pre_mime_sniffing_throttles))); | 1760 std::move(handler), request, std::move(pre_mime_sniffing_throttles))); |
1749 | 1761 |
1750 return handler; | 1762 return handler; |
1751 } | 1763 } |
1752 | 1764 |
1753 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { | 1765 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile( |
1754 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 1766 const ResourceRequesterInfo* requester_info, |
1767 int request_id) { | |
1768 UnregisterDownloadedTempFile(requester_info->child_id(), request_id); | |
1755 } | 1769 } |
1756 | 1770 |
1757 void ResourceDispatcherHostImpl::OnDidChangePriority( | 1771 void ResourceDispatcherHostImpl::OnDidChangePriority( |
1772 const ResourceRequesterInfo* requester_info, | |
1758 int request_id, | 1773 int request_id, |
1759 net::RequestPriority new_priority, | 1774 net::RequestPriority new_priority, |
1760 int intra_priority_value) { | 1775 int intra_priority_value) { |
1761 ResourceLoader* loader = GetLoader(filter_->child_id(), request_id); | 1776 ResourceLoader* loader = GetLoader(requester_info->child_id(), request_id); |
1762 // The request may go away before processing this message, so |loader| can | 1777 // The request may go away before processing this message, so |loader| can |
1763 // legitimately be null. | 1778 // legitimately be null. |
1764 if (!loader) | 1779 if (!loader) |
1765 return; | 1780 return; |
1766 | 1781 |
1767 scheduler_->ReprioritizeRequest(loader->request(), new_priority, | 1782 scheduler_->ReprioritizeRequest(loader->request(), new_priority, |
1768 intra_priority_value); | 1783 intra_priority_value); |
1769 } | 1784 } |
1770 | 1785 |
1771 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( | 1786 void ResourceDispatcherHostImpl::RegisterDownloadedTempFile( |
(...skipping 30 matching lines...) Expand all Loading... | |
1802 | 1817 |
1803 // Note that we don't remove the security bits here. This will be done | 1818 // Note that we don't remove the security bits here. This will be done |
1804 // when all file refs are deleted (see RegisterDownloadedTempFile). | 1819 // when all file refs are deleted (see RegisterDownloadedTempFile). |
1805 } | 1820 } |
1806 | 1821 |
1807 bool ResourceDispatcherHostImpl::Send(IPC::Message* message) { | 1822 bool ResourceDispatcherHostImpl::Send(IPC::Message* message) { |
1808 delete message; | 1823 delete message; |
1809 return false; | 1824 return false; |
1810 } | 1825 } |
1811 | 1826 |
1812 void ResourceDispatcherHostImpl::OnCancelRequest(int request_id) { | 1827 void ResourceDispatcherHostImpl::OnCancelRequest( |
1813 CancelRequestFromRenderer(GlobalRequestID(filter_->child_id(), request_id)); | 1828 const ResourceRequesterInfo* requester_info, |
1829 int request_id) { | |
1830 CancelRequestFromRenderer( | |
1831 GlobalRequestID(requester_info->child_id(), request_id)); | |
1814 } | 1832 } |
1815 | 1833 |
1816 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( | 1834 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( |
1817 int child_id, | 1835 int child_id, |
1818 int render_view_route_id, | 1836 int render_view_route_id, |
1819 int render_frame_route_id, | 1837 int render_frame_route_id, |
1820 bool download, | 1838 bool download, |
1821 ResourceContext* context) { | 1839 ResourceContext* context) { |
1822 return new ResourceRequestInfoImpl( | 1840 return new ResourceRequestInfoImpl( |
1823 PROCESS_TYPE_RENDERER, child_id, render_view_route_id, | 1841 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id), |
1842 render_view_route_id, | |
1824 -1, // frame_tree_node_id | 1843 -1, // frame_tree_node_id |
1825 0, MakeRequestID(), render_frame_route_id, | 1844 0, MakeRequestID(), render_frame_route_id, |
1826 false, // is_main_frame | 1845 false, // is_main_frame |
1827 false, // parent_is_main_frame | 1846 false, // parent_is_main_frame |
1828 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, | 1847 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, |
1829 false, // should_replace_current_entry | 1848 false, // should_replace_current_entry |
1830 download, // is_download | 1849 download, // is_download |
1831 false, // is_stream | 1850 false, // is_stream |
1832 download, // allow_download | 1851 download, // allow_download |
1833 false, // has_user_gesture | 1852 false, // has_user_gesture |
1834 false, // enable_load_timing | 1853 false, // enable_load_timing |
1835 false, // enable_upload_progress | 1854 false, // enable_upload_progress |
1836 false, // do_not_prompt_for_login | 1855 false, // do_not_prompt_for_login |
1837 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible, | 1856 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible, |
1838 context, | 1857 context, |
1839 base::WeakPtr<ResourceMessageFilter>(), // filter | 1858 false, // report_raw_headers |
1840 false, // report_raw_headers | 1859 true, // is_async |
1841 true, // is_async | 1860 false, // is_using_lofi |
1842 false, // is_using_lofi | 1861 std::string(), // original_headers |
1843 std::string(), // original_headers | 1862 nullptr, // body |
1844 nullptr, // body | 1863 false); // initiated_in_secure_context |
1845 false); // initiated_in_secure_context | |
1846 } | 1864 } |
1847 | 1865 |
1848 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, | 1866 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, |
1849 int route_id) { | 1867 int route_id) { |
1850 scheduler_->OnClientCreated(child_id, route_id); | 1868 scheduler_->OnClientCreated(child_id, route_id); |
1851 } | 1869 } |
1852 | 1870 |
1853 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, | 1871 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, |
1854 int route_id) { | 1872 int route_id) { |
1855 scheduler_->OnClientDeleted(child_id, route_id); | 1873 scheduler_->OnClientDeleted(child_id, route_id); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2175 body, blob_context, | 2193 body, blob_context, |
2176 nullptr, // file_system_context | 2194 nullptr, // file_system_context |
2177 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); | 2195 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); |
2178 } | 2196 } |
2179 | 2197 |
2180 // Make extra info and read footer (contains request ID). | 2198 // Make extra info and read footer (contains request ID). |
2181 // | 2199 // |
2182 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so | 2200 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so |
2183 // that IO thread -> UI thread hops will work. | 2201 // that IO thread -> UI thread hops will work. |
2184 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( | 2202 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( |
2185 PROCESS_TYPE_BROWSER, | 2203 ResourceRequesterInfo::CreateForBrowserSideNavigation( |
2186 -1, // child_id | 2204 service_worker_handle_core |
2205 ? service_worker_handle_core->context_wrapper() | |
2206 : scoped_refptr<ServiceWorkerContextWrapper>()), | |
2187 -1, // route_id | 2207 -1, // route_id |
2188 info.frame_tree_node_id, | 2208 info.frame_tree_node_id, |
2189 -1, // request_data.origin_pid, | 2209 -1, // request_data.origin_pid, |
2190 MakeRequestID(), | 2210 MakeRequestID(), |
2191 -1, // request_data.render_frame_id, | 2211 -1, // request_data.render_frame_id, |
2192 info.is_main_frame, info.parent_is_main_frame, resource_type, | 2212 info.is_main_frame, info.parent_is_main_frame, resource_type, |
2193 info.common_params.transition, | 2213 info.common_params.transition, |
2194 // should_replace_current_entry. This was only maintained at layer for | 2214 // should_replace_current_entry. This was only maintained at layer for |
2195 // request transfers and isn't needed for browser-side navigations. | 2215 // request transfers and isn't needed for browser-side navigations. |
2196 false, | 2216 false, |
2197 false, // is download | 2217 false, // is download |
2198 false, // is stream | 2218 false, // is stream |
2199 info.common_params.allow_download, info.begin_params.has_user_gesture, | 2219 info.common_params.allow_download, info.begin_params.has_user_gesture, |
2200 true, // enable_load_timing | 2220 true, // enable_load_timing |
2201 false, // enable_upload_progress | 2221 false, // enable_upload_progress |
2202 false, // do_not_prompt_for_login | 2222 false, // do_not_prompt_for_login |
2203 info.common_params.referrer.policy, | 2223 info.common_params.referrer.policy, |
2204 // TODO(davidben): This is only used for prerenders. Replace | 2224 // TODO(davidben): This is only used for prerenders. Replace |
2205 // is_showing with something for that. Or maybe it just comes from the | 2225 // is_showing with something for that. Or maybe it just comes from the |
2206 // same mechanism as the cookie one. | 2226 // same mechanism as the cookie one. |
2207 blink::WebPageVisibilityStateVisible, resource_context, | 2227 blink::WebPageVisibilityStateVisible, resource_context, |
2208 base::WeakPtr<ResourceMessageFilter>(), // filter | |
2209 info.report_raw_headers, | 2228 info.report_raw_headers, |
2210 true, // is_async | 2229 true, // is_async |
2211 IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request, | 2230 IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request, |
2212 resource_context, info.is_main_frame), | 2231 resource_context, info.is_main_frame), |
2213 // The original_headers field is for stale-while-revalidate but the | 2232 // The original_headers field is for stale-while-revalidate but the |
2214 // feature doesn't work with PlzNavigate, so it's just a placeholder | 2233 // feature doesn't work with PlzNavigate, so it's just a placeholder |
2215 // here. | 2234 // here. |
2216 // TODO(ricea): Make the feature work with stale-while-revalidate | 2235 // TODO(ricea): Make the feature work with stale-while-revalidate |
2217 // and clean this up. | 2236 // and clean this up. |
2218 std::string(), // original_headers | 2237 std::string(), // original_headers |
2219 info.common_params.post_data, | 2238 info.common_params.post_data, |
2220 // TODO(mek): Currently initiated_in_secure_context is only used for | 2239 // TODO(mek): Currently initiated_in_secure_context is only used for |
2221 // subresource requests, so it doesn't matter what value it gets here. | 2240 // subresource requests, so it doesn't matter what value it gets here. |
2222 // If in the future this changes this should be updated to somehow get a | 2241 // If in the future this changes this should be updated to somehow get a |
2223 // meaningful value. | 2242 // meaningful value. |
2224 false); // initiated_in_secure_context | 2243 false); // initiated_in_secure_context |
2225 extra_info->set_navigation_ui_data(std::move(navigation_ui_data)); | 2244 extra_info->set_navigation_ui_data(std::move(navigation_ui_data)); |
2226 | 2245 |
2227 if (service_worker_handle_core) { | |
2228 extra_info->set_service_worker_context( | |
2229 service_worker_handle_core->context_wrapper()); | |
2230 } | |
2231 | |
2232 // Request takes ownership. | 2246 // Request takes ownership. |
2233 extra_info->AssociateWithRequest(new_request.get()); | 2247 extra_info->AssociateWithRequest(new_request.get()); |
2234 | 2248 |
2235 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2249 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
2236 // Hang on to a reference to ensure the blob is not released prior | 2250 // Hang on to a reference to ensure the blob is not released prior |
2237 // to the job being started. | 2251 // to the job being started. |
2238 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2252 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2239 new_request.get(), | 2253 new_request.get(), |
2240 blob_context->GetBlobDataFromPublicURL(new_request->url())); | 2254 blob_context->GetBlobDataFromPublicURL(new_request->url())); |
2241 } | 2255 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2277 LoaderDelegate* loader_delegate) { | 2291 LoaderDelegate* loader_delegate) { |
2278 loader_delegate_ = loader_delegate; | 2292 loader_delegate_ = loader_delegate; |
2279 } | 2293 } |
2280 | 2294 |
2281 void ResourceDispatcherHostImpl::OnRenderFrameDeleted( | 2295 void ResourceDispatcherHostImpl::OnRenderFrameDeleted( |
2282 const GlobalFrameRoutingId& global_routing_id) { | 2296 const GlobalFrameRoutingId& global_routing_id) { |
2283 CancelRequestsForRoute(global_routing_id); | 2297 CancelRequestsForRoute(global_routing_id); |
2284 } | 2298 } |
2285 | 2299 |
2286 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo( | 2300 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo( |
2301 const ResourceRequesterInfo* requester_info, | |
2287 int routing_id, | 2302 int routing_id, |
2288 int request_id, | 2303 int request_id, |
2289 const ResourceRequest& request, | 2304 const ResourceRequest& request, |
2290 mojom::URLLoaderAssociatedRequest mojo_request, | 2305 mojom::URLLoaderAssociatedRequest mojo_request, |
2291 mojom::URLLoaderClientAssociatedPtr url_loader_client, | 2306 mojom::URLLoaderClientAssociatedPtr url_loader_client) { |
2292 ResourceMessageFilter* filter) { | 2307 OnRequestResourceInternal(requester_info, routing_id, request_id, request, |
2293 filter_ = filter; | |
2294 OnRequestResourceInternal(routing_id, request_id, request, | |
2295 std::move(mojo_request), | 2308 std::move(mojo_request), |
2296 std::move(url_loader_client)); | 2309 std::move(url_loader_client)); |
2297 filter_ = nullptr; | |
2298 } | 2310 } |
2299 | 2311 |
2300 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo( | 2312 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo( |
2313 const ResourceRequesterInfo* requester_info, | |
2301 int routing_id, | 2314 int routing_id, |
2302 int request_id, | 2315 int request_id, |
2303 const ResourceRequest& request_data, | 2316 const ResourceRequest& request_data, |
2304 ResourceMessageFilter* filter, | |
2305 const SyncLoadResultCallback& result_handler) { | 2317 const SyncLoadResultCallback& result_handler) { |
2306 filter_ = filter; | 2318 BeginRequest(requester_info, request_id, request_data, result_handler, |
2307 BeginRequest(request_id, request_data, result_handler, routing_id, | 2319 routing_id, nullptr, nullptr); |
2308 nullptr, nullptr); | |
2309 filter_ = nullptr; | |
2310 } | 2320 } |
2311 | 2321 |
2312 // static | 2322 // static |
2313 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( | 2323 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( |
2314 net::URLRequest* request) { | 2324 net::URLRequest* request) { |
2315 // The following fields should be a minor size contribution (experimentally | 2325 // The following fields should be a minor size contribution (experimentally |
2316 // on the order of 100). However since they are variable length, it could | 2326 // on the order of 100). However since they are variable length, it could |
2317 // in theory be a sizeable contribution. | 2327 // in theory be a sizeable contribution. |
2318 int strings_cost = 0; | 2328 int strings_cost = 0; |
2319 for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers()); | 2329 for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers()); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2698 DCHECK(it->second->HasObserver(delegate)); | 2708 DCHECK(it->second->HasObserver(delegate)); |
2699 it->second->RemoveObserver(delegate); | 2709 it->second->RemoveObserver(delegate); |
2700 if (!it->second->might_have_observers()) { | 2710 if (!it->second->might_have_observers()) { |
2701 delete it->second; | 2711 delete it->second; |
2702 delegate_map_.erase(it); | 2712 delegate_map_.erase(it); |
2703 } | 2713 } |
2704 } | 2714 } |
2705 | 2715 |
2706 int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest( | 2716 int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest( |
2707 const ResourceRequest& request_data, | 2717 const ResourceRequest& request_data, |
2708 int child_id, | |
2709 bool is_sync_load) { | 2718 bool is_sync_load) { |
2710 int load_flags = request_data.load_flags; | 2719 int load_flags = request_data.load_flags; |
2711 | 2720 |
2712 // Although EV status is irrelevant to sub-frames and sub-resources, we have | 2721 // Although EV status is irrelevant to sub-frames and sub-resources, we have |
2713 // to perform EV certificate verification on all resources because an HTTP | 2722 // to perform EV certificate verification on all resources because an HTTP |
2714 // keep-alive connection created to load a sub-frame or a sub-resource could | 2723 // keep-alive connection created to load a sub-frame or a sub-resource could |
2715 // be reused to load a main frame. | 2724 // be reused to load a main frame. |
2716 load_flags |= net::LOAD_VERIFY_EV_CERT; | 2725 load_flags |= net::LOAD_VERIFY_EV_CERT; |
2717 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { | 2726 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) { |
2718 load_flags |= net::LOAD_MAIN_FRAME_DEPRECATED; | 2727 load_flags |= net::LOAD_MAIN_FRAME_DEPRECATED; |
2719 } else if (request_data.resource_type == RESOURCE_TYPE_PREFETCH) { | 2728 } else if (request_data.resource_type == RESOURCE_TYPE_PREFETCH) { |
2720 load_flags |= net::LOAD_PREFETCH; | 2729 load_flags |= net::LOAD_PREFETCH; |
2721 } | 2730 } |
2722 | 2731 |
2723 if (is_sync_load) | 2732 if (is_sync_load) |
2724 load_flags |= net::LOAD_IGNORE_LIMITS; | 2733 load_flags |= net::LOAD_IGNORE_LIMITS; |
2725 | 2734 |
2726 return load_flags; | 2735 return load_flags; |
2727 } | 2736 } |
2728 | 2737 |
2729 bool ResourceDispatcherHostImpl::ShouldServiceRequest( | 2738 bool ResourceDispatcherHostImpl::ShouldServiceRequest( |
2730 int process_type, | |
2731 int child_id, | 2739 int child_id, |
2732 const ResourceRequest& request_data, | 2740 const ResourceRequest& request_data, |
2733 const net::HttpRequestHeaders& headers, | 2741 const net::HttpRequestHeaders& headers, |
2734 ResourceMessageFilter* filter, | 2742 const ResourceRequesterInfo* requester_info, |
2735 ResourceContext* resource_context) { | 2743 ResourceContext* resource_context) { |
2736 ChildProcessSecurityPolicyImpl* policy = | 2744 ChildProcessSecurityPolicyImpl* policy = |
2737 ChildProcessSecurityPolicyImpl::GetInstance(); | 2745 ChildProcessSecurityPolicyImpl::GetInstance(); |
2738 | 2746 |
2739 // Check if the renderer is permitted to request the requested URL. | 2747 // Check if the renderer is permitted to request the requested URL. |
2740 if (!policy->CanRequestURL(child_id, request_data.url)) { | 2748 if (!policy->CanRequestURL(child_id, request_data.url)) { |
2741 VLOG(1) << "Denied unauthorized request for " | 2749 VLOG(1) << "Denied unauthorized request for " |
2742 << request_data.url.possibly_invalid_spec(); | 2750 << request_data.url.possibly_invalid_spec(); |
2743 return false; | 2751 return false; |
2744 } | 2752 } |
2745 | 2753 |
2746 // Check if the renderer is using an illegal Origin header. If so, kill it. | 2754 // Check if the renderer is using an illegal Origin header. If so, kill it. |
2747 std::string origin_string; | 2755 std::string origin_string; |
2748 bool has_origin = | 2756 bool has_origin = |
2749 headers.GetHeader("Origin", &origin_string) && origin_string != "null"; | 2757 headers.GetHeader("Origin", &origin_string) && origin_string != "null"; |
2750 if (has_origin) { | 2758 if (has_origin) { |
2751 GURL origin(origin_string); | 2759 GURL origin(origin_string); |
2752 if (!policy->CanSetAsOriginHeader(child_id, origin)) { | 2760 if (!policy->CanSetAsOriginHeader(child_id, origin)) { |
2753 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; | 2761 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; |
2754 bad_message::ReceivedBadMessage(filter, bad_message::RDH_ILLEGAL_ORIGIN); | 2762 bad_message::ReceivedBadMessage(requester_info->filter(), |
2763 bad_message::RDH_ILLEGAL_ORIGIN); | |
2755 return false; | 2764 return false; |
2756 } | 2765 } |
2757 } | 2766 } |
2758 | 2767 |
2759 // Check if the renderer is permitted to upload the requested files. | 2768 // Check if the renderer is permitted to upload the requested files. |
2760 if (request_data.request_body.get()) { | 2769 if (request_data.request_body.get()) { |
2761 const std::vector<ResourceRequestBodyImpl::Element>* uploads = | 2770 const std::vector<ResourceRequestBodyImpl::Element>* uploads = |
2762 request_data.request_body->elements(); | 2771 request_data.request_body->elements(); |
2763 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; | 2772 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; |
2764 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | 2773 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
2765 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && | 2774 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
2766 !policy->CanReadFile(child_id, iter->path())) { | 2775 !policy->CanReadFile(child_id, iter->path())) { |
2767 NOTREACHED() << "Denied unauthorized upload of " | 2776 NOTREACHED() << "Denied unauthorized upload of " |
2768 << iter->path().value(); | 2777 << iter->path().value(); |
2769 return false; | 2778 return false; |
2770 } | 2779 } |
2771 if (iter->type() == | 2780 if (iter->type() == |
2772 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { | 2781 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { |
2773 storage::FileSystemURL url = | 2782 storage::FileSystemURL url = |
2774 filter->file_system_context()->CrackURL(iter->filesystem_url()); | 2783 requester_info->file_system_context()->CrackURL( |
2784 iter->filesystem_url()); | |
2775 if (!policy->CanReadFileSystemFile(child_id, url)) { | 2785 if (!policy->CanReadFileSystemFile(child_id, url)) { |
2776 NOTREACHED() << "Denied unauthorized upload of " | 2786 NOTREACHED() << "Denied unauthorized upload of " |
2777 << iter->filesystem_url().spec(); | 2787 << iter->filesystem_url().spec(); |
2778 return false; | 2788 return false; |
2779 } | 2789 } |
2780 } | 2790 } |
2781 } | 2791 } |
2782 } | 2792 } |
2783 return true; | 2793 return true; |
2784 } | 2794 } |
(...skipping 14 matching lines...) Expand all Loading... | |
2799 &throttles); | 2809 &throttles); |
2800 if (!throttles.empty()) { | 2810 if (!throttles.empty()) { |
2801 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2811 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2802 std::move(throttles))); | 2812 std::move(throttles))); |
2803 } | 2813 } |
2804 } | 2814 } |
2805 return handler; | 2815 return handler; |
2806 } | 2816 } |
2807 | 2817 |
2808 } // namespace content | 2818 } // namespace content |
OLD | NEW |