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