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

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBIndex.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/IDBIndex.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
index c0c93bb67abf5ab45c928e3270436578f997909c..8ea793ebcff3f514642f73d4e0df42939b593e7b 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
@@ -45,14 +45,15 @@ using blink::WebIDBDatabase;
namespace blink {
-IDBIndex::IDBIndex(const IDBIndexMetadata& metadata,
+IDBIndex::IDBIndex(RefPtr<IDBIndexMetadata> metadata,
IDBObjectStore* objectStore,
IDBTransaction* transaction)
- : m_metadata(metadata),
+ : m_metadata(std::move(metadata)),
m_objectStore(objectStore),
m_transaction(transaction) {
DCHECK(m_objectStore);
DCHECK(m_transaction);
+ DCHECK(m_metadata.get());
DCHECK_NE(id(), IDBIndexMetadata::InvalidId);
}
@@ -105,15 +106,21 @@ void IDBIndex::setName(const String& name, ExceptionState& exceptionState) {
backendDB()->renameIndex(m_transaction->id(), m_objectStore->id(), id(),
name);
- m_metadata.name = name;
- m_objectStore->indexRenamed(m_metadata.id, name);
- m_transaction->db()->indexRenamed(m_objectStore->id(), id(), name);
+ m_objectStore->renameIndex(id(), name);
}
ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const {
return ScriptValue::from(scriptState, metadata().keyPath);
}
+void IDBIndex::revertMetadata(RefPtr<IDBIndexMetadata> oldMetadata) {
+ m_metadata = std::move(oldMetadata);
+
+ // An index's metadata will only get reverted if the index was in the
+ // database when the versionchange transaction started.
+ m_deleted = false;
+}
+
IDBRequest* IDBIndex::openCursor(ScriptState* scriptState,
const ScriptValue& range,
const String& directionString,
@@ -374,8 +381,4 @@ WebIDBDatabase* IDBIndex::backendDB() const {
return m_transaction->backendDB();
}
-bool IDBIndex::isDeleted() const {
- return m_deleted || m_objectStore->isDeleted();
-}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698