OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "storage/browser/blob/blob_memory_controller.h" | 5 #include "storage/browser/blob/blob_memory_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <numeric> | 8 #include <numeric> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 bytes_written < 0 || !success ? File::FILE_ERROR_FAILED : File::FILE_OK; | 238 bytes_written < 0 || !success ? File::FILE_ERROR_FAILED : File::FILE_OK; |
239 creation_info.last_modified = info.last_modified; | 239 creation_info.last_modified = info.last_modified; |
240 return std::make_pair(std::move(creation_info), disk_availability); | 240 return std::make_pair(std::move(creation_info), disk_availability); |
241 } | 241 } |
242 | 242 |
243 uint64_t GetTotalSizeAndFileSizes( | 243 uint64_t GetTotalSizeAndFileSizes( |
244 const std::vector<scoped_refptr<ShareableBlobDataItem>>& | 244 const std::vector<scoped_refptr<ShareableBlobDataItem>>& |
245 unreserved_file_items, | 245 unreserved_file_items, |
246 std::vector<uint64_t>* file_sizes_output) { | 246 std::vector<uint64_t>* file_sizes_output) { |
247 uint64_t total_size_output = 0; | 247 uint64_t total_size_output = 0; |
248 base::SmallMap<std::map<uint64_t, uint64_t>> file_id_to_sizes; | 248 base::small_map<std::map<uint64_t, uint64_t>> file_id_to_sizes; |
249 for (const auto& item : unreserved_file_items) { | 249 for (const auto& item : unreserved_file_items) { |
250 const DataElement& element = item->item()->data_element(); | 250 const DataElement& element = item->item()->data_element(); |
251 uint64_t file_id = BlobDataBuilder::GetFutureFileID(element); | 251 uint64_t file_id = BlobDataBuilder::GetFutureFileID(element); |
252 auto it = file_id_to_sizes.find(file_id); | 252 auto it = file_id_to_sizes.find(file_id); |
253 if (it != file_id_to_sizes.end()) | 253 if (it != file_id_to_sizes.end()) |
254 it->second = std::max(it->second, element.offset() + element.length()); | 254 it->second = std::max(it->second, element.offset() + element.length()); |
255 else | 255 else |
256 file_id_to_sizes[file_id] = element.offset() + element.length(); | 256 file_id_to_sizes[file_id] = element.offset() + element.length(); |
257 total_size_output += element.length(); | 257 total_size_output += element.length(); |
258 } | 258 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 MaybeGrantPendingMemoryRequests(); | 975 MaybeGrantPendingMemoryRequests(); |
976 } | 976 } |
977 | 977 |
978 void BlobMemoryController::OnBlobFileDelete(uint64_t size, | 978 void BlobMemoryController::OnBlobFileDelete(uint64_t size, |
979 const FilePath& path) { | 979 const FilePath& path) { |
980 DCHECK_LE(size, disk_used_); | 980 DCHECK_LE(size, disk_used_); |
981 disk_used_ -= size; | 981 disk_used_ -= size; |
982 } | 982 } |
983 | 983 |
984 } // namespace storage | 984 } // namespace storage |
OLD | NEW |