| 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..f4a002fce198709621fa48b9224837b755bd62ac 100644
|
| --- a/storage/browser/blob/blob_memory_controller.cc
|
| +++ b/storage/browser/blob/blob_memory_controller.cc
|
| @@ -5,6 +5,7 @@
|
| #include "storage/browser/blob/blob_memory_controller.h"
|
|
|
| #include <algorithm>
|
| +#include <numeric>
|
|
|
| #include "base/callback.h"
|
| #include "base/callback_helpers.h"
|
| @@ -45,6 +46,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);
|
| + DLOG_IF(ERROR, error != File::FILE_OK)
|
| + << "Error creating blob storage directory: " << error;
|
| return error;
|
| }
|
|
|
| @@ -74,15 +77,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 +128,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);
|
| @@ -162,6 +160,10 @@ uint64_t GetTotalSizeAndFileSizes(
|
| for (const auto& size_pair : file_id_to_sizes) {
|
| file_sizes_output->push_back(size_pair.second);
|
| }
|
| + DCHECK_EQ(std::accumulate(file_sizes_output->begin(),
|
| + file_sizes_output->end(), 0ull),
|
| + total_size_output)
|
| + << "Illegal builder configuration, temporary files must be totally used.";
|
| return total_size_output;
|
| }
|
|
|
| @@ -298,7 +300,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 +315,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 +343,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 +381,7 @@ BlobMemoryController::~BlobMemoryController() {}
|
| void BlobMemoryController::DisableFilePaging(base::File::Error reason) {
|
| UMA_HISTOGRAM_ENUMERATION("Storage.Blob.PagingDisabled", -reason,
|
| -File::FILE_ERROR_MAX);
|
| + DLOG(ERROR) << "Blob storage paging disabled, reason: " << reason;
|
| file_paging_enabled_ = false;
|
| in_flight_memory_used_ = 0;
|
| items_paging_to_file_.clear();
|
| @@ -398,7 +401,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);
|
| }
|
| }
|
|
|
|
|