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

Side by Side Diff: content/common/indexed_db/indexed_db_struct_traits.cc

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Address last nits and fix leaks in unit tests. 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 unified diff | Download patch
OLDNEW
(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 #include "content/common/indexed_db/indexed_db_param_traits.h"
6 #include "content/common/indexed_db/indexed_db_struct_traits.h"
7
8 namespace mojo {
9
10 bool StructTraits<indexed_db::mojom::IndexMetadataDataView,
11 content::IndexedDBIndexMetadata>::
12 Read(indexed_db::mojom::IndexMetadataDataView data,
13 content::IndexedDBIndexMetadata* out) {
14 out->id = data.id();
15 if (!data.ReadName(&out->name))
16 return false;
17 if (!data.ReadKeyPath(&out->key_path))
18 return false;
19 out->unique = data.unique();
20 out->multi_entry = data.multi_entry();
21 return true;
22 }
23
24 bool StructTraits<indexed_db::mojom::ObjectStoreMetadataDataView,
25 content::IndexedDBObjectStoreMetadata>::
26 Read(indexed_db::mojom::ObjectStoreMetadataDataView data,
27 content::IndexedDBObjectStoreMetadata* out) {
28 out->id = data.id();
29 if (!data.ReadName(&out->name))
30 return false;
31 if (!data.ReadKeyPath(&out->key_path))
32 return false;
33 out->auto_increment = data.auto_increment();
34 out->max_index_id = data.max_index_id();
35 ArrayDataView<indexed_db::mojom::IndexMetadataDataView> indexes;
36 data.GetIndexesDataView(&indexes);
37 for (size_t i = 0; i < indexes.size(); ++i) {
38 indexed_db::mojom::IndexMetadataDataView index;
39 indexes.GetDataView(i, &index);
40 DCHECK(!base::ContainsKey(out->indexes, index.id()));
41 if (!StructTraits<
42 indexed_db::mojom::IndexMetadataDataView,
43 content::IndexedDBIndexMetadata>::Read(index,
44 &out->indexes[index.id()]))
45 return false;
46 }
47 return true;
48 }
49
50 bool StructTraits<indexed_db::mojom::DatabaseMetadataDataView,
51 content::IndexedDBDatabaseMetadata>::
52 Read(indexed_db::mojom::DatabaseMetadataDataView data,
53 content::IndexedDBDatabaseMetadata* out) {
54 out->id = data.id();
55 if (!data.ReadName(&out->name))
56 return false;
57 out->version = data.version();
58 out->max_object_store_id = data.max_object_store_id();
59 ArrayDataView<indexed_db::mojom::ObjectStoreMetadataDataView> object_stores;
60 data.GetObjectStoresDataView(&object_stores);
61 for (size_t i = 0; i < object_stores.size(); ++i) {
62 indexed_db::mojom::ObjectStoreMetadataDataView object_store;
63 object_stores.GetDataView(i, &object_store);
64 DCHECK(!base::ContainsKey(out->object_stores, object_store.id()));
65 if (!StructTraits<indexed_db::mojom::ObjectStoreMetadataDataView,
66 content::IndexedDBObjectStoreMetadata>::
67 Read(object_store, &out->object_stores[object_store.id()]))
68 return false;
69 }
70 return true;
71 }
72
73 } // namespace mojo
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_struct_traits.h ('k') | content/common/indexed_db/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698