| 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 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 | 1150 |
| 1151 if (is_shutdown_ || | 1151 if (is_shutdown_ || |
| 1152 !ShouldServiceRequest(child_id, request_data, headers, requester_info, | 1152 !ShouldServiceRequest(child_id, request_data, headers, requester_info, |
| 1153 resource_context)) { | 1153 resource_context)) { |
| 1154 AbortRequestBeforeItStarts(requester_info->filter(), sync_result_handler, | 1154 AbortRequestBeforeItStarts(requester_info->filter(), sync_result_handler, |
| 1155 request_id, std::move(url_loader_client)); | 1155 request_id, std::move(url_loader_client)); |
| 1156 return; | 1156 return; |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 if (!is_navigation_stream_request) { | 1159 if (!is_navigation_stream_request) { |
| 1160 storage::BlobStorageContext* blob_context = |
| 1161 GetBlobStorageContext(requester_info->blob_storage_context()); |
| 1162 // Resolve elements from request_body and prepare upload data. |
| 1163 if (request_data.request_body.get()) { |
| 1164 // |blob_context| could be null when the request is from the plugins |
| 1165 // because ResourceMessageFilters created in PluginProcessHost don't have |
| 1166 // the blob context. |
| 1167 if (blob_context) { |
| 1168 // Attaches the BlobDataHandles to request_body not to free the blobs |
| 1169 // and any attached shareable files until upload completion. These data |
| 1170 // will be used in UploadDataStream and ServiceWorkerURLRequestJob. |
| 1171 bool blobs_alive = AttachRequestBodyBlobDataHandles( |
| 1172 request_data.request_body.get(), resource_context); |
| 1173 if (!blobs_alive) { |
| 1174 AbortRequestBeforeItStarts(requester_info->filter(), |
| 1175 sync_result_handler, request_id, |
| 1176 std::move(url_loader_client)); |
| 1177 return; |
| 1178 } |
| 1179 } |
| 1180 } |
| 1181 |
| 1160 // Check if we have a registered interceptor for the headers passed in. If | 1182 // Check if we have a registered interceptor for the headers passed in. If |
| 1161 // yes then we need to mark the current request as pending and wait for the | 1183 // yes then we need to mark the current request as pending and wait for the |
| 1162 // interceptor to invoke the callback with a status code indicating whether | 1184 // interceptor to invoke the callback with a status code indicating whether |
| 1163 // the request needs to be aborted or continued. | 1185 // the request needs to be aborted or continued. |
| 1164 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { | 1186 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { |
| 1165 HeaderInterceptorMap::iterator index = | 1187 HeaderInterceptorMap::iterator index = |
| 1166 http_header_interceptor_map_.find(it.name()); | 1188 http_header_interceptor_map_.find(it.name()); |
| 1167 if (index != http_header_interceptor_map_.end()) { | 1189 if (index != http_header_interceptor_map_.end()) { |
| 1168 HeaderInterceptorInfo& interceptor_info = index->second; | 1190 HeaderInterceptorInfo& interceptor_info = index->second; |
| 1169 | 1191 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 const Referrer referrer( | 1319 const Referrer referrer( |
| 1298 request_data.referrer, request_data.referrer_policy); | 1320 request_data.referrer, request_data.referrer_policy); |
| 1299 Referrer::SetReferrerForRequest(new_request.get(), referrer); | 1321 Referrer::SetReferrerForRequest(new_request.get(), referrer); |
| 1300 | 1322 |
| 1301 new_request->SetExtraRequestHeaders(headers); | 1323 new_request->SetExtraRequestHeaders(headers); |
| 1302 | 1324 |
| 1303 blob_context = | 1325 blob_context = |
| 1304 GetBlobStorageContext(requester_info->blob_storage_context()); | 1326 GetBlobStorageContext(requester_info->blob_storage_context()); |
| 1305 // Resolve elements from request_body and prepare upload data. | 1327 // Resolve elements from request_body and prepare upload data. |
| 1306 if (request_data.request_body.get()) { | 1328 if (request_data.request_body.get()) { |
| 1307 // |blob_context| could be null when the request is from the plugins | |
| 1308 // because ResourceMessageFilters created in PluginProcessHost don't have | |
| 1309 // the blob context. | |
| 1310 if (blob_context) { | |
| 1311 // Attaches the BlobDataHandles to request_body not to free the blobs | |
| 1312 // and any attached shareable files until upload completion. These data | |
| 1313 // will be used in UploadDataStream and ServiceWorkerURLRequestJob. | |
| 1314 AttachRequestBodyBlobDataHandles(request_data.request_body.get(), | |
| 1315 resource_context); | |
| 1316 } | |
| 1317 new_request->set_upload(UploadDataStreamBuilder::Build( | 1329 new_request->set_upload(UploadDataStreamBuilder::Build( |
| 1318 request_data.request_body.get(), blob_context, | 1330 request_data.request_body.get(), blob_context, |
| 1319 requester_info->file_system_context(), | 1331 requester_info->file_system_context(), |
| 1320 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); | 1332 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); |
| 1321 } | 1333 } |
| 1322 | 1334 |
| 1323 allow_download = request_data.allow_download && | 1335 allow_download = request_data.allow_download && |
| 1324 IsResourceTypeFrame(request_data.resource_type); | 1336 IsResourceTypeFrame(request_data.resource_type); |
| 1325 do_not_prompt_for_login = request_data.do_not_prompt_for_login; | 1337 do_not_prompt_for_login = request_data.do_not_prompt_for_login; |
| 1326 | 1338 |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 new_request->SetExtraRequestHeaders(headers); | 2076 new_request->SetExtraRequestHeaders(headers); |
| 2065 | 2077 |
| 2066 new_request->SetLoadFlags(load_flags); | 2078 new_request->SetLoadFlags(load_flags); |
| 2067 | 2079 |
| 2068 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | 2080 storage::BlobStorageContext* blob_context = GetBlobStorageContext( |
| 2069 GetChromeBlobStorageContextForResourceContext(resource_context)); | 2081 GetChromeBlobStorageContextForResourceContext(resource_context)); |
| 2070 | 2082 |
| 2071 // Resolve elements from request_body and prepare upload data. | 2083 // Resolve elements from request_body and prepare upload data. |
| 2072 ResourceRequestBodyImpl* body = info.common_params.post_data.get(); | 2084 ResourceRequestBodyImpl* body = info.common_params.post_data.get(); |
| 2073 if (body) { | 2085 if (body) { |
| 2074 AttachRequestBodyBlobDataHandles(body, resource_context); | 2086 bool blobs_alive = AttachRequestBodyBlobDataHandles(body, resource_context); |
| 2087 if (!blobs_alive) { |
| 2088 new_request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); |
| 2089 loader->NotifyRequestFailed(false, net::ERR_ABORTED); |
| 2090 return; |
| 2091 } |
| 2075 new_request->set_upload(UploadDataStreamBuilder::Build( | 2092 new_request->set_upload(UploadDataStreamBuilder::Build( |
| 2076 body, blob_context, upload_file_system_context, | 2093 body, blob_context, upload_file_system_context, |
| 2077 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); | 2094 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); |
| 2078 } | 2095 } |
| 2079 | 2096 |
| 2080 // Make extra info and read footer (contains request ID). | 2097 // Make extra info and read footer (contains request ID). |
| 2081 // | 2098 // |
| 2082 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so | 2099 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so |
| 2083 // that IO thread -> UI thread hops will work. | 2100 // that IO thread -> UI thread hops will work. |
| 2084 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( | 2101 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2686 &throttles); | 2703 &throttles); |
| 2687 if (!throttles.empty()) { | 2704 if (!throttles.empty()) { |
| 2688 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2705 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
| 2689 std::move(throttles))); | 2706 std::move(throttles))); |
| 2690 } | 2707 } |
| 2691 } | 2708 } |
| 2692 return handler; | 2709 return handler; |
| 2693 } | 2710 } |
| 2694 | 2711 |
| 2695 } // namespace content | 2712 } // namespace content |
| OLD | NEW |