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" | 7 #include "public/platform/modules/indexeddb/WebIDBMetadata.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
| 11 IDBIndexMetadata::IDBIndexMetadata() = default; |
| 12 |
| 13 IDBIndexMetadata::IDBIndexMetadata(const String& name, int64_t id, const IDBKeyP
ath& keyPath, bool unique, bool multiEntry) |
| 14 : name(name) |
| 15 , id(id) |
| 16 , keyPath(keyPath) |
| 17 , unique(unique) |
| 18 , multiEntry(multiEntry) |
| 19 { |
| 20 } |
| 21 |
| 22 IDBObjectStoreOwnMetadata::IDBObjectStoreOwnMetadata() |
| 23 { |
| 24 } |
| 25 |
| 26 IDBObjectStoreOwnMetadata::IDBObjectStoreOwnMetadata(const String& name, int64_t
id, const IDBKeyPath& keyPath, bool autoIncrement, int64_t maxIndexId) |
| 27 : name(name) |
| 28 , id(id) |
| 29 , keyPath(keyPath) |
| 30 , autoIncrement(autoIncrement) |
| 31 , maxIndexId(maxIndexId) |
| 32 { |
| 33 } |
| 34 |
| 35 IDBObjectStoreOwnMetadata::IDBObjectStoreOwnMetadata(const IDBObjectStoreOwnMeta
data&) = default; |
| 36 |
| 37 IDBObjectStoreOwnMetadata& IDBObjectStoreOwnMetadata::operator =(const IDBObject
StoreOwnMetadata&) = default; |
| 38 |
| 39 IDBObjectStoreMetadata::IDBObjectStoreMetadata() = default; |
| 40 |
| 41 IDBObjectStoreMetadata::IDBObjectStoreMetadata(const String& name, int64_t id, c
onst IDBKeyPath& keyPath, bool autoIncrement, int64_t maxIndexId) |
| 42 : own(name, id, keyPath, autoIncrement, maxIndexId) |
| 43 { |
| 44 } |
| 45 |
| 46 RefPtr<IDBObjectStoreMetadata> IDBObjectStoreMetadata::createCopy() const |
| 47 { |
| 48 RefPtr<IDBObjectStoreMetadata> copy = adoptRef(new IDBObjectStoreMetadata( |
| 49 own.name, own.id, own.keyPath, own.autoIncrement, own.maxIndexId)); |
| 50 |
| 51 for (const auto& it : indexes) { |
| 52 IDBIndexMetadata* index = it.value.get(); |
| 53 RefPtr<IDBIndexMetadata> indexCopy = adoptRef(new IDBIndexMetadata( |
| 54 index->name, index->id, index->keyPath, index->unique, index->multiE
ntry)); |
| 55 copy->indexes.add(it.key, std::move(indexCopy)); |
| 56 } |
| 57 return copy; |
| 58 } |
| 59 |
| 60 IDBDatabaseOwnMetadata::IDBDatabaseOwnMetadata() |
| 61 : version(IDBDatabaseMetadata::NoVersion) |
| 62 { |
| 63 } |
| 64 |
| 65 IDBDatabaseOwnMetadata::IDBDatabaseOwnMetadata(const String& name, int64_t id, i
nt64_t version, int64_t maxObjectStoreId) |
| 66 : name(name) |
| 67 , id(id) |
| 68 , version(version) |
| 69 , maxObjectStoreId(maxObjectStoreId) |
| 70 { |
| 71 } |
| 72 |
| 73 IDBDatabaseOwnMetadata::IDBDatabaseOwnMetadata(const IDBDatabaseOwnMetadata&) =
default; |
| 74 |
| 75 IDBDatabaseOwnMetadata& IDBDatabaseOwnMetadata::operator =(const IDBDatabaseOwnM
etadata&) = default; |
| 76 |
| 77 IDBDatabaseMetadata::IDBDatabaseMetadata() = default; |
| 78 |
| 79 IDBDatabaseMetadata::IDBDatabaseMetadata(const String& name, int64_t id, int64_t
version, int64_t maxObjectStoreId) |
| 80 : own(name, id, version, maxObjectStoreId) |
| 81 { |
| 82 } |
| 83 |
11 IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata) | 84 IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata) |
12 : name(webMetadata.name) | 85 : own(webMetadata.name, webMetadata.id, webMetadata.version, webMetadata.max
ObjectStoreId) |
13 , id(webMetadata.id) | |
14 , version(webMetadata.version) | |
15 , maxObjectStoreId(webMetadata.maxObjectStoreId) | |
16 { | 86 { |
17 for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) { | 87 for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) { |
18 const WebIDBMetadata::ObjectStore webObjectStore = webMetadata.objectSto
res[i]; | 88 const WebIDBMetadata::ObjectStore& webObjectStore = webMetadata.objectSt
ores[i]; |
19 IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.i
d, IDBKeyPath(webObjectStore.keyPath), webObjectStore.autoIncrement, webObjectSt
ore.maxIndexId); | 89 RefPtr<IDBObjectStoreMetadata> objectStore = adoptRef(new IDBObjectStore
Metadata( |
| 90 webObjectStore.name, webObjectStore.id, IDBKeyPath(webObjectStore.ke
yPath), webObjectStore.autoIncrement, webObjectStore.maxIndexId)); |
20 | 91 |
21 for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) { | 92 for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) { |
22 const WebIDBMetadata::Index webIndex = webObjectStore.indexes[j]; | 93 const WebIDBMetadata::Index& webIndex = webObjectStore.indexes[j]; |
23 IDBIndexMetadata index(webIndex.name, webIndex.id, IDBKeyPath(webInd
ex.keyPath), webIndex.unique, webIndex.multiEntry); | 94 RefPtr<IDBIndexMetadata> index = adoptRef(new IDBIndexMetadata( |
24 objectStore.indexes.set(index.id, index); | 95 webIndex.name, webIndex.id, IDBKeyPath(webIndex.keyPath), webInd
ex.unique, webIndex.multiEntry)); |
| 96 objectStore->indexes.set(webIndex.id, std::move(index)); |
25 } | 97 } |
26 objectStores.set(objectStore.id, objectStore); | 98 objectStores.set(webObjectStore.id, std::move(objectStore)); |
27 } | 99 } |
28 } | 100 } |
29 | 101 |
30 } // namespace blink | 102 } // namespace blink |
OLD | NEW |