| Index: storage/browser/blob/blob_memory_controller.cc
|
| diff --git a/storage/browser/blob/blob_memory_controller.cc b/storage/browser/blob/blob_memory_controller.cc
|
| index 6cc6c3f291f72005a32f017737a24984faece169..660269b31186eca12781727acbf4a36dc7399ef4 100644
|
| --- a/storage/browser/blob/blob_memory_controller.cc
|
| +++ b/storage/browser/blob/blob_memory_controller.cc
|
| @@ -45,6 +45,8 @@ File::Error CreateBlobDirectory(const FilePath& blob_storage_dir) {
|
| base::CreateDirectoryAndGetError(blob_storage_dir, &error);
|
| UMA_HISTOGRAM_ENUMERATION("Storage.Blob.CreateDirectoryResult", -error,
|
| -File::FILE_ERROR_MAX);
|
| + if (error != File::FILE_OK)
|
| + LOG(ERROR) << "Error creating blob storage directory: " << error;
|
| return error;
|
| }
|
|
|
| @@ -74,15 +76,6 @@ std::pair<std::vector<FileCreationInfo>, File::Error> CreateEmptyFiles(
|
| return std::make_pair(std::vector<FileCreationInfo>(),
|
| creation_info.error);
|
| }
|
| -
|
| - // Grab the file info to get the "last modified" time and store the file.
|
| - File::Info file_info;
|
| - bool success = file.GetInfo(&file_info);
|
| - creation_info.error = success ? File::FILE_OK : File::FILE_ERROR_FAILED;
|
| - if (!success) {
|
| - return std::make_pair(std::vector<FileCreationInfo>(),
|
| - creation_info.error);
|
| - }
|
| creation_info.file = std::move(file);
|
|
|
| result.push_back(std::move(creation_info));
|
| @@ -134,6 +127,10 @@ FileCreationInfo CreateFileAndWriteItems(
|
| if (bytes_written < 0)
|
| break;
|
| }
|
| + if (!file.Flush()) {
|
| + creation_info.error = File::FILE_ERROR_FAILED;
|
| + return creation_info;
|
| + }
|
|
|
| File::Info info;
|
| bool success = file.GetInfo(&info);
|
| @@ -159,9 +156,13 @@ uint64_t GetTotalSizeAndFileSizes(
|
| file_id_to_sizes[file_id] = element.offset() + element.length();
|
| total_size_output += element.length();
|
| }
|
| + uint64_t sizes_from_files = 0;
|
| for (const auto& size_pair : file_id_to_sizes) {
|
| file_sizes_output->push_back(size_pair.second);
|
| + sizes_from_files += size_pair.second;
|
| }
|
| + DCHECK_EQ(sizes_from_files, total_size_output)
|
| + << "Illegal builder configuration, temporary files must be totally used.";
|
| return total_size_output;
|
| }
|
|
|
| @@ -298,7 +299,7 @@ class BlobMemoryController::FileQuotaAllocationTask
|
| }
|
| ~FileQuotaAllocationTask() override {}
|
|
|
| - void RunDoneCallback(bool success, std::vector<FileCreationInfo> file_info) {
|
| + void RunDoneCallback(std::vector<FileCreationInfo> file_info, bool success) {
|
| // Make sure we clear the weak pointers we gave to the caller beforehand.
|
| weak_factory_.InvalidateWeakPtrs();
|
|
|
| @@ -313,7 +314,7 @@ class BlobMemoryController::FileQuotaAllocationTask
|
| controller_->pending_file_quota_tasks_.erase(my_list_position_);
|
| }
|
|
|
| - done_callback_.Run(success, std::move(file_info));
|
| + done_callback_.Run(std::move(file_info), success);
|
| }
|
|
|
| base::WeakPtr<QuotaAllocationTask> GetWeakPtr() {
|
| @@ -341,7 +342,7 @@ class BlobMemoryController::FileQuotaAllocationTask
|
| for (size_t i = 0; i < files.size(); i++) {
|
| files[i].file_reference = std::move(references[i]);
|
| }
|
| - RunDoneCallback(true, std::move(files));
|
| + RunDoneCallback(std::move(files), true);
|
| }
|
|
|
| // The my_list_position_ iterator is stored so that we can remove ourself
|
| @@ -379,6 +380,7 @@ BlobMemoryController::~BlobMemoryController() {}
|
| void BlobMemoryController::DisableFilePaging(base::File::Error reason) {
|
| UMA_HISTOGRAM_ENUMERATION("Storage.Blob.PagingDisabled", -reason,
|
| -File::FILE_ERROR_MAX);
|
| + LOG(ERROR) << "Blob storage paging disabled due to: " << reason;
|
| file_paging_enabled_ = false;
|
| in_flight_memory_used_ = 0;
|
| items_paging_to_file_.clear();
|
| @@ -398,7 +400,7 @@ void BlobMemoryController::DisableFilePaging(base::File::Error reason) {
|
| memory_request->RunDoneCallback(false);
|
| }
|
| for (auto& file_request : old_file_tasks) {
|
| - file_request->RunDoneCallback(false, std::vector<FileCreationInfo>());
|
| + file_request->RunDoneCallback(std::vector<FileCreationInfo>(), false);
|
| }
|
| }
|
|
|
|
|