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

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

Issue 2276593002: Support renaming of IndexedDB indexes and object stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for create rename in the same aborted transaction. 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/IDBIndex.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
index 86e2166751b60c43799b018e011b477ce57e10a7..ae313f8493c16d18a627144d25811d89ca649dfa 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
@@ -65,6 +65,46 @@ DEFINE_TRACE(IDBIndex)
visitor->trace(m_transaction);
}
+void IDBIndex::setName(const String& name, ExceptionState& exceptionState)
+{
+ if (!RuntimeEnabledFeatures::indexedDBExperimentalEnabled())
+ return;
+
+ IDB_TRACE("IDBIndex::setName");
+ if (!m_transaction->isVersionChange()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTransactionErrorMessage);
+ return;
+ }
+ if (isDeleted()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMessage);
+ return;
+ }
+ if (m_transaction->isFinished() || m_transaction->isFinishing()) {
+ exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
+ return;
+ }
+ if (!m_transaction->isActive()) {
+ exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
+ return;
+ }
+
+ if (m_metadata.name == name)
+ return;
+ if (m_objectStore->containsIndex(name)) {
+ exceptionState.throwDOMException(ConstraintError, IDBDatabase::indexNameTakenErrorMessage);
+ return;
+ }
+ if (!backendDB()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
+ return;
+ }
+
+ backendDB()->renameIndex(m_transaction->id(), m_objectStore->id(), id(), name);
+ m_objectStore->indexWillBeRenamed(m_metadata.name, name);
+ m_metadata.name = name;
+ m_transaction->db()->indexRenamed(m_objectStore->id(), id(), name);
+}
+
ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const
{
return ScriptValue::from(scriptState, m_metadata.keyPath);

Powered by Google App Engine
This is Rietveld 408576698