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

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

Issue 10834289: Split net::UploadData into two: for IPC and for upload handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years, 4 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 | Annotate | Revision Log
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/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
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 19 matching lines...) Expand all
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/webkit_glue.h" 85 #include "webkit/glue/webkit_glue.h"
86 #include "webkit/glue/resource_request_body.h"
darin (slow to review) 2012/08/15 17:49:55 nit: sort
kinuko 2012/08/16 08:14:59 Done.
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
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::UploadData::Element>* uploads = 177 const std::vector<ResourceRequestBody::Element>* uploads =
176 request_data.upload_data->elements(); 178 request_data.request_body->elements();
177 std::vector<net::UploadData::Element>::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::UploadData::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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 903 // Might need to resolve the blob references in the upload data.
902 if (request_data.upload_data) { 904 if (request_data.request_body) {
903 GetBlobStorageControllerForResourceContext(resource_context)-> 905 GetBlobStorageControllerForResourceContext(resource_context)->
904 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); 906 ResolveBlobReferencesInResourceRequestBody(
907 request_data.request_body.get());
905 } 908 }
906 909
907 if (is_shutdown_ || 910 if (is_shutdown_ ||
908 !ShouldServiceRequest(process_type, child_id, request_data)) { 911 !ShouldServiceRequest(process_type, child_id, request_data)) {
909 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); 912 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id);
910 return; 913 return;
911 } 914 }
912 915
913 const Referrer referrer(MaybeStripReferrer(request_data.referrer), 916 const Referrer referrer(MaybeStripReferrer(request_data.referrer),
914 request_data.referrer_policy); 917 request_data.referrer_policy);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 959
957 // TODO(darin): Do we really need all of these URLRequest setters in the 960 // TODO(darin): Do we really need all of these URLRequest setters in the
958 // transferred navigation case? 961 // transferred navigation case?
959 962
960 request->set_load_flags(load_flags); 963 request->set_load_flags(load_flags);
961 964
962 request->set_priority(DetermineRequestPriority(request_data.resource_type)); 965 request->set_priority(DetermineRequestPriority(request_data.resource_type));
963 966
964 // Set upload data. 967 // Set upload data.
965 uint64 upload_size = 0; 968 uint64 upload_size = 0;
966 if (request_data.upload_data) { 969 if (request_data.request_body) {
967 request->set_upload(request_data.upload_data); 970 scoped_refptr<net::UploadData> upload = new net::UploadData;
971 request_data.request_body->PopulateUploadData(upload.get());
972 request->set_upload(upload);
968 // This results in performing file IO. crbug.com/112607. 973 // This results in performing file IO. crbug.com/112607.
969 base::ThreadRestrictions::ScopedAllowIO allow_io; 974 base::ThreadRestrictions::ScopedAllowIO allow_io;
970 upload_size = request_data.upload_data->GetContentLengthSync(); 975 upload_size = upload->GetContentLengthSync();
971 } 976 }
972 977
973 bool allow_download = request_data.allow_download && 978 bool allow_download = request_data.allow_download &&
974 ResourceType::IsFrame(request_data.resource_type); 979 ResourceType::IsFrame(request_data.resource_type);
975 980
976 // Make extra info and read footer (contains request ID). 981 // Make extra info and read footer (contains request ID).
977 ResourceRequestInfoImpl* extra_info = 982 ResourceRequestInfoImpl* extra_info =
978 new ResourceRequestInfoImpl( 983 new ResourceRequestInfoImpl(
979 process_type, 984 process_type,
980 child_id, 985 child_id,
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 1735
1731 return i->second.get(); 1736 return i->second.get();
1732 } 1737 }
1733 1738
1734 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, 1739 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id,
1735 int request_id) const { 1740 int request_id) const {
1736 return GetLoader(GlobalRequestID(child_id, request_id)); 1741 return GetLoader(GlobalRequestID(child_id, request_id));
1737 } 1742 }
1738 1743
1739 } // namespace content 1744 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698