| 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 5db46a24726647bcf614777b5eb9322ae038a877..ba9aded2cfeca88efe65b2bd54bbb8eb5a362dc8 100644
|
| --- a/content/child/blob_storage/blob_transport_controller.cc
|
| +++ b/content/child/blob_storage/blob_transport_controller.cc
|
| @@ -82,6 +82,7 @@ bool WriteSingleChunk(base::File* file, const char* memory, size_t size) {
|
| int actual_written =
|
| file->WriteAtCurrentPos(memory, static_cast<int>(writing_size));
|
| bool write_failed = actual_written < 0;
|
| + LOG_IF(ERROR, write_failed) << "Write failed";
|
| UMA_HISTOGRAM_BOOLEAN("Storage.Blob.RendererFileWriteFailed", write_failed);
|
| if (write_failed)
|
| return false;
|
| @@ -90,27 +91,25 @@ bool WriteSingleChunk(base::File* file, const char* memory, size_t size) {
|
| return true;
|
| }
|
|
|
| -base::Optional<base::Time> WriteSingleRequestToDisk(
|
| - const BlobConsolidation* consolidation,
|
| - const BlobItemBytesRequest& request,
|
| - File* file) {
|
| +bool WriteSingleRequestToDisk(const BlobConsolidation* consolidation,
|
| + const BlobItemBytesRequest& request,
|
| + File* file) {
|
| if (!file->IsValid())
|
| - return base::nullopt;
|
| + return false;
|
| int64_t seek_distance = file->Seek(
|
| File::FROM_BEGIN, base::checked_cast<int64_t>(request.handle_offset));
|
| bool seek_failed = seek_distance < 0;
|
| UMA_HISTOGRAM_BOOLEAN("Storage.Blob.RendererFileSeekFailed", seek_failed);
|
| if (seek_failed) {
|
| - return base::nullopt;
|
| + LOG(ERROR) << "Seek failed";
|
| + return false;
|
| }
|
| BlobConsolidation::ReadStatus status = consolidation->VisitMemory(
|
| request.renderer_item_index, request.renderer_item_offset, request.size,
|
| base::Bind(&WriteSingleChunk, file));
|
| if (status != BlobConsolidation::ReadStatus::OK)
|
| - return base::nullopt;
|
| - File::Info info;
|
| - file->GetInfo(&info);
|
| - return base::make_optional(info.last_modified);
|
| + return false;
|
| + return true;
|
| }
|
|
|
| base::Optional<std::vector<BlobItemBytesResponse>> WriteDiskRequests(
|
| @@ -118,8 +117,6 @@ base::Optional<std::vector<BlobItemBytesResponse>> WriteDiskRequests(
|
| std::unique_ptr<std::vector<BlobItemBytesRequest>> requests,
|
| const std::vector<IPC::PlatformFileForTransit>& file_handles) {
|
| std::vector<BlobItemBytesResponse> responses;
|
| - std::vector<base::Time> last_modified_times;
|
| - last_modified_times.resize(file_handles.size());
|
| // We grab ownership of the file handles here. When this vector is destroyed
|
| // it will close the files.
|
| std::vector<File> files;
|
| @@ -127,14 +124,27 @@ base::Optional<std::vector<BlobItemBytesResponse>> WriteDiskRequests(
|
| for (const auto& file_handle : file_handles) {
|
| files.emplace_back(IPC::PlatformFileForTransitToFile(file_handle));
|
| }
|
| + // First we write everything, then we flush, then we grab the last modified
|
| + // times.
|
| for (const auto& request : *requests) {
|
| - base::Optional<base::Time> last_modified = WriteSingleRequestToDisk(
|
| - consolidation.get(), request, &files[request.handle_index]);
|
| - if (!last_modified) {
|
| + if (!WriteSingleRequestToDisk(consolidation.get(), request,
|
| + &files[request.handle_index])) {
|
| return base::nullopt;
|
| }
|
| - last_modified_times[request.handle_index] = last_modified.value();
|
| }
|
| + std::vector<base::Time> last_modified_times;
|
| + last_modified_times.resize(file_handles.size());
|
| + for (size_t i = 0; i < files.size(); ++i) {
|
| + auto& file = files[i];
|
| + if (!file.Flush())
|
| + return base::nullopt;
|
| + File::Info info;
|
| + if (!file.GetInfo(&info))
|
| + return base::nullopt;
|
| + LOG(ERROR) << "got post-flush modified time " << info.last_modified;
|
| + last_modified_times[i] = info.last_modified;
|
| + }
|
| +
|
| for (const auto& request : *requests) {
|
| responses.push_back(BlobItemBytesResponse(request.request_number));
|
| responses.back().time_file_modified =
|
| @@ -381,6 +391,7 @@ void BlobTransportController::OnFileWriteComplete(
|
| if (blob_storage_.find(uuid) == blob_storage_.end())
|
| return;
|
| if (!result) {
|
| + LOG(ERROR) << "Error writing files";
|
| sender->Send(new BlobStorageMsg_SendBlobStatus(
|
| uuid, BlobStatus::ERR_FILE_WRITE_FAILED));
|
| ReleaseBlobConsolidation(uuid);
|
|
|