OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/indexeddb/IDBMetadata.h" | 5 #include "modules/indexeddb/IDBMetadata.h" |
6 | 6 |
7 #include "public/platform/modules/indexeddb/WebIDBMetadata.h" | |
8 | |
9 namespace blink { | 7 namespace blink { |
10 | 8 |
11 IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata) | 9 IDBDatabaseMetadata::IDBDatabaseMetadata(indexed_db::mojom::blink::DatabaseMetad
ataPtr databaseMetadata) |
12 : name(webMetadata.name) | 10 : name(databaseMetadata->name) |
13 , id(webMetadata.id) | 11 , id(databaseMetadata->id) |
14 , version(webMetadata.version) | 12 , version(databaseMetadata->version) |
15 , maxObjectStoreId(webMetadata.maxObjectStoreId) | 13 , maxObjectStoreId(databaseMetadata->max_object_store_id) |
16 { | 14 { |
17 for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) { | 15 for (const auto& store : databaseMetadata->object_stores.values()) { |
18 const WebIDBMetadata::ObjectStore webObjectStore = webMetadata.objectSto
res[i]; | 16 IDBObjectStoreMetadata objectStore(store->name, store->id, IDBKeyPath(st
ore->key_path), store->auto_increment, store->max_index_id); |
19 IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.i
d, IDBKeyPath(webObjectStore.keyPath), webObjectStore.autoIncrement, webObjectSt
ore.maxIndexId); | 17 for (const auto& storeMetadata : store->indexes.values()) { |
20 | 18 IDBIndexMetadata index(storeMetadata->name, storeMetadata->id, IDBKe
yPath(storeMetadata->key_path), storeMetadata->unique, storeMetadata->multi_entr
y); |
21 for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) { | |
22 const WebIDBMetadata::Index webIndex = webObjectStore.indexes[j]; | |
23 IDBIndexMetadata index(webIndex.name, webIndex.id, IDBKeyPath(webInd
ex.keyPath), webIndex.unique, webIndex.multiEntry); | |
24 objectStore.indexes.set(index.id, index); | 19 objectStore.indexes.set(index.id, index); |
25 } | 20 } |
26 objectStores.set(objectStore.id, objectStore); | |
27 } | 21 } |
28 } | 22 } |
29 | 23 |
30 } // namespace blink | 24 } // namespace blink |
OLD | NEW |