OLD | NEW |
---|---|
(Empty) | |
1 // TODO: Insert description here. (generated by dmurph) | |
2 | |
3 #include "storage/browser/blob/blob_flattener.h" | |
4 | |
5 #include <utility> | |
6 | |
7 #include "storage/browser/blob/blob_async_transport_request_builder.h" | |
8 #include "storage/browser/blob/blob_data_builder.h" | |
9 #include "storage/browser/blob/blob_storage_context.h" | |
10 #include "storage/browser/blob/blob_storage_registry.h" | |
11 #include "storage/browser/blob/shareable_blob_data_item.h" | |
12 | |
13 namespace storage { | |
14 namespace { | |
15 using ItemCopyEntry = BlobStorageRegistry::ItemCopyEntry; | |
16 | |
17 bool IsBytes(DataElement::Type type) { | |
18 return type == DataElement::TYPE_BYTES || | |
19 type == DataElement::TYPE_BYTES_DESCRIPTION; | |
20 } | |
21 | |
22 } // namespace | |
23 | |
24 void BlobFlattener::FlattenBlob( | |
25 const std::string& uuid, | |
26 InternalBlobData* output_blob, | |
27 std::vector<BlobStorageRegistry::ItemCopyEntry>* copies_from_built_ref, | |
28 std::vector<BlobStorageRegistry::ItemCopyEntry>* copies_from_pending_ref, | |
29 std::map<std::string, BlobSlice> slice_map, | |
30 const BlobDataBuilder& transportation_result) { | |
31 const std::vector<scoped_refptr<BlobDataItem>>& transport_items = | |
32 transportation_result.items_; | |
33 | |
34 size_t blob_flattening_index_offset = 0; | |
Marijn Kruisselbrink
2016/06/29 22:42:21
You're not using this for anything?
dmurph
2016/07/06 23:44:29
Removed thanks.
| |
35 size_t current_browser_index = 0; | |
36 for (size_t transport_item_index = 0; | |
37 transport_item_index < transport_items.size(); transport_item_index++) { | |
38 scoped_refptr<BlobDataItem> transport_item = | |
39 transport_items[transport_item_index]; | |
40 | |
41 if (IsBytes(transport_item->type())) { | |
42 output_blob->AppendSharedBlobItem( | |
43 uuid, | |
44 new ShareableBlobDataItem(BlobStorageContext::GetAndIncrementItemId(), | |
45 std::move(transport_item))); | |
46 current_browser_index++; | |
47 } else if (transport_item->type() == DataElement::TYPE_BLOB) { | |
48 BlobSlice& slice = slice_map[transport_item->blob_uuid()]; | |
49 std::vector<BlobStorageRegistry::ItemCopyEntry>* copies = | |
50 slice.done_building() ? copies_from_built_ref | |
Marijn Kruisselbrink
2016/06/29 22:42:21
is done_building() her the right thing to do? Or c
dmurph
2016/07/06 23:44:29
I can remove this now, especially because I no lon
| |
51 : copies_from_pending_ref; | |
52 if (slice.has_sliced_first_memory_item()) { | |
53 copies->push_back(ItemCopyEntry( | |
54 transport_item->blob_uuid(), slice.first_item_index(), | |
55 slice.first_item_slice_offset(), current_browser_index, | |
56 slice.items().front()->item()->length())); | |
57 } | |
58 | |
59 for (const auto& shareable_item : slice.items()) { | |
60 output_blob->AppendSharedBlobItem(uuid, std::move(shareable_item)); | |
61 ++current_browser_index; | |
62 ++blob_flattening_index_offset; | |
63 } | |
64 --blob_flattening_index_offset; | |
65 | |
66 if (slice.has_sliced_last_memory_item()) { | |
67 copies->push_back(ItemCopyEntry( | |
68 transport_item->blob_uuid(), slice.last_item_index(), 0, | |
69 current_browser_index - 1, slice.items().back()->item()->length())); | |
70 } | |
71 } else { | |
72 output_blob->AppendSharedBlobItem( | |
73 uuid, | |
74 new ShareableBlobDataItem(BlobStorageContext::GetAndIncrementItemId(), | |
75 std::move(transport_item))); | |
76 current_browser_index++; | |
77 } | |
78 } | |
79 } | |
80 | |
81 } // namespace storage | |
OLD | NEW |