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/renderer_host/resource_dispatcher_host_impl.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 33 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
34 #include "content/browser/plugin_service_impl.h" | 34 #include "content/browser/plugin_service_impl.h" |
35 #include "content/browser/renderer_host/async_resource_handler.h" | 35 #include "content/browser/renderer_host/async_resource_handler.h" |
36 #include "content/browser/renderer_host/buffered_resource_handler.h" | 36 #include "content/browser/renderer_host/buffered_resource_handler.h" |
37 #include "content/browser/renderer_host/cross_site_resource_handler.h" | 37 #include "content/browser/renderer_host/cross_site_resource_handler.h" |
38 #include "content/browser/renderer_host/duplicate_content_resource_handler.h" | 38 #include "content/browser/renderer_host/duplicate_content_resource_handler.h" |
39 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" | 39 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" |
40 #include "content/browser/renderer_host/render_view_host_delegate.h" | 40 #include "content/browser/renderer_host/render_view_host_delegate.h" |
41 #include "content/browser/renderer_host/render_view_host_impl.h" | 41 #include "content/browser/renderer_host/render_view_host_impl.h" |
42 #include "content/browser/renderer_host/resource_message_filter.h" | 42 #include "content/browser/renderer_host/resource_message_filter.h" |
43 #include "content/browser/renderer_host/transfer_navigation_resource_throttle.h" | |
44 #include "content/browser/renderer_host/resource_request_info_impl.h" | 43 #include "content/browser/renderer_host/resource_request_info_impl.h" |
45 #include "content/browser/renderer_host/sync_resource_handler.h" | 44 #include "content/browser/renderer_host/sync_resource_handler.h" |
46 #include "content/browser/renderer_host/throttling_resource_handler.h" | 45 #include "content/browser/renderer_host/throttling_resource_handler.h" |
| 46 #include "content/browser/renderer_host/transfer_navigation_resource_throttle.h" |
47 #include "content/browser/resource_context_impl.h" | 47 #include "content/browser/resource_context_impl.h" |
48 #include "content/browser/worker_host/worker_service_impl.h" | 48 #include "content/browser/worker_host/worker_service_impl.h" |
49 #include "content/common/resource_messages.h" | 49 #include "content/common/resource_messages.h" |
50 #include "content/common/ssl_status_serialization.h" | 50 #include "content/common/ssl_status_serialization.h" |
51 #include "content/common/view_messages.h" | 51 #include "content/common/view_messages.h" |
52 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
53 #include "content/public/browser/content_browser_client.h" | 53 #include "content/public/browser/content_browser_client.h" |
54 #include "content/public/browser/download_manager.h" | 54 #include "content/public/browser/download_manager.h" |
55 #include "content/public/browser/global_request_id.h" | 55 #include "content/public/browser/global_request_id.h" |
56 #include "content/public/browser/notification_service.h" | 56 #include "content/public/browser/notification_service.h" |
(...skipping 18 matching lines...) Expand all Loading... |
75 #include "net/http/http_response_headers.h" | 75 #include "net/http/http_response_headers.h" |
76 #include "net/http/http_response_info.h" | 76 #include "net/http/http_response_info.h" |
77 #include "net/http/http_transaction_factory.h" | 77 #include "net/http/http_transaction_factory.h" |
78 #include "net/url_request/url_request.h" | 78 #include "net/url_request/url_request.h" |
79 #include "net/url_request/url_request_context.h" | 79 #include "net/url_request/url_request_context.h" |
80 #include "net/url_request/url_request_job_factory.h" | 80 #include "net/url_request/url_request_job_factory.h" |
81 #include "webkit/appcache/appcache_interceptor.h" | 81 #include "webkit/appcache/appcache_interceptor.h" |
82 #include "webkit/appcache/appcache_interfaces.h" | 82 #include "webkit/appcache/appcache_interfaces.h" |
83 #include "webkit/blob/blob_storage_controller.h" | 83 #include "webkit/blob/blob_storage_controller.h" |
84 #include "webkit/blob/shareable_file_reference.h" | 84 #include "webkit/blob/shareable_file_reference.h" |
| 85 #include "webkit/glue/resource_request_body.h" |
85 #include "webkit/glue/webkit_glue.h" | 86 #include "webkit/glue/webkit_glue.h" |
86 | 87 |
87 using base::Time; | 88 using base::Time; |
88 using base::TimeDelta; | 89 using base::TimeDelta; |
89 using base::TimeTicks; | 90 using base::TimeTicks; |
90 using webkit_blob::ShareableFileReference; | 91 using webkit_blob::ShareableFileReference; |
| 92 using webkit_glue::ResourceRequestBody; |
91 | 93 |
92 // ---------------------------------------------------------------------------- | 94 // ---------------------------------------------------------------------------- |
93 | 95 |
94 namespace content { | 96 namespace content { |
95 | 97 |
96 namespace { | 98 namespace { |
97 | 99 |
98 static ResourceDispatcherHostImpl* g_resource_dispatcher_host; | 100 static ResourceDispatcherHostImpl* g_resource_dispatcher_host; |
99 | 101 |
100 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates | 102 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ChildProcessSecurityPolicyImpl::GetInstance(); | 166 ChildProcessSecurityPolicyImpl::GetInstance(); |
165 | 167 |
166 // Check if the renderer is permitted to request the requested URL. | 168 // Check if the renderer is permitted to request the requested URL. |
167 if (!policy->CanRequestURL(child_id, request_data.url)) { | 169 if (!policy->CanRequestURL(child_id, request_data.url)) { |
168 VLOG(1) << "Denied unauthorized request for " | 170 VLOG(1) << "Denied unauthorized request for " |
169 << request_data.url.possibly_invalid_spec(); | 171 << request_data.url.possibly_invalid_spec(); |
170 return false; | 172 return false; |
171 } | 173 } |
172 | 174 |
173 // Check if the renderer is permitted to upload the requested files. | 175 // Check if the renderer is permitted to upload the requested files. |
174 if (request_data.upload_data) { | 176 if (request_data.request_body) { |
175 const std::vector<net::UploadElement>* uploads = | 177 const std::vector<ResourceRequestBody::Element>* uploads = |
176 request_data.upload_data->elements(); | 178 request_data.request_body->elements(); |
177 std::vector<net::UploadElement>::const_iterator iter; | 179 std::vector<ResourceRequestBody::Element>::const_iterator iter; |
178 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | 180 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
179 if (iter->type() == net::UploadElement::TYPE_FILE && | 181 if (iter->type() == ResourceRequestBody::TYPE_FILE && |
180 !policy->CanReadFile(child_id, iter->file_path())) { | 182 !policy->CanReadFile(child_id, iter->file_path())) { |
181 NOTREACHED() << "Denied unauthorized upload of " | 183 NOTREACHED() << "Denied unauthorized upload of " |
182 << iter->file_path().value(); | 184 << iter->file_path().value(); |
183 return false; | 185 return false; |
184 } | 186 } |
185 } | 187 } |
186 } | 188 } |
187 | 189 |
188 return true; | 190 return true; |
189 } | 191 } |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 filter_->BadMessageReceived(); | 893 filter_->BadMessageReceived(); |
892 return; | 894 return; |
893 } | 895 } |
894 } | 896 } |
895 } | 897 } |
896 | 898 |
897 ResourceContext* resource_context = filter_->resource_context(); | 899 ResourceContext* resource_context = filter_->resource_context(); |
898 // http://crbug.com/90971 | 900 // http://crbug.com/90971 |
899 CHECK(ContainsKey(active_resource_contexts_, resource_context)); | 901 CHECK(ContainsKey(active_resource_contexts_, resource_context)); |
900 | 902 |
901 // Might need to resolve the blob references in the upload data. | |
902 if (request_data.upload_data) { | |
903 GetBlobStorageControllerForResourceContext(resource_context)-> | |
904 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); | |
905 } | |
906 | |
907 if (is_shutdown_ || | 903 if (is_shutdown_ || |
908 !ShouldServiceRequest(process_type, child_id, request_data)) { | 904 !ShouldServiceRequest(process_type, child_id, request_data)) { |
909 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 905 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); |
910 return; | 906 return; |
911 } | 907 } |
912 | 908 |
913 const Referrer referrer(MaybeStripReferrer(request_data.referrer), | 909 const Referrer referrer(MaybeStripReferrer(request_data.referrer), |
914 request_data.referrer_policy); | 910 request_data.referrer_policy); |
915 | 911 |
916 // Allow the observer to block/handle the request. | 912 // Allow the observer to block/handle the request. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 request->SetExtraRequestHeaders(headers); | 950 request->SetExtraRequestHeaders(headers); |
955 } | 951 } |
956 | 952 |
957 // TODO(darin): Do we really need all of these URLRequest setters in the | 953 // TODO(darin): Do we really need all of these URLRequest setters in the |
958 // transferred navigation case? | 954 // transferred navigation case? |
959 | 955 |
960 request->set_load_flags(load_flags); | 956 request->set_load_flags(load_flags); |
961 | 957 |
962 request->set_priority(DetermineRequestPriority(request_data.resource_type)); | 958 request->set_priority(DetermineRequestPriority(request_data.resource_type)); |
963 | 959 |
964 // Set upload data. | 960 // Resolve elements from request_body and prepare upload data. |
965 uint64 upload_size = 0; | 961 uint64 upload_size = 0; |
966 if (request_data.upload_data) { | 962 if (request_data.request_body) { |
967 request->set_upload(request_data.upload_data); | 963 request->set_upload( |
| 964 request_data.request_body->ResolveElementsAndCreateUploadData( |
| 965 GetBlobStorageControllerForResourceContext(resource_context))); |
968 // This results in performing file IO. crbug.com/112607. | 966 // This results in performing file IO. crbug.com/112607. |
969 base::ThreadRestrictions::ScopedAllowIO allow_io; | 967 base::ThreadRestrictions::ScopedAllowIO allow_io; |
970 upload_size = request_data.upload_data->GetContentLengthSync(); | 968 upload_size = request->get_upload_mutable()->GetContentLengthSync(); |
971 } | 969 } |
972 | 970 |
973 bool allow_download = request_data.allow_download && | 971 bool allow_download = request_data.allow_download && |
974 ResourceType::IsFrame(request_data.resource_type); | 972 ResourceType::IsFrame(request_data.resource_type); |
975 | 973 |
976 // Make extra info and read footer (contains request ID). | 974 // Make extra info and read footer (contains request ID). |
977 ResourceRequestInfoImpl* extra_info = | 975 ResourceRequestInfoImpl* extra_info = |
978 new ResourceRequestInfoImpl( | 976 new ResourceRequestInfoImpl( |
979 process_type, | 977 process_type, |
980 child_id, | 978 child_id, |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 | 1728 |
1731 return i->second.get(); | 1729 return i->second.get(); |
1732 } | 1730 } |
1733 | 1731 |
1734 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, | 1732 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, |
1735 int request_id) const { | 1733 int request_id) const { |
1736 return GetLoader(GlobalRequestID(child_id, request_id)); | 1734 return GetLoader(GlobalRequestID(child_id, request_id)); |
1737 } | 1735 } |
1738 | 1736 |
1739 } // namespace content | 1737 } // namespace content |
OLD | NEW |