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

Unified Diff: content/common/indexed_db/indexed_db_struct_traits.cc

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Store IOThreadHelper in an unique_ptr and add a TestBrowserThreadBundle where needed. Created 4 years, 2 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: content/common/indexed_db/indexed_db_struct_traits.cc
diff --git a/content/common/indexed_db/indexed_db_struct_traits.cc b/content/common/indexed_db/indexed_db_struct_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2bbf297d1db98c7281adb61276b73bedceed9df3
--- /dev/null
+++ b/content/common/indexed_db/indexed_db_struct_traits.cc
@@ -0,0 +1,73 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/indexed_db/indexed_db_param_traits.h"
+#include "content/common/indexed_db/indexed_db_struct_traits.h"
+
+namespace mojo {
+
+bool StructTraits<indexed_db::mojom::IndexMetadataDataView,
+ content::IndexedDBIndexMetadata>::
+ Read(indexed_db::mojom::IndexMetadataDataView data,
+ content::IndexedDBIndexMetadata* out) {
+ out->id = data.id();
+ if (!data.ReadName(&out->name))
+ return false;
+ if (!data.ReadKeyPath(&out->key_path))
+ return false;
+ out->unique = data.unique();
+ out->multi_entry = data.multi_entry();
+ return true;
+}
+
+bool StructTraits<indexed_db::mojom::ObjectStoreMetadataDataView,
+ content::IndexedDBObjectStoreMetadata>::
+ Read(indexed_db::mojom::ObjectStoreMetadataDataView data,
+ content::IndexedDBObjectStoreMetadata* out) {
+ out->id = data.id();
+ if (!data.ReadName(&out->name))
+ return false;
+ if (!data.ReadKeyPath(&out->key_path))
+ return false;
+ out->auto_increment = data.auto_increment();
+ out->max_index_id = data.max_index_id();
+ ArrayDataView<indexed_db::mojom::IndexMetadataDataView> indexes;
+ data.GetIndexesDataView(&indexes);
+ for (size_t i = 0; i < indexes.size(); ++i) {
+ indexed_db::mojom::IndexMetadataDataView index;
+ indexes.GetDataView(i, &index);
+ DCHECK(!base::ContainsKey(out->indexes, index.id()));
+ if (!StructTraits<
+ indexed_db::mojom::IndexMetadataDataView,
+ content::IndexedDBIndexMetadata>::Read(index,
+ &out->indexes[index.id()]))
+ return false;
+ }
+ return true;
+}
+
+bool StructTraits<indexed_db::mojom::DatabaseMetadataDataView,
+ content::IndexedDBDatabaseMetadata>::
+ Read(indexed_db::mojom::DatabaseMetadataDataView data,
+ content::IndexedDBDatabaseMetadata* out) {
+ out->id = data.id();
+ if (!data.ReadName(&out->name))
+ return false;
+ out->version = data.version();
+ out->max_object_store_id = data.max_object_store_id();
+ ArrayDataView<indexed_db::mojom::ObjectStoreMetadataDataView> object_stores;
+ data.GetObjectStoresDataView(&object_stores);
+ for (size_t i = 0; i < object_stores.size(); ++i) {
+ indexed_db::mojom::ObjectStoreMetadataDataView object_store;
+ object_stores.GetDataView(i, &object_store);
+ DCHECK(!base::ContainsKey(out->object_stores, object_store.id()));
+ if (!StructTraits<indexed_db::mojom::ObjectStoreMetadataDataView,
+ content::IndexedDBObjectStoreMetadata>::
+ Read(object_store, &out->object_stores[object_store.id()]))
+ return false;
+ }
+ return true;
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698