| 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 webkit_blob::BlobStorageContext* GetBlobStorageContext( | 302 webkit_blob::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 webkit_blob::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<webkit_blob::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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 | 1072 |
| 1053 const Referrer referrer(request_data.referrer, request_data.referrer_policy); | 1073 const Referrer referrer(request_data.referrer, request_data.referrer_policy); |
| 1054 SetReferrerForRequest(new_request.get(), referrer); | 1074 SetReferrerForRequest(new_request.get(), referrer); |
| 1055 | 1075 |
| 1056 net::HttpRequestHeaders headers; | 1076 net::HttpRequestHeaders headers; |
| 1057 headers.AddHeadersFromString(request_data.headers); | 1077 headers.AddHeadersFromString(request_data.headers); |
| 1058 new_request->SetExtraRequestHeaders(headers); | 1078 new_request->SetExtraRequestHeaders(headers); |
| 1059 | 1079 |
| 1060 new_request->SetLoadFlags(load_flags); | 1080 new_request->SetLoadFlags(load_flags); |
| 1061 | 1081 |
| 1082 webkit_blob::BlobStorageContext* blob_context = |
| 1083 GetBlobStorageContext(filter_); |
| 1062 // Resolve elements from request_body and prepare upload data. | 1084 // Resolve elements from request_body and prepare upload data. |
| 1063 if (request_data.request_body.get()) { | 1085 if (request_data.request_body.get()) { |
| 1086 // Attaches the BlobDataHandles to request_body not to free the blobs and |
| 1087 // any attached shareable files until upload completion. These data will be |
| 1088 // used in UploadDataStream and ServiceWorkerURLRequestJob. |
| 1089 AttachRequestBodyBlobDataHandles( |
| 1090 request_data.request_body.get(), |
| 1091 blob_context); |
| 1064 new_request->set_upload(UploadDataStreamBuilder::Build( | 1092 new_request->set_upload(UploadDataStreamBuilder::Build( |
| 1065 request_data.request_body.get(), | 1093 request_data.request_body.get(), |
| 1066 GetBlobStorageContext(filter_), | 1094 blob_context, |
| 1067 filter_->file_system_context(), | 1095 filter_->file_system_context(), |
| 1068 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | 1096 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
| 1069 .get())); | 1097 .get())); |
| 1070 } | 1098 } |
| 1071 | 1099 |
| 1072 bool allow_download = request_data.allow_download && | 1100 bool allow_download = request_data.allow_download && |
| 1073 IsResourceTypeFrame(request_data.resource_type); | 1101 IsResourceTypeFrame(request_data.resource_type); |
| 1074 | 1102 |
| 1075 // Make extra info and read footer (contains request ID). | 1103 // Make extra info and read footer (contains request ID). |
| 1076 ResourceRequestInfoImpl* extra_info = | 1104 ResourceRequestInfoImpl* extra_info = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1106 webkit_blob::BlobProtocolHandler::SetRequestedBlobDataHandle( | 1134 webkit_blob::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 1107 new_request.get(), | 1135 new_request.get(), |
| 1108 filter_->blob_storage_context()->context()-> | 1136 filter_->blob_storage_context()->context()-> |
| 1109 GetBlobDataFromPublicURL(new_request->url())); | 1137 GetBlobDataFromPublicURL(new_request->url())); |
| 1110 } | 1138 } |
| 1111 | 1139 |
| 1112 // Initialize the service worker handler for the request. | 1140 // Initialize the service worker handler for the request. |
| 1113 ServiceWorkerRequestHandler::InitializeHandler( | 1141 ServiceWorkerRequestHandler::InitializeHandler( |
| 1114 new_request.get(), | 1142 new_request.get(), |
| 1115 filter_->service_worker_context(), | 1143 filter_->service_worker_context(), |
| 1116 GetBlobStorageContext(filter_), | 1144 blob_context, |
| 1117 child_id, | 1145 child_id, |
| 1118 request_data.service_worker_provider_id, | 1146 request_data.service_worker_provider_id, |
| 1119 request_data.resource_type, | 1147 request_data.resource_type, |
| 1120 request_data.request_body); | 1148 request_data.request_body); |
| 1121 | 1149 |
| 1122 // Have the appcache associate its extra info with the request. | 1150 // Have the appcache associate its extra info with the request. |
| 1123 AppCacheInterceptor::SetExtraRequestInfo( | 1151 AppCacheInterceptor::SetExtraRequestInfo( |
| 1124 new_request.get(), filter_->appcache_service(), child_id, | 1152 new_request.get(), filter_->appcache_service(), child_id, |
| 1125 request_data.appcache_host_id, request_data.resource_type); | 1153 request_data.appcache_host_id, request_data.resource_type); |
| 1126 | 1154 |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1998 | 2026 |
| 1999 // Add a flag to selectively bypass the data reduction proxy if the resource | 2027 // Add a flag to selectively bypass the data reduction proxy if the resource |
| 2000 // type is not an image. | 2028 // type is not an image. |
| 2001 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) | 2029 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) |
| 2002 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; | 2030 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; |
| 2003 | 2031 |
| 2004 return load_flags; | 2032 return load_flags; |
| 2005 } | 2033 } |
| 2006 | 2034 |
| 2007 } // namespace content | 2035 } // namespace content |
| OLD | NEW |