Chromium Code Reviews

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

Issue 2276593002: Support renaming of IndexedDB indexes and object stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: finished up rename-object-store tests. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
index 2f035a201a6dd6e53b3f691d8f07dbd57a52a8e3..100a5bc6e2904c070173d299197f15313129a91f 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
@@ -71,6 +71,38 @@ DEFINE_TRACE(IDBObjectStore)
visitor->trace(m_createdIndexes);
}
+void IDBObjectStore::setName(const String& name, ExceptionState& exceptionState)
+{
+ IDB_TRACE("IDBObjectStore::setName");
+ if (!m_transaction->isVersionChange()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTransactionErrorMessage);
jsbell 2016/08/26 23:20:50 FYI, we have a generic storage/indexeddb/exception
pwnall 2016/08/29 19:24:12 I think the Web Platform layout tests I wrote cove
+ return;
+ }
+ if (isDeleted()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectStoreDeletedErrorMessage);
+ 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_transaction->db()->containsObjectStore(name)) {
jsbell 2016/08/26 23:20:50 Do we need a special case for `store.name = store.
pwnall 2016/08/29 19:24:12 Yes, we do :) The code here doesn't pass the test
+ exceptionState.throwDOMException(ConstraintError, "An object store with the specified name already exists.");
+ return;
+ }
+ if (!backendDB()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
+ return;
+ }
+
+ m_metadata.name = name;
+}
+
ScriptValue IDBObjectStore::keyPath(ScriptState* scriptState) const
{
return ScriptValue::from(scriptState, m_metadata.keyPath);

Powered by Google App Engine