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

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp

Issue 2314933005: Align IndexedDB metadata rollback on transaction abort to spec. (Closed)
Patch Set: Rebased. Created 4 years, 3 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: 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 e2b28eae4389b401287565c39ae6c90b2904903c..668f3cba47214e2ba94fab421f46f3411cc7d9d7 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp
@@ -8,22 +8,94 @@
namespace blink {
+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)
+{
+}
+
+IDBObjectStoreOwnMetadata::IDBObjectStoreOwnMetadata()
+{
+}
+
+IDBObjectStoreOwnMetadata::IDBObjectStoreOwnMetadata(const String& name, int64_t id, const IDBKeyPath& keyPath, bool autoIncrement, int64_t maxIndexId)
+ : name(name)
+ , id(id)
+ , keyPath(keyPath)
+ , autoIncrement(autoIncrement)
+ , maxIndexId(maxIndexId)
+{
+}
+
+IDBObjectStoreOwnMetadata::IDBObjectStoreOwnMetadata(const IDBObjectStoreOwnMetadata&) = default;
+
+IDBObjectStoreOwnMetadata& IDBObjectStoreOwnMetadata::operator =(const IDBObjectStoreOwnMetadata&) = default;
+
+IDBObjectStoreMetadata::IDBObjectStoreMetadata() = default;
+
+IDBObjectStoreMetadata::IDBObjectStoreMetadata(const String& name, int64_t id, const IDBKeyPath& keyPath, bool autoIncrement, int64_t maxIndexId)
+ : own(name, id, keyPath, autoIncrement, maxIndexId)
+{
+}
+
+RefPtr<IDBObjectStoreMetadata> IDBObjectStoreMetadata::createCopy() const
+{
+ RefPtr<IDBObjectStoreMetadata> copy = adoptRef(new IDBObjectStoreMetadata(
+ own.name, own.id, own.keyPath, own.autoIncrement, own.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;
+}
+
+IDBDatabaseOwnMetadata::IDBDatabaseOwnMetadata()
+ : version(IDBDatabaseMetadata::NoVersion)
+{
+}
+
+IDBDatabaseOwnMetadata::IDBDatabaseOwnMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId)
+ : name(name)
+ , id(id)
+ , version(version)
+ , maxObjectStoreId(maxObjectStoreId)
+{
+}
+
+IDBDatabaseOwnMetadata::IDBDatabaseOwnMetadata(const IDBDatabaseOwnMetadata&) = default;
+
+IDBDatabaseOwnMetadata& IDBDatabaseOwnMetadata::operator =(const IDBDatabaseOwnMetadata&) = default;
+
+IDBDatabaseMetadata::IDBDatabaseMetadata() = default;
+
+IDBDatabaseMetadata::IDBDatabaseMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId)
+ : own(name, id, version, maxObjectStoreId)
+{
+}
+
IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata)
- : name(webMetadata.name)
- , id(webMetadata.id)
- , version(webMetadata.version)
- , maxObjectStoreId(webMetadata.maxObjectStoreId)
+ : own(webMetadata.name, webMetadata.id, webMetadata.version, 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));
}
}

Powered by Google App Engine
This is Rietveld 408576698