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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2960023002: Remove SupportsUserData from ResourceRequestBodyImpl. (Closed)
Patch Set: Merge, response to comment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 21 matching lines...) Expand all
32 #include "base/profiler/scoped_tracker.h" 32 #include "base/profiler/scoped_tracker.h"
33 #include "base/stl_util.h" 33 #include "base/stl_util.h"
34 #include "base/strings/string_util.h" 34 #include "base/strings/string_util.h"
35 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 35 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
36 #include "base/threading/thread_task_runner_handle.h" 36 #include "base/threading/thread_task_runner_handle.h"
37 #include "base/timer/timer.h" 37 #include "base/timer/timer.h"
38 #include "content/browser/appcache/appcache_interceptor.h" 38 #include "content/browser/appcache/appcache_interceptor.h"
39 #include "content/browser/appcache/appcache_navigation_handle_core.h" 39 #include "content/browser/appcache/appcache_navigation_handle_core.h"
40 #include "content/browser/appcache/chrome_appcache_service.h" 40 #include "content/browser/appcache/chrome_appcache_service.h"
41 #include "content/browser/bad_message.h" 41 #include "content/browser/bad_message.h"
42 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
43 #include "content/browser/browsing_data/clear_site_data_throttle.h" 42 #include "content/browser/browsing_data/clear_site_data_throttle.h"
44 #include "content/browser/child_process_security_policy_impl.h" 43 #include "content/browser/child_process_security_policy_impl.h"
45 #include "content/browser/frame_host/navigation_request_info.h" 44 #include "content/browser/frame_host/navigation_request_info.h"
46 #include "content/browser/loader/async_resource_handler.h" 45 #include "content/browser/loader/async_resource_handler.h"
47 #include "content/browser/loader/detachable_resource_handler.h" 46 #include "content/browser/loader/detachable_resource_handler.h"
48 #include "content/browser/loader/intercepting_resource_handler.h" 47 #include "content/browser/loader/intercepting_resource_handler.h"
49 #include "content/browser/loader/loader_delegate.h" 48 #include "content/browser/loader/loader_delegate.h"
50 #include "content/browser/loader/mime_sniffing_resource_handler.h" 49 #include "content/browser/loader/mime_sniffing_resource_handler.h"
51 #include "content/browser/loader/mojo_async_resource_handler.h" 50 #include "content/browser/loader/mojo_async_resource_handler.h"
52 #include "content/browser/loader/navigation_resource_handler.h" 51 #include "content/browser/loader/navigation_resource_handler.h"
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 headers.AddHeadersFromString(request_data.headers); 1151 headers.AddHeadersFromString(request_data.headers);
1153 1152
1154 if (is_shutdown_ || 1153 if (is_shutdown_ ||
1155 !ShouldServiceRequest(child_id, request_data, headers, requester_info, 1154 !ShouldServiceRequest(child_id, request_data, headers, requester_info,
1156 resource_context)) { 1155 resource_context)) {
1157 AbortRequestBeforeItStarts(requester_info->filter(), sync_result_handler, 1156 AbortRequestBeforeItStarts(requester_info->filter(), sync_result_handler,
1158 request_id, std::move(url_loader_client)); 1157 request_id, std::move(url_loader_client));
1159 return; 1158 return;
1160 } 1159 }
1161 1160
1161 BlobHandles blob_handles;
1162 if (!is_navigation_stream_request) { 1162 if (!is_navigation_stream_request) {
1163 storage::BlobStorageContext* blob_context = 1163 storage::BlobStorageContext* blob_context =
1164 GetBlobStorageContext(requester_info->blob_storage_context()); 1164 GetBlobStorageContext(requester_info->blob_storage_context());
1165 // Resolve elements from request_body and prepare upload data. 1165 // Resolve elements from request_body and prepare upload data.
1166 if (request_data.request_body.get()) { 1166 if (request_data.request_body.get()) {
1167 // |blob_context| could be null when the request is from the plugins 1167 // |blob_context| could be null when the request is from the plugins
1168 // because ResourceMessageFilters created in PluginProcessHost don't have 1168 // because ResourceMessageFilters created in PluginProcessHost don't have
1169 // the blob context. 1169 // the blob context.
1170 if (blob_context) { 1170 if (blob_context) {
1171 // Attaches the BlobDataHandles to request_body not to free the blobs 1171 // Get BlobHandles to request_body to prevent blobs and any attached
1172 // and any attached shareable files until upload completion. These data 1172 // shareable files from being freed until upload completion. These data
1173 // will be used in UploadDataStream and ServiceWorkerURLRequestJob. 1173 // will be used in UploadDataStream and ServiceWorkerURLRequestJob.
1174 bool blobs_alive = AttachRequestBodyBlobDataHandles( 1174 if (!GetBodyBlobDataHandles(request_data.request_body.get(),
1175 request_data.request_body.get(), resource_context); 1175 resource_context, &blob_handles)) {
1176 if (!blobs_alive) {
1177 AbortRequestBeforeItStarts(requester_info->filter(), 1176 AbortRequestBeforeItStarts(requester_info->filter(),
1178 sync_result_handler, request_id, 1177 sync_result_handler, request_id,
1179 std::move(url_loader_client)); 1178 std::move(url_loader_client));
1180 return; 1179 return;
1181 } 1180 }
1182 } 1181 }
1183 } 1182 }
1184 1183
1185 // Check if we have a registered interceptor for the headers passed in. If 1184 // Check if we have a registered interceptor for the headers passed in. If
1186 // yes then we need to mark the current request as pending and wait for the 1185 // yes then we need to mark the current request as pending and wait for the
(...skipping 12 matching lines...) Expand all
1199 base::CompareCase::INSENSITIVE_ASCII); 1198 base::CompareCase::INSENSITIVE_ASCII);
1200 } 1199 }
1201 if (call_interceptor) { 1200 if (call_interceptor) {
1202 interceptor_info.interceptor.Run( 1201 interceptor_info.interceptor.Run(
1203 it.name(), it.value(), child_id, resource_context, 1202 it.name(), it.value(), child_id, resource_context,
1204 base::Bind( 1203 base::Bind(
1205 &ResourceDispatcherHostImpl::ContinuePendingBeginRequest, 1204 &ResourceDispatcherHostImpl::ContinuePendingBeginRequest,
1206 base::Unretained(this), make_scoped_refptr(requester_info), 1205 base::Unretained(this), make_scoped_refptr(requester_info),
1207 request_id, request_data, sync_result_handler, route_id, 1206 request_id, request_data, sync_result_handler, route_id,
1208 headers, base::Passed(std::move(mojo_request)), 1207 headers, base::Passed(std::move(mojo_request)),
1209 base::Passed(std::move(url_loader_client)))); 1208 base::Passed(std::move(url_loader_client)),
1209 base::Passed(std::move(blob_handles))));
1210 return; 1210 return;
1211 } 1211 }
1212 } 1212 }
1213 } 1213 }
1214 } 1214 }
1215 ContinuePendingBeginRequest( 1215 ContinuePendingBeginRequest(
1216 requester_info, request_id, request_data, sync_result_handler, route_id, 1216 requester_info, request_id, request_data, sync_result_handler, route_id,
1217 headers, std::move(mojo_request), std::move(url_loader_client), 1217 headers, std::move(mojo_request), std::move(url_loader_client),
1218 HeaderInterceptorResult::CONTINUE); 1218 std::move(blob_handles), HeaderInterceptorResult::CONTINUE);
1219 } 1219 }
1220 1220
1221 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( 1221 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest(
1222 scoped_refptr<ResourceRequesterInfo> requester_info, 1222 scoped_refptr<ResourceRequesterInfo> requester_info,
1223 int request_id, 1223 int request_id,
1224 const ResourceRequest& request_data, 1224 const ResourceRequest& request_data,
1225 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1225 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1226 int route_id, 1226 int route_id,
1227 const net::HttpRequestHeaders& headers, 1227 const net::HttpRequestHeaders& headers,
1228 mojom::URLLoaderAssociatedRequest mojo_request, 1228 mojom::URLLoaderAssociatedRequest mojo_request,
1229 mojom::URLLoaderClientPtr url_loader_client, 1229 mojom::URLLoaderClientPtr url_loader_client,
1230 BlobHandles blob_handles,
1230 HeaderInterceptorResult interceptor_result) { 1231 HeaderInterceptorResult interceptor_result) {
1231 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload()); 1232 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload());
1232 if (interceptor_result != HeaderInterceptorResult::CONTINUE) { 1233 if (interceptor_result != HeaderInterceptorResult::CONTINUE) {
1233 if (requester_info->IsRenderer() && 1234 if (requester_info->IsRenderer() &&
1234 interceptor_result == HeaderInterceptorResult::KILL) { 1235 interceptor_result == HeaderInterceptorResult::KILL) {
1235 // TODO(ananta): Find a way to specify the right error code here. Passing 1236 // TODO(ananta): Find a way to specify the right error code here. Passing
1236 // in a non-content error code is not safe, but future header interceptors 1237 // in a non-content error code is not safe, but future header interceptors
1237 // might say to kill for reasons other than illegal origins. 1238 // might say to kill for reasons other than illegal origins.
1238 bad_message::ReceivedBadMessage(requester_info->filter(), 1239 bad_message::ReceivedBadMessage(requester_info->filter(),
1239 bad_message::RDH_ILLEGAL_ORIGIN); 1240 bad_message::RDH_ILLEGAL_ORIGIN);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 false, // is stream 1401 false, // is stream
1401 allow_download, request_data.has_user_gesture, 1402 allow_download, request_data.has_user_gesture,
1402 request_data.enable_load_timing, request_data.enable_upload_progress, 1403 request_data.enable_load_timing, request_data.enable_upload_progress,
1403 do_not_prompt_for_login, request_data.referrer_policy, 1404 do_not_prompt_for_login, request_data.referrer_policy,
1404 request_data.visibility_state, resource_context, report_raw_headers, 1405 request_data.visibility_state, resource_context, report_raw_headers,
1405 !is_sync_load, 1406 !is_sync_load,
1406 GetPreviewsState(request_data.previews_state, delegate_, *new_request, 1407 GetPreviewsState(request_data.previews_state, delegate_, *new_request,
1407 resource_context, 1408 resource_context,
1408 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME), 1409 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME),
1409 request_data.request_body, request_data.initiated_in_secure_context); 1410 request_data.request_body, request_data.initiated_in_secure_context);
1411 extra_info->SetBlobHandles(std::move(blob_handles));
1410 // Request takes ownership. 1412 // Request takes ownership.
1411 extra_info->AssociateWithRequest(new_request.get()); 1413 extra_info->AssociateWithRequest(new_request.get());
1412 1414
1413 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1415 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1414 // Hang on to a reference to ensure the blob is not released prior 1416 // Hang on to a reference to ensure the blob is not released prior
1415 // to the job being started. 1417 // to the job being started.
1416 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1418 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1417 new_request.get(), requester_info->blob_storage_context() 1419 new_request.get(), requester_info->blob_storage_context()
1418 ->context() 1420 ->context()
1419 ->GetBlobDataFromPublicURL(new_request->url())); 1421 ->GetBlobDataFromPublicURL(new_request->url()));
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
2108 headers.AddHeadersFromString(info.begin_params.headers); 2110 headers.AddHeadersFromString(info.begin_params.headers);
2109 new_request->SetExtraRequestHeaders(headers); 2111 new_request->SetExtraRequestHeaders(headers);
2110 2112
2111 new_request->SetLoadFlags(load_flags); 2113 new_request->SetLoadFlags(load_flags);
2112 2114
2113 storage::BlobStorageContext* blob_context = GetBlobStorageContext( 2115 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
2114 GetChromeBlobStorageContextForResourceContext(resource_context)); 2116 GetChromeBlobStorageContextForResourceContext(resource_context));
2115 2117
2116 // Resolve elements from request_body and prepare upload data. 2118 // Resolve elements from request_body and prepare upload data.
2117 ResourceRequestBodyImpl* body = info.common_params.post_data.get(); 2119 ResourceRequestBodyImpl* body = info.common_params.post_data.get();
2120 BlobHandles blob_handles;
2118 if (body) { 2121 if (body) {
2119 bool blobs_alive = AttachRequestBodyBlobDataHandles(body, resource_context); 2122 if (!GetBodyBlobDataHandles(body, resource_context, &blob_handles)) {
2120 if (!blobs_alive) {
2121 new_request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); 2123 new_request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
2122 loader->NotifyRequestFailed(false, net::ERR_ABORTED); 2124 loader->NotifyRequestFailed(false, net::ERR_ABORTED);
2123 return; 2125 return;
2124 } 2126 }
2125 new_request->set_upload(UploadDataStreamBuilder::Build( 2127 new_request->set_upload(UploadDataStreamBuilder::Build(
2126 body, blob_context, upload_file_system_context, 2128 body, blob_context, upload_file_system_context,
2127 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); 2129 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get()));
2128 } 2130 }
2129 2131
2130 // Make extra info and read footer (contains request ID). 2132 // Make extra info and read footer (contains request ID).
(...skipping 25 matching lines...) Expand all
2156 resource_context, info.report_raw_headers, 2158 resource_context, info.report_raw_headers,
2157 true, // is_async 2159 true, // is_async
2158 GetPreviewsState(info.common_params.previews_state, delegate_, 2160 GetPreviewsState(info.common_params.previews_state, delegate_,
2159 *new_request, resource_context, info.is_main_frame), 2161 *new_request, resource_context, info.is_main_frame),
2160 info.common_params.post_data, 2162 info.common_params.post_data,
2161 // TODO(mek): Currently initiated_in_secure_context is only used for 2163 // TODO(mek): Currently initiated_in_secure_context is only used for
2162 // subresource requests, so it doesn't matter what value it gets here. 2164 // subresource requests, so it doesn't matter what value it gets here.
2163 // If in the future this changes this should be updated to somehow get a 2165 // If in the future this changes this should be updated to somehow get a
2164 // meaningful value. 2166 // meaningful value.
2165 false); // initiated_in_secure_context 2167 false); // initiated_in_secure_context
2168 extra_info->SetBlobHandles(std::move(blob_handles));
2166 extra_info->set_navigation_ui_data(std::move(navigation_ui_data)); 2169 extra_info->set_navigation_ui_data(std::move(navigation_ui_data));
2167 2170
2168 // Request takes ownership. 2171 // Request takes ownership.
2169 extra_info->AssociateWithRequest(new_request.get()); 2172 extra_info->AssociateWithRequest(new_request.get());
2170 2173
2171 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2174 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2172 // Hang on to a reference to ensure the blob is not released prior 2175 // Hang on to a reference to ensure the blob is not released prior
2173 // to the job being started. 2176 // to the job being started.
2174 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2177 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2175 new_request.get(), 2178 new_request.get(),
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 if (iter->second > 2) { 2781 if (iter->second > 2) {
2779 active_tabs++; 2782 active_tabs++;
2780 if (active_tabs >= 2) 2783 if (active_tabs >= 2)
2781 return true; 2784 return true;
2782 } 2785 }
2783 } 2786 }
2784 return false; 2787 return false;
2785 } 2788 }
2786 2789
2787 } // namespace content 2790 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_request_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698