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

Unified Diff: content/child/blob_storage/blob_transport_controller.cc

Issue 1988983003: [BlobStorage] Fix IPC race in sending IPC and posting to IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix one test Created 4 years, 7 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
Index: content/child/blob_storage/blob_transport_controller.cc
diff --git a/content/child/blob_storage/blob_transport_controller.cc b/content/child/blob_storage/blob_transport_controller.cc
index 0bcadbc85d30e80ac8d13d4cbaad0b5864627a04..c9d89060c08234e6c8360fa559e939d504bfa186 100644
--- a/content/child/blob_storage/blob_transport_controller.cc
+++ b/content/child/blob_storage/blob_transport_controller.cc
@@ -72,22 +72,12 @@ void BlobTransportController::InitiateBlobTransfer(
main_runner->PostTask(FROM_HERE, base::Bind(&IncChildProcessRefCount));
}
- std::vector<storage::DataElement> descriptions;
- std::set<std::string> referenced_blobs = consolidation->referenced_blobs();
- BlobTransportController::GetDescriptions(
- consolidation.get(), kBlobStorageIPCThresholdBytes, &descriptions);
- // I post the task first to make sure that we store our consolidation before
- // we get a request back from the browser.
io_runner->PostTask(
FROM_HERE,
- base::Bind(&BlobTransportController::StoreBlobDataForRequests,
- base::Unretained(BlobTransportController::GetInstance()), uuid,
- base::Passed(std::move(consolidation)),
+ base::Bind(&BlobTransportController::InitiateBlobTransferOnIOThread, uuid,
+ content_type, base::Passed(std::move(consolidation)),
+ base::Passed(std::move(sender)),
base::Passed(std::move(main_runner))));
- // TODO(dmurph): Merge register and start messages.
- sender->Send(new BlobStorageMsg_RegisterBlobUUID(uuid, content_type, "",
- referenced_blobs));
- sender->Send(new BlobStorageMsg_StartBuildingBlob(uuid, descriptions));
}
void BlobTransportController::OnMemoryRequest(
@@ -198,6 +188,26 @@ void BlobTransportController::ClearForTesting() {
blob_storage_.clear();
}
+// static
+void BlobTransportController::InitiateBlobTransferOnIOThread(
+ const std::string& uuid,
+ const std::string& content_type,
+ std::unique_ptr<BlobConsolidation> consolidation,
+ scoped_refptr<ThreadSafeSender> sender,
+ scoped_refptr<base::SingleThreadTaskRunner> main_runner) {
+ std::vector<storage::DataElement> descriptions;
+ std::set<std::string> referenced_blobs = consolidation->referenced_blobs();
+ BlobTransportController::GetDescriptions(
+ consolidation.get(), kBlobStorageIPCThresholdBytes, &descriptions);
+ BlobTransportController::GetInstance()->StoreBlobDataForRequests(
+ uuid, std::move(consolidation), std::move(main_runner));
+
+ // TODO(dmurph): Merge register and start messages.
+ sender->Send(new BlobStorageMsg_RegisterBlobUUID(uuid, content_type, "",
+ referenced_blobs));
+ sender->Send(new BlobStorageMsg_StartBuildingBlob(uuid, descriptions));
+}
+
void BlobTransportController::StoreBlobDataForRequests(
const std::string& uuid,
std::unique_ptr<BlobConsolidation> consolidation,

Powered by Google App Engine
This is Rietveld 408576698