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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #include "content/browser/service_worker/service_worker_request_handler.h" | 69 #include "content/browser/service_worker/service_worker_request_handler.h" |
70 #include "content/browser/streams/stream.h" | 70 #include "content/browser/streams/stream.h" |
71 #include "content/browser/streams/stream_context.h" | 71 #include "content/browser/streams/stream_context.h" |
72 #include "content/browser/streams/stream_registry.h" | 72 #include "content/browser/streams/stream_registry.h" |
73 #include "content/browser/web_contents/web_contents_impl.h" | 73 #include "content/browser/web_contents/web_contents_impl.h" |
74 #include "content/common/appcache_interfaces.h" | 74 #include "content/common/appcache_interfaces.h" |
75 #include "content/common/navigation_params.h" | 75 #include "content/common/navigation_params.h" |
76 #include "content/common/net/url_request_service_worker_data.h" | 76 #include "content/common/net/url_request_service_worker_data.h" |
77 #include "content/common/resource_messages.h" | 77 #include "content/common/resource_messages.h" |
78 #include "content/common/resource_request.h" | 78 #include "content/common/resource_request.h" |
| 79 #include "content/common/resource_request_body_impl.h" |
79 #include "content/common/resource_request_completion_status.h" | 80 #include "content/common/resource_request_completion_status.h" |
80 #include "content/common/site_isolation_policy.h" | 81 #include "content/common/site_isolation_policy.h" |
81 #include "content/common/ssl_status_serialization.h" | 82 #include "content/common/ssl_status_serialization.h" |
82 #include "content/common/view_messages.h" | 83 #include "content/common/view_messages.h" |
83 #include "content/public/browser/browser_thread.h" | 84 #include "content/public/browser/browser_thread.h" |
84 #include "content/public/browser/content_browser_client.h" | 85 #include "content/public/browser/content_browser_client.h" |
85 #include "content/public/browser/download_manager.h" | 86 #include "content/public/browser/download_manager.h" |
86 #include "content/public/browser/download_url_parameters.h" | 87 #include "content/public/browser/download_url_parameters.h" |
87 #include "content/public/browser/global_request_id.h" | 88 #include "content/public/browser/global_request_id.h" |
88 #include "content/public/browser/plugin_service.h" | 89 #include "content/public/browser/plugin_service.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 GetContentClient()->browser()->IsIllegalOrigin(resource_context, | 321 GetContentClient()->browser()->IsIllegalOrigin(resource_context, |
321 child_id, origin)) { | 322 child_id, origin)) { |
322 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; | 323 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; |
323 bad_message::ReceivedBadMessage(filter, bad_message::RDH_ILLEGAL_ORIGIN); | 324 bad_message::ReceivedBadMessage(filter, bad_message::RDH_ILLEGAL_ORIGIN); |
324 return false; | 325 return false; |
325 } | 326 } |
326 } | 327 } |
327 | 328 |
328 // Check if the renderer is permitted to upload the requested files. | 329 // Check if the renderer is permitted to upload the requested files. |
329 if (request_data.request_body.get()) { | 330 if (request_data.request_body.get()) { |
330 const std::vector<ResourceRequestBody::Element>* uploads = | 331 const std::vector<ResourceRequestBodyImpl::Element>* uploads = |
331 request_data.request_body->elements(); | 332 request_data.request_body->elements(); |
332 std::vector<ResourceRequestBody::Element>::const_iterator iter; | 333 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; |
333 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | 334 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
334 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE && | 335 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
335 !policy->CanReadFile(child_id, iter->path())) { | 336 !policy->CanReadFile(child_id, iter->path())) { |
336 NOTREACHED() << "Denied unauthorized upload of " | 337 NOTREACHED() << "Denied unauthorized upload of " |
337 << iter->path().value(); | 338 << iter->path().value(); |
338 return false; | 339 return false; |
339 } | 340 } |
340 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM) { | 341 if (iter->type() == |
| 342 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { |
341 storage::FileSystemURL url = | 343 storage::FileSystemURL url = |
342 filter->file_system_context()->CrackURL(iter->filesystem_url()); | 344 filter->file_system_context()->CrackURL(iter->filesystem_url()); |
343 if (!policy->CanReadFileSystemFile(child_id, url)) { | 345 if (!policy->CanReadFileSystemFile(child_id, url)) { |
344 NOTREACHED() << "Denied unauthorized upload of " | 346 NOTREACHED() << "Denied unauthorized upload of " |
345 << iter->filesystem_url().spec(); | 347 << iter->filesystem_url().spec(); |
346 return false; | 348 return false; |
347 } | 349 } |
348 } | 350 } |
349 } | 351 } |
350 } | 352 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } | 396 } |
395 | 397 |
396 storage::BlobStorageContext* GetBlobStorageContext( | 398 storage::BlobStorageContext* GetBlobStorageContext( |
397 ChromeBlobStorageContext* blob_storage_context) { | 399 ChromeBlobStorageContext* blob_storage_context) { |
398 if (!blob_storage_context) | 400 if (!blob_storage_context) |
399 return NULL; | 401 return NULL; |
400 return blob_storage_context->context(); | 402 return blob_storage_context->context(); |
401 } | 403 } |
402 | 404 |
403 void AttachRequestBodyBlobDataHandles( | 405 void AttachRequestBodyBlobDataHandles( |
404 ResourceRequestBody* body, | 406 ResourceRequestBodyImpl* body, |
405 storage::BlobStorageContext* blob_context) { | 407 storage::BlobStorageContext* blob_context) { |
406 DCHECK(blob_context); | 408 DCHECK(blob_context); |
407 for (size_t i = 0; i < body->elements()->size(); ++i) { | 409 for (size_t i = 0; i < body->elements()->size(); ++i) { |
408 const ResourceRequestBody::Element& element = (*body->elements())[i]; | 410 const ResourceRequestBodyImpl::Element& element = (*body->elements())[i]; |
409 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) | 411 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) |
410 continue; | 412 continue; |
411 std::unique_ptr<storage::BlobDataHandle> handle = | 413 std::unique_ptr<storage::BlobDataHandle> handle = |
412 blob_context->GetBlobDataFromUUID(element.blob_uuid()); | 414 blob_context->GetBlobDataFromUUID(element.blob_uuid()); |
413 DCHECK(handle); | 415 DCHECK(handle); |
414 if (!handle) | 416 if (!handle) |
415 continue; | 417 continue; |
416 // Ensure the blob and any attached shareable files survive until | 418 // Ensure the blob and any attached shareable files survive until |
417 // upload completion. The |body| takes ownership of |handle|. | 419 // upload completion. The |body| takes ownership of |handle|. |
418 const void* key = handle.get(); | 420 const void* key = handle.get(); |
419 body->SetUserData(key, handle.release()); | 421 body->SetUserData(key, handle.release()); |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 bool download, | 1856 bool download, |
1855 ResourceContext* context) { | 1857 ResourceContext* context) { |
1856 return new ResourceRequestInfoImpl( | 1858 return new ResourceRequestInfoImpl( |
1857 PROCESS_TYPE_RENDERER, | 1859 PROCESS_TYPE_RENDERER, |
1858 child_id, | 1860 child_id, |
1859 render_view_route_id, | 1861 render_view_route_id, |
1860 -1, // frame_tree_node_id | 1862 -1, // frame_tree_node_id |
1861 0, | 1863 0, |
1862 request_id_, | 1864 request_id_, |
1863 render_frame_route_id, | 1865 render_frame_route_id, |
1864 false, // is_main_frame | 1866 false, // is_main_frame |
1865 false, // parent_is_main_frame | 1867 false, // parent_is_main_frame |
1866 RESOURCE_TYPE_SUB_RESOURCE, | 1868 RESOURCE_TYPE_SUB_RESOURCE, |
1867 ui::PAGE_TRANSITION_LINK, | 1869 ui::PAGE_TRANSITION_LINK, |
1868 false, // should_replace_current_entry | 1870 false, // should_replace_current_entry |
1869 download, // is_download | 1871 download, // is_download |
1870 false, // is_stream | 1872 false, // is_stream |
1871 download, // allow_download | 1873 download, // allow_download |
1872 false, // has_user_gesture | 1874 false, // has_user_gesture |
1873 false, // enable_load_timing | 1875 false, // enable_load_timing |
1874 false, // enable_upload_progress | 1876 false, // enable_upload_progress |
1875 false, // do_not_prompt_for_login | 1877 false, // do_not_prompt_for_login |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 net::HttpRequestHeaders headers; | 2250 net::HttpRequestHeaders headers; |
2249 headers.AddHeadersFromString(info.begin_params.headers); | 2251 headers.AddHeadersFromString(info.begin_params.headers); |
2250 new_request->SetExtraRequestHeaders(headers); | 2252 new_request->SetExtraRequestHeaders(headers); |
2251 | 2253 |
2252 new_request->SetLoadFlags(load_flags); | 2254 new_request->SetLoadFlags(load_flags); |
2253 | 2255 |
2254 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | 2256 storage::BlobStorageContext* blob_context = GetBlobStorageContext( |
2255 GetChromeBlobStorageContextForResourceContext(resource_context)); | 2257 GetChromeBlobStorageContextForResourceContext(resource_context)); |
2256 | 2258 |
2257 // Resolve elements from request_body and prepare upload data. | 2259 // Resolve elements from request_body and prepare upload data. |
2258 ResourceRequestBody* body = info.common_params.post_data.get(); | 2260 ResourceRequestBodyImpl* body = info.common_params.post_data.get(); |
2259 if (body) { | 2261 if (body) { |
2260 AttachRequestBodyBlobDataHandles(body, blob_context); | 2262 AttachRequestBodyBlobDataHandles(body, blob_context); |
2261 // TODO(davidben): The FileSystemContext is null here. In the case where | 2263 // TODO(davidben): The FileSystemContext is null here. In the case where |
2262 // another renderer requested this navigation, this should be the same | 2264 // another renderer requested this navigation, this should be the same |
2263 // FileSystemContext passed into ShouldServiceRequest. | 2265 // FileSystemContext passed into ShouldServiceRequest. |
2264 new_request->set_upload(UploadDataStreamBuilder::Build( | 2266 new_request->set_upload(UploadDataStreamBuilder::Build( |
2265 body, | 2267 body, |
2266 blob_context, | 2268 blob_context, |
2267 nullptr, // file_system_context | 2269 nullptr, // file_system_context |
2268 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | 2270 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2695 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); |
2694 response->head.security_info = SerializeSecurityInfo(ssl); | 2696 response->head.security_info = SerializeSecurityInfo(ssl); |
2695 } | 2697 } |
2696 | 2698 |
2697 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2699 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
2698 return cert_store_for_testing_ ? cert_store_for_testing_ | 2700 return cert_store_for_testing_ ? cert_store_for_testing_ |
2699 : CertStore::GetInstance(); | 2701 : CertStore::GetInstance(); |
2700 } | 2702 } |
2701 | 2703 |
2702 } // namespace content | 2704 } // namespace content |
OLD | NEW |