Index: third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp |
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp |
index 65e2a3b58073a87c3e4f2784171f8c8f2fa21520..25c31dc2a7d68485338305e21e8ac21690939e81 100644 |
--- a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp |
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp |
@@ -12,6 +12,55 @@ constexpr int64_t IDBIndexMetadata::InvalidId; |
constexpr int64_t IDBObjectStoreMetadata::InvalidId; |
+IDBIndexMetadata::IDBIndexMetadata() = default; |
+ |
+IDBIndexMetadata::IDBIndexMetadata(const String& name, int64_t id, const IDBKeyPath& keyPath, bool unique, bool multiEntry) |
+ : name(name) |
+ , id(id) |
+ , keyPath(keyPath) |
+ , unique(unique) |
+ , multiEntry(multiEntry) |
+{ |
+} |
+ |
+IDBObjectStoreMetadata::IDBObjectStoreMetadata() = default; |
+ |
+IDBObjectStoreMetadata::IDBObjectStoreMetadata(const String& name, int64_t id, const IDBKeyPath& keyPath, bool autoIncrement, int64_t maxIndexId) |
+ : name(name) |
+ , id(id) |
+ , keyPath(keyPath) |
+ , autoIncrement(autoIncrement) |
+ , maxIndexId(maxIndexId) |
+{ |
+} |
+ |
+RefPtr<IDBObjectStoreMetadata> IDBObjectStoreMetadata::createCopy() const |
+{ |
+ RefPtr<IDBObjectStoreMetadata> copy = adoptRef(new IDBObjectStoreMetadata( |
+ name, id, keyPath, autoIncrement, maxIndexId)); |
+ |
+ for (const auto& it : indexes) { |
+ IDBIndexMetadata* index = it.value.get(); |
+ RefPtr<IDBIndexMetadata> indexCopy = adoptRef(new IDBIndexMetadata( |
+ index->name, index->id, index->keyPath, index->unique, index->multiEntry)); |
+ copy->indexes.add(it.key, std::move(indexCopy)); |
+ } |
+ return copy; |
+} |
+ |
+IDBDatabaseMetadata::IDBDatabaseMetadata() |
+ : version(IDBDatabaseMetadata::NoVersion) |
+{ |
+} |
+ |
+IDBDatabaseMetadata::IDBDatabaseMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId) |
+ : name(name) |
+ , id(id) |
+ , version(version) |
+ , maxObjectStoreId(maxObjectStoreId) |
+{ |
+} |
+ |
IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata) |
: name(webMetadata.name) |
, id(webMetadata.id) |
@@ -19,15 +68,17 @@ IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata) |
, maxObjectStoreId(webMetadata.maxObjectStoreId) |
{ |
for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) { |
- const WebIDBMetadata::ObjectStore webObjectStore = webMetadata.objectStores[i]; |
- IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.id, IDBKeyPath(webObjectStore.keyPath), webObjectStore.autoIncrement, webObjectStore.maxIndexId); |
+ const WebIDBMetadata::ObjectStore& webObjectStore = webMetadata.objectStores[i]; |
+ RefPtr<IDBObjectStoreMetadata> objectStore = adoptRef(new IDBObjectStoreMetadata( |
+ webObjectStore.name, webObjectStore.id, IDBKeyPath(webObjectStore.keyPath), webObjectStore.autoIncrement, webObjectStore.maxIndexId)); |
for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) { |
- const WebIDBMetadata::Index webIndex = webObjectStore.indexes[j]; |
- IDBIndexMetadata index(webIndex.name, webIndex.id, IDBKeyPath(webIndex.keyPath), webIndex.unique, webIndex.multiEntry); |
- objectStore.indexes.set(index.id, index); |
+ const WebIDBMetadata::Index& webIndex = webObjectStore.indexes[j]; |
+ RefPtr<IDBIndexMetadata> index = adoptRef(new IDBIndexMetadata( |
+ webIndex.name, webIndex.id, IDBKeyPath(webIndex.keyPath), webIndex.unique, webIndex.multiEntry)); |
+ objectStore->indexes.set(webIndex.id, std::move(index)); |
} |
- objectStores.set(objectStore.id, objectStore); |
+ objectStores.set(webObjectStore.id, std::move(objectStore)); |
} |
} |