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

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 past the big reformat. 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 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 c6ed31a3aca476240b950f39f6f979267973b418..d065841d43eb6d06465121c82cb8dde6c0883aae 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp
@@ -12,27 +12,80 @@ 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),
version(webMetadata.version),
maxObjectStoreId(webMetadata.maxObjectStoreId) {
for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) {
- const WebIDBMetadata::ObjectStore webObjectStore =
+ const WebIDBMetadata::ObjectStore& webObjectStore =
webMetadata.objectStores[i];
- IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.id,
- IDBKeyPath(webObjectStore.keyPath),
- webObjectStore.autoIncrement,
- webObjectStore.maxIndexId);
+ 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