OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_FLATTENER_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_FLATTENER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <utility> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "base/numerics/safe_math.h" |
| 14 #include "storage/browser/blob/blob_storage_registry.h" |
| 15 #include "storage/browser/blob/internal_blob_data.h" |
| 16 #include "storage/browser/storage_browser_export.h" |
| 17 |
| 18 namespace storage { |
| 19 class BlobDataBuilder; |
| 20 |
| 21 // The class takes an input BlobDataBuilder and turns it into our |
| 22 // InternalBlobData representation. This includes 'flattening' out blob |
| 23 // references by extracting the ShareableBlobDataItem slice from the reference |
| 24 // and including those items instead. The resulting flattened blob (both regular |
| 25 // items and items from other blobs) is put into the |output_blob|. We keep |
| 26 // track of edge cases like partial slicing on data or pending file entries, |
| 27 // and calculate the total & required memory for this blob. |
| 28 struct STORAGE_EXPORT BlobFlattener { |
| 29 BlobFlattener(const BlobDataBuilder& input_builder, |
| 30 InternalBlobData* output_blob, |
| 31 BlobStorageRegistry* registry); |
| 32 ~BlobFlattener(); |
| 33 |
| 34 // This can be: |
| 35 // * DONE if we're successful, |
| 36 // * PENDING_DATA_POPULATION if there's pending data that the user needs to |
| 37 // populate, |
| 38 // * INVALID_CONSTRUCTION_ARGUMENTS if we have invalid input, or |
| 39 // * REFERENCED_BLOB_BROKEN if one of the referenced blobs is broken or we |
| 40 // reference ourself. |
| 41 BlobStatus status = BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS; |
| 42 |
| 43 // This is the total size of the blob, including all memory, files, etc. |
| 44 base::CheckedNumeric<uint64_t> total_size; |
| 45 // This is the new memory needed to construct the blob, including both memory |
| 46 // items as well as copies from other blobs. |
| 47 base::CheckedNumeric<uint64_t> memory_needed; |
| 48 |
| 49 // This contains all blobs referenced. |
| 50 std::vector<std::pair<std::string, InternalBlobData*>> dependent_blobs; |
| 51 |
| 52 // These record all future copies we'll need to do from referenced blobs. This |
| 53 // happens when we do a partial slice from a pending data or file item. |
| 54 std::vector<InternalBlobData::ItemCopyEntry> copies; |
| 55 }; |
| 56 |
| 57 } // namespace storage |
| 58 #endif // STORAGE_BROWSER_BLOB_BLOB_FLATTENER_H_ |
OLD | NEW |