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 <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 return sct_status.status == net::ct::SCT_STATUS_OK; | 299 return sct_status.status == net::ct::SCT_STATUS_OK; |
300 } | 300 } |
301 | 301 |
302 storage::BlobStorageContext* GetBlobStorageContext( | 302 storage::BlobStorageContext* GetBlobStorageContext( |
303 ResourceMessageFilter* filter) { | 303 ResourceMessageFilter* filter) { |
304 if (!filter->blob_storage_context()) | 304 if (!filter->blob_storage_context()) |
305 return NULL; | 305 return NULL; |
306 return filter->blob_storage_context()->context(); | 306 return filter->blob_storage_context()->context(); |
307 } | 307 } |
308 | 308 |
| 309 void AttachRequestBodyBlobDataHandles( |
| 310 ResourceRequestBody* body, |
| 311 storage::BlobStorageContext* blob_context) { |
| 312 DCHECK(blob_context); |
| 313 for (size_t i = 0; i < body->elements()->size(); ++i) { |
| 314 const ResourceRequestBody::Element& element = (*body->elements())[i]; |
| 315 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) |
| 316 continue; |
| 317 scoped_ptr<storage::BlobDataHandle> handle = |
| 318 blob_context->GetBlobDataFromUUID(element.blob_uuid()); |
| 319 DCHECK(handle); |
| 320 if (!handle) |
| 321 continue; |
| 322 // Ensure the blob and any attached shareable files survive until |
| 323 // upload completion. The |body| takes ownership of |handle|. |
| 324 const void* key = handle.get(); |
| 325 body->SetUserData(key, handle.release()); |
| 326 } |
| 327 } |
| 328 |
309 } // namespace | 329 } // namespace |
310 | 330 |
311 // static | 331 // static |
312 ResourceDispatcherHost* ResourceDispatcherHost::Get() { | 332 ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
313 return g_resource_dispatcher_host; | 333 return g_resource_dispatcher_host; |
314 } | 334 } |
315 | 335 |
316 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() | 336 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
317 : save_file_manager_(new SaveFileManager()), | 337 : save_file_manager_(new SaveFileManager()), |
318 request_id_(-1), | 338 request_id_(-1), |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 | 1070 |
1051 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 1071 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
1052 SetReferrerForRequest(new_request.get(), referrer); | 1072 SetReferrerForRequest(new_request.get(), referrer); |
1053 | 1073 |
1054 net::HttpRequestHeaders headers; | 1074 net::HttpRequestHeaders headers; |
1055 headers.AddHeadersFromString(request_data.headers); | 1075 headers.AddHeadersFromString(request_data.headers); |
1056 new_request->SetExtraRequestHeaders(headers); | 1076 new_request->SetExtraRequestHeaders(headers); |
1057 | 1077 |
1058 new_request->SetLoadFlags(load_flags); | 1078 new_request->SetLoadFlags(load_flags); |
1059 | 1079 |
| 1080 storage::BlobStorageContext* blob_context = |
| 1081 GetBlobStorageContext(filter_); |
1060 // Resolve elements from request_body and prepare upload data. | 1082 // Resolve elements from request_body and prepare upload data. |
1061 if (request_data.request_body.get()) { | 1083 if (request_data.request_body.get()) { |
| 1084 // Attaches the BlobDataHandles to request_body not to free the blobs and |
| 1085 // any attached shareable files until upload completion. These data will be |
| 1086 // used in UploadDataStream and ServiceWorkerURLRequestJob. |
| 1087 AttachRequestBodyBlobDataHandles( |
| 1088 request_data.request_body.get(), |
| 1089 blob_context); |
1062 new_request->set_upload(UploadDataStreamBuilder::Build( | 1090 new_request->set_upload(UploadDataStreamBuilder::Build( |
1063 request_data.request_body.get(), | 1091 request_data.request_body.get(), |
1064 GetBlobStorageContext(filter_), | 1092 blob_context, |
1065 filter_->file_system_context(), | 1093 filter_->file_system_context(), |
1066 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | 1094 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
1067 .get())); | 1095 .get())); |
1068 } | 1096 } |
1069 | 1097 |
1070 bool allow_download = request_data.allow_download && | 1098 bool allow_download = request_data.allow_download && |
1071 IsResourceTypeFrame(request_data.resource_type); | 1099 IsResourceTypeFrame(request_data.resource_type); |
1072 | 1100 |
1073 // Make extra info and read footer (contains request ID). | 1101 // Make extra info and read footer (contains request ID). |
1074 ResourceRequestInfoImpl* extra_info = | 1102 ResourceRequestInfoImpl* extra_info = |
(...skipping 29 matching lines...) Expand all Loading... |
1104 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 1132 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
1105 new_request.get(), | 1133 new_request.get(), |
1106 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( | 1134 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( |
1107 new_request->url())); | 1135 new_request->url())); |
1108 } | 1136 } |
1109 | 1137 |
1110 // Initialize the service worker handler for the request. | 1138 // Initialize the service worker handler for the request. |
1111 ServiceWorkerRequestHandler::InitializeHandler( | 1139 ServiceWorkerRequestHandler::InitializeHandler( |
1112 new_request.get(), | 1140 new_request.get(), |
1113 filter_->service_worker_context(), | 1141 filter_->service_worker_context(), |
1114 GetBlobStorageContext(filter_), | 1142 blob_context, |
1115 child_id, | 1143 child_id, |
1116 request_data.service_worker_provider_id, | 1144 request_data.service_worker_provider_id, |
1117 request_data.resource_type, | 1145 request_data.resource_type, |
1118 request_data.request_body); | 1146 request_data.request_body); |
1119 | 1147 |
1120 // Have the appcache associate its extra info with the request. | 1148 // Have the appcache associate its extra info with the request. |
1121 AppCacheInterceptor::SetExtraRequestInfo( | 1149 AppCacheInterceptor::SetExtraRequestInfo( |
1122 new_request.get(), filter_->appcache_service(), child_id, | 1150 new_request.get(), filter_->appcache_service(), child_id, |
1123 request_data.appcache_host_id, request_data.resource_type); | 1151 request_data.appcache_host_id, request_data.resource_type); |
1124 | 1152 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 | 2032 |
2005 // Add a flag to selectively bypass the data reduction proxy if the resource | 2033 // Add a flag to selectively bypass the data reduction proxy if the resource |
2006 // type is not an image. | 2034 // type is not an image. |
2007 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2035 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
2008 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2036 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
2009 | 2037 |
2010 return load_flags; | 2038 return load_flags; |
2011 } | 2039 } |
2012 | 2040 |
2013 } // namespace content | 2041 } // namespace content |
OLD | NEW |