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

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

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined BlobSlice & BlobFlattener files, more comments, a little cleanup. Created 4 years, 5 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 b5cc88416ca6f89b5c319c100d175ac2460b0f8e..773518cdf80f96e158791970ea9566bc49f285da 100644
--- a/content/child/blob_storage/blob_transport_controller.cc
+++ b/content/child/blob_storage/blob_transport_controller.cc
@@ -49,7 +49,7 @@ using storage::kBlobStorageIPCThresholdBytes;
using storage::BlobItemBytesResponse;
using storage::BlobItemBytesRequest;
-using storage::IPCBlobCreationCancelCode;
+using storage::BlobStatus;
namespace content {
using ConsolidatedItem = BlobConsolidation::ConsolidatedItem;
@@ -115,10 +115,7 @@ base::Optional<base::Time> WriteSingleRequestToDisk(
return base::make_optional(info.last_modified);
}
-// This returns either the responses, or if they're empty, an error code.
-std::pair<std::vector<storage::BlobItemBytesResponse>,
- IPCBlobCreationCancelCode>
-WriteDiskRequests(
+std::pair<BlobStatus, std::vector<BlobItemBytesResponse>> WriteDiskRequests(
michaeln 2016/08/15 22:44:43 oh, this might be a good place for a base::Optiona
dmurph 2016/08/19 00:18:32 Done.
scoped_refptr<BlobConsolidation> consolidation,
std::unique_ptr<std::vector<BlobItemBytesRequest>> requests,
const std::vector<IPC::PlatformFileForTransit>& file_handles) {
@@ -136,8 +133,8 @@ WriteDiskRequests(
base::Optional<base::Time> last_modified = WriteSingleRequestToDisk(
consolidation.get(), request, &files[request.handle_index]);
if (!last_modified) {
- return std::make_pair(std::vector<storage::BlobItemBytesResponse>(),
- IPCBlobCreationCancelCode::FILE_WRITE_FAILED);
+ return std::make_pair(BlobStatus::ERR_FILE_WRITE_FAILED,
+ std::vector<storage::BlobItemBytesResponse>());
}
last_modified_times[request.handle_index] = last_modified.value();
}
@@ -147,7 +144,7 @@ WriteDiskRequests(
last_modified_times[request.handle_index];
}
- return std::make_pair(responses, IPCBlobCreationCancelCode::UNKNOWN);
+ return std::make_pair(BlobStatus::DONE, responses);
}
} // namespace
@@ -171,7 +168,6 @@ void BlobTransportController::InitiateBlobTransfer(
}
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
@@ -182,10 +178,8 @@ void BlobTransportController::InitiateBlobTransfer(
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));
+ sender->Send(
+ new BlobStorageMsg_RegisterBlob(uuid, content_type, "", descriptions));
}
void BlobTransportController::OnMemoryRequest(
@@ -304,15 +298,12 @@ void BlobTransportController::OnMemoryRequest(
sender->Send(new BlobStorageMsg_MemoryItemResponse(uuid, responses));
}
-void BlobTransportController::OnCancel(
- const std::string& uuid,
- storage::IPCBlobCreationCancelCode code) {
- DVLOG(1) << "Received blob cancel for blob " << uuid
- << " with code: " << static_cast<int>(code);
- ReleaseBlobConsolidation(uuid);
-}
-
-void BlobTransportController::OnDone(const std::string& uuid) {
+void BlobTransportController::OnBlobStatus(const std::string& uuid,
+ storage::BlobStatus code) {
+ DVLOG_IF(1, storage::BlobStatusIsError(code))
+ << "Received blob error for blob " << uuid
+ << " with code: " << static_cast<int>(code);
+ DCHECK(code != storage::BlobStatus::PENDING);
ReleaseBlobConsolidation(uuid);
}
@@ -388,16 +379,15 @@ BlobTransportController::~BlobTransportController() {}
void BlobTransportController::OnFileWriteComplete(
IPC::Sender* sender,
const std::string& uuid,
- const std::pair<std::vector<BlobItemBytesResponse>,
- IPCBlobCreationCancelCode>& result) {
+ const std::pair<BlobStatus, std::vector<BlobItemBytesResponse>>& result) {
if (blob_storage_.find(uuid) == blob_storage_.end())
return;
- if (!result.first.empty()) {
- sender->Send(new BlobStorageMsg_MemoryItemResponse(uuid, result.first));
+ if (BlobStatusIsError(result.first)) {
+ sender->Send(new BlobStorageMsg_SendBlobStatus(uuid, result.first));
+ ReleaseBlobConsolidation(uuid);
return;
}
- sender->Send(new BlobStorageMsg_CancelBuildingBlob(uuid, result.second));
- ReleaseBlobConsolidation(uuid);
+ sender->Send(new BlobStorageMsg_MemoryItemResponse(uuid, result.second));
}
void BlobTransportController::StoreBlobDataForRequests(

Powered by Google App Engine
This is Rietveld 408576698