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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #include "content/browser/service_worker/link_header_support.h" | 67 #include "content/browser/service_worker/link_header_support.h" |
68 #include "content/browser/service_worker/service_worker_request_handler.h" | 68 #include "content/browser/service_worker/service_worker_request_handler.h" |
69 #include "content/browser/streams/stream.h" | 69 #include "content/browser/streams/stream.h" |
70 #include "content/browser/streams/stream_context.h" | 70 #include "content/browser/streams/stream_context.h" |
71 #include "content/browser/streams/stream_registry.h" | 71 #include "content/browser/streams/stream_registry.h" |
72 #include "content/browser/web_contents/web_contents_impl.h" | 72 #include "content/browser/web_contents/web_contents_impl.h" |
73 #include "content/common/navigation_params.h" | 73 #include "content/common/navigation_params.h" |
74 #include "content/common/net/url_request_service_worker_data.h" | 74 #include "content/common/net/url_request_service_worker_data.h" |
75 #include "content/common/resource_messages.h" | 75 #include "content/common/resource_messages.h" |
76 #include "content/common/resource_request.h" | 76 #include "content/common/resource_request.h" |
| 77 #include "content/common/resource_request_body_impl.h" |
77 #include "content/common/resource_request_completion_status.h" | 78 #include "content/common/resource_request_completion_status.h" |
78 #include "content/common/site_isolation_policy.h" | 79 #include "content/common/site_isolation_policy.h" |
79 #include "content/common/ssl_status_serialization.h" | 80 #include "content/common/ssl_status_serialization.h" |
80 #include "content/common/view_messages.h" | 81 #include "content/common/view_messages.h" |
81 #include "content/public/browser/browser_thread.h" | 82 #include "content/public/browser/browser_thread.h" |
82 #include "content/public/browser/content_browser_client.h" | 83 #include "content/public/browser/content_browser_client.h" |
83 #include "content/public/browser/global_request_id.h" | 84 #include "content/public/browser/global_request_id.h" |
84 #include "content/public/browser/plugin_service.h" | 85 #include "content/public/browser/plugin_service.h" |
85 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 86 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
86 #include "content/public/browser/resource_request_details.h" | 87 #include "content/public/browser/resource_request_details.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 GetContentClient()->browser()->IsIllegalOrigin(resource_context, | 317 GetContentClient()->browser()->IsIllegalOrigin(resource_context, |
317 child_id, origin)) { | 318 child_id, origin)) { |
318 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; | 319 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; |
319 bad_message::ReceivedBadMessage(filter, bad_message::RDH_ILLEGAL_ORIGIN); | 320 bad_message::ReceivedBadMessage(filter, bad_message::RDH_ILLEGAL_ORIGIN); |
320 return false; | 321 return false; |
321 } | 322 } |
322 } | 323 } |
323 | 324 |
324 // Check if the renderer is permitted to upload the requested files. | 325 // Check if the renderer is permitted to upload the requested files. |
325 if (request_data.request_body.get()) { | 326 if (request_data.request_body.get()) { |
326 const std::vector<ResourceRequestBody::Element>* uploads = | 327 const std::vector<ResourceRequestBodyImpl::Element>* uploads = |
327 request_data.request_body->elements(); | 328 request_data.request_body->elements(); |
328 std::vector<ResourceRequestBody::Element>::const_iterator iter; | 329 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; |
329 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | 330 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
330 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE && | 331 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && |
331 !policy->CanReadFile(child_id, iter->path())) { | 332 !policy->CanReadFile(child_id, iter->path())) { |
332 NOTREACHED() << "Denied unauthorized upload of " | 333 NOTREACHED() << "Denied unauthorized upload of " |
333 << iter->path().value(); | 334 << iter->path().value(); |
334 return false; | 335 return false; |
335 } | 336 } |
336 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM) { | 337 if (iter->type() == |
| 338 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { |
337 storage::FileSystemURL url = | 339 storage::FileSystemURL url = |
338 filter->file_system_context()->CrackURL(iter->filesystem_url()); | 340 filter->file_system_context()->CrackURL(iter->filesystem_url()); |
339 if (!policy->CanReadFileSystemFile(child_id, url)) { | 341 if (!policy->CanReadFileSystemFile(child_id, url)) { |
340 NOTREACHED() << "Denied unauthorized upload of " | 342 NOTREACHED() << "Denied unauthorized upload of " |
341 << iter->filesystem_url().spec(); | 343 << iter->filesystem_url().spec(); |
342 return false; | 344 return false; |
343 } | 345 } |
344 } | 346 } |
345 } | 347 } |
346 } | 348 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 392 } |
391 | 393 |
392 storage::BlobStorageContext* GetBlobStorageContext( | 394 storage::BlobStorageContext* GetBlobStorageContext( |
393 ChromeBlobStorageContext* blob_storage_context) { | 395 ChromeBlobStorageContext* blob_storage_context) { |
394 if (!blob_storage_context) | 396 if (!blob_storage_context) |
395 return NULL; | 397 return NULL; |
396 return blob_storage_context->context(); | 398 return blob_storage_context->context(); |
397 } | 399 } |
398 | 400 |
399 void AttachRequestBodyBlobDataHandles( | 401 void AttachRequestBodyBlobDataHandles( |
400 ResourceRequestBody* body, | 402 ResourceRequestBodyImpl* body, |
401 storage::BlobStorageContext* blob_context) { | 403 storage::BlobStorageContext* blob_context) { |
402 DCHECK(blob_context); | 404 DCHECK(blob_context); |
403 for (size_t i = 0; i < body->elements()->size(); ++i) { | 405 for (size_t i = 0; i < body->elements()->size(); ++i) { |
404 const ResourceRequestBody::Element& element = (*body->elements())[i]; | 406 const ResourceRequestBodyImpl::Element& element = (*body->elements())[i]; |
405 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) | 407 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) |
406 continue; | 408 continue; |
407 std::unique_ptr<storage::BlobDataHandle> handle = | 409 std::unique_ptr<storage::BlobDataHandle> handle = |
408 blob_context->GetBlobDataFromUUID(element.blob_uuid()); | 410 blob_context->GetBlobDataFromUUID(element.blob_uuid()); |
409 DCHECK(handle); | 411 DCHECK(handle); |
410 if (!handle) | 412 if (!handle) |
411 continue; | 413 continue; |
412 // Ensure the blob and any attached shareable files survive until | 414 // Ensure the blob and any attached shareable files survive until |
413 // upload completion. The |body| takes ownership of |handle|. | 415 // upload completion. The |body| takes ownership of |handle|. |
414 const void* key = handle.get(); | 416 const void* key = handle.get(); |
415 body->SetUserData(key, handle.release()); | 417 body->SetUserData(key, handle.release()); |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 bool download, | 1815 bool download, |
1814 ResourceContext* context) { | 1816 ResourceContext* context) { |
1815 return new ResourceRequestInfoImpl( | 1817 return new ResourceRequestInfoImpl( |
1816 PROCESS_TYPE_RENDERER, | 1818 PROCESS_TYPE_RENDERER, |
1817 child_id, | 1819 child_id, |
1818 render_view_route_id, | 1820 render_view_route_id, |
1819 -1, // frame_tree_node_id | 1821 -1, // frame_tree_node_id |
1820 0, | 1822 0, |
1821 request_id_, | 1823 request_id_, |
1822 render_frame_route_id, | 1824 render_frame_route_id, |
1823 false, // is_main_frame | 1825 false, // is_main_frame |
1824 false, // parent_is_main_frame | 1826 false, // parent_is_main_frame |
1825 RESOURCE_TYPE_SUB_RESOURCE, | 1827 RESOURCE_TYPE_SUB_RESOURCE, |
1826 ui::PAGE_TRANSITION_LINK, | 1828 ui::PAGE_TRANSITION_LINK, |
1827 false, // should_replace_current_entry | 1829 false, // should_replace_current_entry |
1828 download, // is_download | 1830 download, // is_download |
1829 false, // is_stream | 1831 false, // is_stream |
1830 download, // allow_download | 1832 download, // allow_download |
1831 false, // has_user_gesture | 1833 false, // has_user_gesture |
1832 false, // enable_load_timing | 1834 false, // enable_load_timing |
1833 false, // enable_upload_progress | 1835 false, // enable_upload_progress |
1834 false, // do_not_prompt_for_login | 1836 false, // do_not_prompt_for_login |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2193 net::HttpRequestHeaders headers; | 2195 net::HttpRequestHeaders headers; |
2194 headers.AddHeadersFromString(info.begin_params.headers); | 2196 headers.AddHeadersFromString(info.begin_params.headers); |
2195 new_request->SetExtraRequestHeaders(headers); | 2197 new_request->SetExtraRequestHeaders(headers); |
2196 | 2198 |
2197 new_request->SetLoadFlags(load_flags); | 2199 new_request->SetLoadFlags(load_flags); |
2198 | 2200 |
2199 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | 2201 storage::BlobStorageContext* blob_context = GetBlobStorageContext( |
2200 GetChromeBlobStorageContextForResourceContext(resource_context)); | 2202 GetChromeBlobStorageContextForResourceContext(resource_context)); |
2201 | 2203 |
2202 // Resolve elements from request_body and prepare upload data. | 2204 // Resolve elements from request_body and prepare upload data. |
2203 ResourceRequestBody* body = info.common_params.post_data.get(); | 2205 ResourceRequestBodyImpl* body = info.common_params.post_data.get(); |
2204 if (body) { | 2206 if (body) { |
2205 AttachRequestBodyBlobDataHandles(body, blob_context); | 2207 AttachRequestBodyBlobDataHandles(body, blob_context); |
2206 // TODO(davidben): The FileSystemContext is null here. In the case where | 2208 // TODO(davidben): The FileSystemContext is null here. In the case where |
2207 // another renderer requested this navigation, this should be the same | 2209 // another renderer requested this navigation, this should be the same |
2208 // FileSystemContext passed into ShouldServiceRequest. | 2210 // FileSystemContext passed into ShouldServiceRequest. |
2209 new_request->set_upload(UploadDataStreamBuilder::Build( | 2211 new_request->set_upload(UploadDataStreamBuilder::Build( |
2210 body, | 2212 body, |
2211 blob_context, | 2213 blob_context, |
2212 nullptr, // file_system_context | 2214 nullptr, // file_system_context |
2213 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | 2215 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2640 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); |
2639 response->head.security_info = SerializeSecurityInfo(ssl); | 2641 response->head.security_info = SerializeSecurityInfo(ssl); |
2640 } | 2642 } |
2641 | 2643 |
2642 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2644 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
2643 return cert_store_for_testing_ ? cert_store_for_testing_ | 2645 return cert_store_for_testing_ ? cert_store_for_testing_ |
2644 : CertStore::GetInstance(); | 2646 : CertStore::GetInstance(); |
2645 } | 2647 } |
2646 | 2648 |
2647 } // namespace content | 2649 } // namespace content |
OLD | NEW |