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

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

Issue 1988293002: [BlobAsync] Fixed race between IPC messages and IO task queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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..2b0e184b550a978aa46c23f718a2762a6f75ed08 100644
--- a/content/child/blob_storage/blob_transport_controller.cc
+++ b/content/child/blob_storage/blob_transport_controller.cc
@@ -72,22 +72,18 @@ void BlobTransportController::InitiateBlobTransfer(
main_runner->PostTask(FROM_HERE, base::Bind(&IncChildProcessRefCount));
}
- std::vector<storage::DataElement> descriptions;
+ // TODO(dmurph): handle racy io thread scheduling, so we can send both
+ // messages ASAP.
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.
+ sender->Send(new BlobStorageMsg_RegisterBlobUUID(uuid, content_type, "",
+ referenced_blobs));
io_runner->PostTask(
FROM_HERE,
- base::Bind(&BlobTransportController::StoreBlobDataForRequests,
+ base::Bind(&BlobTransportController::StoreBlobDataAndStart,
base::Unretained(BlobTransportController::GetInstance()), uuid,
- base::Passed(std::move(consolidation)),
- 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));
+ base::Passed(&consolidation),
+ base::Passed(&sender),
+ base::Passed(&main_runner)));
}
void BlobTransportController::OnMemoryRequest(
@@ -198,10 +194,16 @@ void BlobTransportController::ClearForTesting() {
blob_storage_.clear();
}
-void BlobTransportController::StoreBlobDataForRequests(
+void BlobTransportController::StoreBlobDataAndStart(
const std::string& uuid,
std::unique_ptr<BlobConsolidation> consolidation,
+ scoped_refptr<ThreadSafeSender> sender,
scoped_refptr<base::SingleThreadTaskRunner> main_runner) {
+ std::vector<storage::DataElement> descriptions;
+ BlobTransportController::GetDescriptions(
+ consolidation.get(), kBlobStorageIPCThresholdBytes, &descriptions);
+ sender->Send(new BlobStorageMsg_StartBuildingBlob(uuid, descriptions));
+
if (!main_thread_runner_.get()) {
main_thread_runner_ = std::move(main_runner);
}

Powered by Google App Engine
This is Rietveld 408576698