Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1034)

Unified Diff: storage/browser/blob/blob_flattener.cc

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added back transport controller test, small cleanups Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: storage/browser/blob/blob_flattener.cc
diff --git a/storage/browser/blob/blob_flattener.cc b/storage/browser/blob/blob_flattener.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c069966884249dcf5ee5f285b53b4535a6ce2bbf
--- /dev/null
+++ b/storage/browser/blob/blob_flattener.cc
@@ -0,0 +1,81 @@
+// TODO: Insert description here. (generated by dmurph)
+
+#include "storage/browser/blob/blob_flattener.h"
+
+#include <utility>
+
+#include "storage/browser/blob/blob_async_transport_request_builder.h"
+#include "storage/browser/blob/blob_data_builder.h"
+#include "storage/browser/blob/blob_storage_context.h"
+#include "storage/browser/blob/blob_storage_registry.h"
+#include "storage/browser/blob/shareable_blob_data_item.h"
+
+namespace storage {
+namespace {
+using ItemCopyEntry = BlobStorageRegistry::ItemCopyEntry;
+
+bool IsBytes(DataElement::Type type) {
+ return type == DataElement::TYPE_BYTES ||
+ type == DataElement::TYPE_BYTES_DESCRIPTION;
+}
+
+} // namespace
+
+void BlobFlattener::FlattenBlob(
+ const std::string& uuid,
+ InternalBlobData* output_blob,
+ std::vector<BlobStorageRegistry::ItemCopyEntry>* copies_from_built_ref,
+ std::vector<BlobStorageRegistry::ItemCopyEntry>* copies_from_pending_ref,
+ std::map<std::string, BlobSlice> slice_map,
+ const BlobDataBuilder& transportation_result) {
+ const std::vector<scoped_refptr<BlobDataItem>>& transport_items =
+ transportation_result.items_;
+
+ 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.
+ size_t current_browser_index = 0;
+ for (size_t transport_item_index = 0;
+ transport_item_index < transport_items.size(); transport_item_index++) {
+ scoped_refptr<BlobDataItem> transport_item =
+ transport_items[transport_item_index];
+
+ if (IsBytes(transport_item->type())) {
+ output_blob->AppendSharedBlobItem(
+ uuid,
+ new ShareableBlobDataItem(BlobStorageContext::GetAndIncrementItemId(),
+ std::move(transport_item)));
+ current_browser_index++;
+ } else if (transport_item->type() == DataElement::TYPE_BLOB) {
+ BlobSlice& slice = slice_map[transport_item->blob_uuid()];
+ std::vector<BlobStorageRegistry::ItemCopyEntry>* copies =
+ 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
+ : copies_from_pending_ref;
+ if (slice.has_sliced_first_memory_item()) {
+ copies->push_back(ItemCopyEntry(
+ transport_item->blob_uuid(), slice.first_item_index(),
+ slice.first_item_slice_offset(), current_browser_index,
+ slice.items().front()->item()->length()));
+ }
+
+ for (const auto& shareable_item : slice.items()) {
+ output_blob->AppendSharedBlobItem(uuid, std::move(shareable_item));
+ ++current_browser_index;
+ ++blob_flattening_index_offset;
+ }
+ --blob_flattening_index_offset;
+
+ if (slice.has_sliced_last_memory_item()) {
+ copies->push_back(ItemCopyEntry(
+ transport_item->blob_uuid(), slice.last_item_index(), 0,
+ current_browser_index - 1, slice.items().back()->item()->length()));
+ }
+ } else {
+ output_blob->AppendSharedBlobItem(
+ uuid,
+ new ShareableBlobDataItem(BlobStorageContext::GetAndIncrementItemId(),
+ std::move(transport_item)));
+ current_browser_index++;
+ }
+ }
+}
+
+} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698