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/storage_browser_export.h" | |
16 | |
17 namespace storage { | |
18 class BlobDataBuilder; | |
19 class InternalBlobData; | |
20 | |
21 // This class takes a BlobDataBuilder which can contain blob references and | |
22 // 'flattens' these references out. The resulting flattened blob (both regular | |
23 // items and items from other blobs) is put into the |output_blob|. We keep | |
24 // track of edge cases like partial slicing on data or pending file entries, | |
25 // and calculate the total & required memory for this blob. | |
26 struct STORAGE_EXPORT BlobFlattener { | |
kinuko
2016/07/17 16:15:46
Btw this seems to do more than just flattening out
kinuko
2016/07/17 16:15:46
Is the only user of this struct BlobStorageContext
dmurph
2016/07/19 02:26:27
Same problem as BlobSlice, where we need 5 output
| |
27 BlobFlattener(const BlobDataBuilder& transportation_result, | |
kinuko
2016/07/17 16:15:46
nit: On the callsite we just call the builder 'con
dmurph
2016/07/19 02:26:27
Done.
| |
28 InternalBlobData* output_blob, | |
29 BlobStorageRegistry* registry); | |
30 ~BlobFlattener(); | |
31 | |
32 // References didn't exist, the reference offset/size were invalid, or we were | |
33 // referencing ourself. | |
34 bool contains_invalid_references = false; | |
35 // A references was broken, so we should be broken. | |
36 bool contains_broken_references = false; | |
37 | |
38 // The input builder has an item with type TYPE_BYTES_DESCRIPTION or TYPE_FILE | |
39 // with the path == BlobDataBuilder::kAppendFutureFileTemporaryFileName. | |
40 // (These occur when one calls AppendFutureData or AppendFutureFile on the | |
41 // builder). | |
42 bool contains_pending_content = false; | |
kinuko
2016/07/17 16:15:46
Could these three bools be just captured as a sing
dmurph
2016/07/19 02:26:27
Done.
| |
43 | |
44 // This is the total size of the blob, including all memory, files, etc. | |
45 base::CheckedNumeric<uint64_t> total_size; | |
46 // This is the new memory needed to construct the blob, including both memory | |
47 // items as well as copies from other blobs. | |
48 base::CheckedNumeric<uint64_t> memory_needed; | |
49 | |
50 // This contains all blobs referenced. | |
51 std::vector<std::pair<std::string, BlobStorageRegistry::Entry*>> | |
52 dependent_blobs; | |
53 | |
54 // These record all future copies we'll need to do from referenced blobs. This | |
55 // happens when we do a partial slice from a pending data or file item. | |
56 std::vector<BlobStorageRegistry::ItemCopyEntry> copies; | |
57 }; | |
58 | |
59 } // namespace storage | |
60 #endif // STORAGE_BROWSER_BLOB_BLOB_FLATTENER_H_ | |
OLD | NEW |