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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 492603002: Move SetUserData of BlobDataHandles from UploadDataStreamBuilder to ResourceDispatcherHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added comments in upload_data_stream_builder.h Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/loader/upload_data_stream_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 76ed7dee10e5b978d54ef18b0b0461e2175e86b1..4d571f824c3cbd388717aa4bdbb4f243f3d43a9b 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -306,6 +306,26 @@ storage::BlobStorageContext* GetBlobStorageContext(
return filter->blob_storage_context()->context();
}
+void AttachRequestBodyBlobDataHandles(
+ ResourceRequestBody* body,
+ storage::BlobStorageContext* blob_context) {
+ DCHECK(blob_context);
+ for (size_t i = 0; i < body->elements()->size(); ++i) {
+ const ResourceRequestBody::Element& element = (*body->elements())[i];
+ if (element.type() != ResourceRequestBody::Element::TYPE_BLOB)
+ continue;
+ scoped_ptr<storage::BlobDataHandle> handle =
+ blob_context->GetBlobDataFromUUID(element.blob_uuid());
+ DCHECK(handle);
+ if (!handle)
+ continue;
+ // Ensure the blob and any attached shareable files survive until
+ // upload completion. The |body| takes ownership of |handle|.
+ const void* key = handle.get();
+ body->SetUserData(key, handle.release());
+ }
+}
+
} // namespace
// static
@@ -1057,11 +1077,19 @@ void ResourceDispatcherHostImpl::BeginRequest(
new_request->SetLoadFlags(load_flags);
+ storage::BlobStorageContext* blob_context =
+ GetBlobStorageContext(filter_);
// Resolve elements from request_body and prepare upload data.
if (request_data.request_body.get()) {
+ // Attaches the BlobDataHandles to request_body not to free the blobs and
+ // any attached shareable files until upload completion. These data will be
+ // used in UploadDataStream and ServiceWorkerURLRequestJob.
+ AttachRequestBodyBlobDataHandles(
+ request_data.request_body.get(),
+ blob_context);
new_request->set_upload(UploadDataStreamBuilder::Build(
request_data.request_body.get(),
- GetBlobStorageContext(filter_),
+ blob_context,
filter_->file_system_context(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
.get()));
@@ -1111,7 +1139,7 @@ void ResourceDispatcherHostImpl::BeginRequest(
ServiceWorkerRequestHandler::InitializeHandler(
new_request.get(),
filter_->service_worker_context(),
- GetBlobStorageContext(filter_),
+ blob_context,
child_id,
request_data.service_worker_provider_id,
request_data.resource_type,
« no previous file with comments | « no previous file | content/browser/loader/upload_data_stream_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698