Chromium Code Reviews| Index: content/browser/loader/resource_dispatcher_host_impl.cc |
| diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc |
| index f29936fb96a456115560085cebc5c208caef6cfb..2d3315dd3eaa50dd34e902610e5c17e2012ddb9f 100644 |
| --- a/content/browser/loader/resource_dispatcher_host_impl.cc |
| +++ b/content/browser/loader/resource_dispatcher_host_impl.cc |
| @@ -1157,6 +1157,28 @@ void ResourceDispatcherHostImpl::BeginRequest( |
| } |
| if (!is_navigation_stream_request) { |
| + storage::BlobStorageContext* blob_context = |
| + GetBlobStorageContext(requester_info->blob_storage_context()); |
| + // Resolve elements from request_body and prepare upload data. |
| + if (request_data.request_body.get()) { |
| + // |blob_context| could be null when the request is from the plugins |
| + // because ResourceMessageFilters created in PluginProcessHost don't have |
| + // the blob context. |
| + if (blob_context) { |
| + // Attaches the BlobDataHandles to request_body not to free the blobs |
| + // and any attached shareable files until upload completion. These data |
| + // will be used in UploadDataStream and ServiceWorkerURLRequestJob. |
| + bool blobs_alive = AttachRequestBodyBlobDataHandles( |
| + request_data.request_body.get(), resource_context); |
| + if (!blobs_alive) { |
| + AbortRequestBeforeItStarts(requester_info->filter(), |
| + sync_result_handler, request_id, |
| + std::move(url_loader_client)); |
| + return; |
| + } |
| + } |
| + } |
| + |
| // Check if we have a registered interceptor for the headers passed in. If |
| // yes then we need to mark the current request as pending and wait for the |
| // interceptor to invoke the callback with a status code indicating whether |
| @@ -1181,7 +1203,7 @@ void ResourceDispatcherHostImpl::BeginRequest( |
| base::Unretained(this), requester_info, request_id, |
| request_data, sync_result_handler, route_id, headers, |
| base::Passed(std::move(mojo_request)), |
| - base::Passed(std::move(url_loader_client)))); |
| + base::Passed(std::move(url_loader_client)), blob_context)); |
| return; |
| } |
| } |
| @@ -1189,7 +1211,7 @@ void ResourceDispatcherHostImpl::BeginRequest( |
| } |
| ContinuePendingBeginRequest( |
| requester_info, request_id, request_data, sync_result_handler, route_id, |
| - headers, std::move(mojo_request), std::move(url_loader_client), |
| + headers, std::move(mojo_request), std::move(url_loader_client), nullptr, |
|
michaeln
2017/06/02 21:36:37
it's crashing because of this nullptr
|
| HeaderInterceptorResult::CONTINUE); |
| } |
| @@ -1202,6 +1224,7 @@ void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( |
| const net::HttpRequestHeaders& headers, |
| mojom::URLLoaderRequest mojo_request, |
| mojom::URLLoaderClientPtr url_loader_client, |
| + storage::BlobStorageContext* blob_context, |
| HeaderInterceptorResult interceptor_result) { |
| DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload()); |
| if (interceptor_result != HeaderInterceptorResult::CONTINUE) { |
| @@ -1218,7 +1241,6 @@ void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( |
| return; |
| } |
| int child_id = requester_info->child_id(); |
| - storage::BlobStorageContext* blob_context = nullptr; |
| bool allow_download = false; |
| bool do_not_prompt_for_login = false; |
| bool report_raw_headers = false; |
| @@ -1300,20 +1322,8 @@ void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( |
| new_request->SetExtraRequestHeaders(headers); |
| - blob_context = |
| - GetBlobStorageContext(requester_info->blob_storage_context()); |
|
michaeln
2017/06/02 21:36:37
you could retain the local variable and avoid the
dmurph
2017/06/02 23:00:33
Done.
|
| // Resolve elements from request_body and prepare upload data. |
| if (request_data.request_body.get()) { |
| - // |blob_context| could be null when the request is from the plugins |
| - // because ResourceMessageFilters created in PluginProcessHost don't have |
| - // the blob context. |
| - if (blob_context) { |
| - // Attaches the BlobDataHandles to request_body not to free the blobs |
| - // and any attached shareable files until upload completion. These data |
| - // will be used in UploadDataStream and ServiceWorkerURLRequestJob. |
| - AttachRequestBodyBlobDataHandles(request_data.request_body.get(), |
| - resource_context); |
| - } |
| new_request->set_upload(UploadDataStreamBuilder::Build( |
| request_data.request_body.get(), blob_context, |
| requester_info->file_system_context(), |
| @@ -2071,7 +2081,12 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest( |
| // Resolve elements from request_body and prepare upload data. |
| ResourceRequestBodyImpl* body = info.common_params.post_data.get(); |
| if (body) { |
| - AttachRequestBodyBlobDataHandles(body, resource_context); |
| + bool blobs_alive = AttachRequestBodyBlobDataHandles(body, resource_context); |
| + if (!blobs_alive) { |
| + new_request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); |
| + loader->NotifyRequestFailed(false, net::ERR_ABORTED); |
| + return; |
| + } |
| new_request->set_upload(UploadDataStreamBuilder::Build( |
| body, blob_context, upload_file_system_context, |
| BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); |