WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-88467-20120607170131.patch (text/plain), 86.49 KB, created by
Joshua Bell
on 2012-06-07 17:01:32 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Joshua Bell
Created:
2012-06-07 17:01:32 PDT
Size:
86.49 KB
patch
obsolete
>Subversion Revision: 119733 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3cc45163b681838458470b3634ae7cc2c2081f80..9a927ef7aa188501e8d877c49f9032e051e861ec 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,101 @@ >+2012-06-07 Joshua Bell <jsbell@chromium.org> >+ >+ IndexedDB: Snapshot metadata in front end to avoid IPC round-trips >+ https://bugs.webkit.org/show_bug.cgi?id=88467 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: storage/indexeddb/deleted-objects.html >+ storage/indexeddb/metadata.html >+ >+ * Modules/indexeddb/IDBDatabase.cpp: >+ (WebCore::IDBDatabase::IDBDatabase): >+ (WebCore::IDBDatabase::setVersionChangeTransaction): >+ (WebCore::IDBDatabase::clearVersionChangeTransaction): >+ (WebCore): >+ (WebCore::IDBDatabase::objectStoreNames): >+ (WebCore::IDBDatabase::createObjectStore): >+ (WebCore::IDBDatabase::deleteObjectStore): >+ * Modules/indexeddb/IDBDatabase.h: >+ (WebCore::IDBDatabase::name): >+ (WebCore::IDBDatabase::version): >+ (IDBDatabase): >+ (WebCore::IDBDatabase::metaData): >+ * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: >+ (WebCore::IDBDatabaseBackendImpl::metaData): >+ (WebCore): >+ * Modules/indexeddb/IDBDatabaseBackendImpl.h: >+ (IDBDatabaseBackendImpl): >+ * Modules/indexeddb/IDBDatabaseBackendInterface.h: >+ (WebCore): >+ (IDBDatabaseBackendInterface): >+ * Modules/indexeddb/IDBIndex.cpp: >+ (WebCore::IDBIndex::IDBIndex): >+ (WebCore::IDBIndex::openCursor): >+ (WebCore::IDBIndex::count): >+ (WebCore::IDBIndex::openKeyCursor): >+ (WebCore::IDBIndex::get): >+ (WebCore::IDBIndex::getKey): >+ * Modules/indexeddb/IDBIndex.h: >+ (WebCore::IDBIndex::create): >+ (WebCore::IDBIndex::name): >+ (WebCore::IDBIndex::objectStore): >+ (WebCore::IDBIndex::keyPath): >+ (WebCore::IDBIndex::unique): >+ (WebCore::IDBIndex::multiEntry): >+ (WebCore::IDBIndex::markDeleted): >+ (IDBIndex): >+ * Modules/indexeddb/IDBIndexBackendImpl.cpp: >+ (WebCore::IDBIndexBackendImpl::metaData): >+ (WebCore): >+ * Modules/indexeddb/IDBIndexBackendImpl.h: >+ (IDBIndexBackendImpl): >+ * Modules/indexeddb/IDBMetaData.h: Added. >+ (WebCore): >+ (WebCore::IDBDatabaseMetaData::IDBDatabaseMetaData): >+ (IDBDatabaseMetaData): >+ (WebCore::IDBObjectStoreMetaData::IDBObjectStoreMetaData): >+ (IDBObjectStoreMetaData): >+ (WebCore::IDBIndexMetaData::IDBIndexMetaData): >+ (IDBIndexMetaData): >+ * Modules/indexeddb/IDBObjectStore.cpp: >+ (WebCore::IDBObjectStore::IDBObjectStore): >+ (WebCore::IDBObjectStore::indexNames): >+ (WebCore::IDBObjectStore::get): >+ (WebCore::IDBObjectStore::add): >+ (WebCore::IDBObjectStore::put): >+ (WebCore::IDBObjectStore::deleteFunction): >+ (WebCore::IDBObjectStore::clear): >+ (WebCore::IDBObjectStore::createIndex): >+ (WebCore::IDBObjectStore::index): >+ (WebCore::IDBObjectStore::deleteIndex): >+ (WebCore::IDBObjectStore::openCursor): >+ (WebCore::IDBObjectStore::count): >+ * Modules/indexeddb/IDBObjectStore.h: >+ (WebCore::IDBObjectStore::create): >+ (WebCore::IDBObjectStore::name): >+ (WebCore::IDBObjectStore::keyPath): >+ (WebCore::IDBObjectStore::transaction): >+ (WebCore::IDBObjectStore::autoIncrement): >+ (WebCore::IDBObjectStore::markDeleted): >+ (WebCore::IDBObjectStore::resetMetaData): >+ (IDBObjectStore): >+ * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: >+ (WebCore::IDBObjectStoreBackendImpl::metaData): >+ (WebCore): >+ * Modules/indexeddb/IDBObjectStoreBackendImpl.h: >+ (WebCore): >+ (IDBObjectStoreBackendImpl): >+ * Modules/indexeddb/IDBTransaction.cpp: >+ (WebCore::IDBTransaction::objectStore): >+ (WebCore::IDBTransaction::objectStoreCreated): >+ (WebCore::IDBTransaction::objectStoreDeleted): >+ (WebCore::IDBTransaction::onAbort): >+ * Modules/indexeddb/IDBTransaction.h: >+ (WebCore::IDBTransaction::isVersionChange): >+ (IDBTransaction): >+ * WebCore.gypi: >+ > 2012-06-07 Raymes Khoury <raymes@chromium.org> > > Incorrect rect-based hit-test result for culled-inline elements >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 075e996c6dadd2ee5f8629895df19aa09c5e41f4..9d9cc01c1e636aa41039fd585c21439842b22896 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,59 @@ >+2012-06-07 Joshua Bell <jsbell@chromium.org> >+ >+ IndexedDB: Snapshot metadata in front end to avoid IPC round-trips >+ https://bugs.webkit.org/show_bug.cgi?id=88467 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebKit.gyp: >+ * public/WebIDBDatabase.h: >+ (WebKit::WebIDBDatabase::metaData): >+ * public/WebIDBMetaData.h: Added. >+ (WebCore): >+ (WebKit): >+ (WebIDBDatabaseMetaData): >+ (WebIDBObjectStoreMetaData): >+ (WebIDBIndexMetaData): >+ * src/IDBDatabaseBackendProxy.cpp: >+ (WebKit::IDBDatabaseBackendProxy::metaData): >+ (WebKit): >+ * src/IDBDatabaseBackendProxy.h: >+ (IDBDatabaseBackendProxy): >+ * src/WebIDBDatabaseImpl.cpp: >+ (WebKit::WebIDBDatabaseImpl::metaData): >+ (WebKit): >+ * src/WebIDBDatabaseImpl.h: >+ (WebKit): >+ (WebIDBDatabaseImpl): >+ * src/WebIDBMetaData.cpp: Added. >+ (WebKit): >+ (WebKit::WebIDBDatabaseMetaData::create): >+ (WebKit::WebIDBDatabaseMetaData::WebIDBDatabaseMetaData): >+ (WebKit::WebIDBDatabaseMetaData::~WebIDBDatabaseMetaData): >+ (WebKit::WebIDBDatabaseMetaData::name): >+ (WebKit::WebIDBDatabaseMetaData::version): >+ (WebKit::WebIDBDatabaseMetaData::objectStores): >+ (WebKit::WebIDBDatabaseMetaData::operator=): >+ (WebKit::WebIDBDatabaseMetaData::operator const WebCore::IDBDatabaseMetaData&): >+ (WebKit::WebIDBObjectStoreMetaData::create): >+ (WebKit::WebIDBObjectStoreMetaData::WebIDBObjectStoreMetaData): >+ (WebKit::WebIDBObjectStoreMetaData::~WebIDBObjectStoreMetaData): >+ (WebKit::WebIDBObjectStoreMetaData::name): >+ (WebKit::WebIDBObjectStoreMetaData::keyPath): >+ (WebKit::WebIDBObjectStoreMetaData::autoIncrement): >+ (WebKit::WebIDBObjectStoreMetaData::indexes): >+ (WebKit::WebIDBObjectStoreMetaData::operator=): >+ (WebKit::WebIDBObjectStoreMetaData::operator const WebCore::IDBObjectStoreMetaData&): >+ (WebKit::WebIDBIndexMetaData::create): >+ (WebKit::WebIDBIndexMetaData::WebIDBIndexMetaData): >+ (WebKit::WebIDBIndexMetaData::~WebIDBIndexMetaData): >+ (WebKit::WebIDBIndexMetaData::name): >+ (WebKit::WebIDBIndexMetaData::keyPath): >+ (WebKit::WebIDBIndexMetaData::unique): >+ (WebKit::WebIDBIndexMetaData::multiEntry): >+ (WebKit::WebIDBIndexMetaData::operator=): >+ (WebKit::WebIDBIndexMetaData::operator const WebCore::IDBIndexMetaData&): >+ > 2012-06-07 Daniel Erat <derat@chromium.org> > > Add setting to enable subpixel-positioned text on Linux. >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >index e1f44cd5060a5c5801cda0f4ef92a50a02ce7262..9b7db6a40a0b51117fe71e4144acb38a8ca88200 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >@@ -65,6 +65,7 @@ IDBDatabase::IDBDatabase(ScriptExecutionContext* context, PassRefPtr<IDBDatabase > // We pass a reference of this object before it can be adopted. > relaxAdoptionRequirement(); > m_databaseCallbacks = IDBDatabaseCallbacksImpl::create(this); >+ m_metaData = m_backend->metaData(); > } > > IDBDatabase::~IDBDatabase() >@@ -77,12 +78,23 @@ void IDBDatabase::setVersionChangeTransaction(IDBTransaction* transaction) > { > ASSERT(!m_versionChangeTransaction); > m_versionChangeTransaction = transaction; >+ m_metaData = m_backend->metaData(); > } > > void IDBDatabase::clearVersionChangeTransaction(IDBTransaction* transaction) > { > ASSERT_UNUSED(transaction, m_versionChangeTransaction == transaction); > m_versionChangeTransaction = 0; >+ m_metaData = m_backend->metaData(); >+} >+ >+PassRefPtr<DOMStringList> IDBDatabase::objectStoreNames() const >+{ >+ RefPtr<DOMStringList> objectStoreNames = DOMStringList::create(); >+ for (IDBDatabaseMetaData::ObjectStoreMap::const_iterator it = m_metaData.objectStores.begin(); it != m_metaData.objectStores.end(); ++it) >+ objectStoreNames->append(it->first); >+ objectStoreNames->sort(); >+ return objectStoreNames.release(); > } > > PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const Dictionary& options, ExceptionCode& ec) >@@ -122,7 +134,10 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co > return 0; > } > >- RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(objectStoreBackend.release(), m_versionChangeTransaction.get()); >+ IDBObjectStoreMetaData metaData(name, keyPath, autoIncrement); >+ RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metaData, objectStoreBackend.release(), m_versionChangeTransaction.get()); >+ m_metaData.objectStores.set(name, metaData); >+ > m_versionChangeTransaction->objectStoreCreated(name, objectStore); > return objectStore.release(); > } >@@ -135,7 +150,10 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionCode& ec) > } > > m_backend->deleteObjectStore(name, m_versionChangeTransaction->backend(), ec); >- m_versionChangeTransaction->objectStoreDeleted(name); >+ if (!ec) { >+ m_versionChangeTransaction->objectStoreDeleted(name); >+ m_metaData.objectStores.remove(name); >+ } > } > > PassRefPtr<IDBVersionChangeRequest> IDBDatabase::setVersion(ScriptExecutionContext* context, const String& version, ExceptionCode& ec) >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabase.h b/Source/WebCore/Modules/indexeddb/IDBDatabase.h >index 6656352f361871e4cfa3d6f7c5b9d7448025f278..0fbc62df704e90ec77aeff5de17152a4e0202c04 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabase.h >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabase.h >@@ -33,6 +33,7 @@ > #include "EventTarget.h" > #include "IDBDatabaseBackendInterface.h" > #include "IDBDatabaseCallbacksImpl.h" >+#include "IDBMetaData.h" > #include "IDBObjectStore.h" > #include "IDBTransaction.h" > #include <wtf/PassRefPtr.h> >@@ -57,9 +58,9 @@ public: > void clearVersionChangeTransaction(IDBTransaction*); > > // Implement the IDL >- String name() const { return m_backend->name(); } >- String version() const { return m_backend->version(); } >- PassRefPtr<DOMStringList> objectStoreNames() const { return m_backend->objectStoreNames(); } >+ String name() const { return m_metaData.name; } >+ String version() const { return m_metaData.version; } >+ PassRefPtr<DOMStringList> objectStoreNames() const; > > // FIXME: Try to modify the code generator so this is unneeded. > PassRefPtr<IDBObjectStore> createObjectStore(const String& name, ExceptionCode& ec) { return createObjectStore(name, Dictionary(), ec); } >@@ -87,6 +88,7 @@ public: > virtual ScriptExecutionContext* scriptExecutionContext() const; > > void open(); >+ const IDBDatabaseMetaData& metaData() const { return m_metaData; } > void enqueueEvent(PassRefPtr<Event>); > bool dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) { return EventTarget::dispatchEvent(event, ec); } > virtual bool dispatchEvent(PassRefPtr<Event>); >@@ -103,6 +105,7 @@ private: > virtual EventTargetData* eventTargetData(); > virtual EventTargetData* ensureEventTargetData(); > >+ IDBDatabaseMetaData m_metaData; > RefPtr<IDBDatabaseBackendInterface> m_backend; > RefPtr<IDBTransaction> m_versionChangeTransaction; > >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp >index 3b29731583929613d1a22fe92f8849d83282b16a..1e38f06d1ac98b34648a0b28254bf084d088819e 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp >@@ -134,6 +134,14 @@ PassRefPtr<IDBBackingStore> IDBDatabaseBackendImpl::backingStore() const > return m_backingStore; > } > >+IDBDatabaseMetaData IDBDatabaseBackendImpl::metaData() const >+{ >+ IDBDatabaseMetaData metaData(m_name, m_version); >+ for (ObjectStoreMap::const_iterator it = m_objectStores.begin(); it != m_objectStores.end(); ++it) >+ metaData.objectStores.set(it->first, it->second->metaData()); >+ return metaData; >+} >+ > PassRefPtr<DOMStringList> IDBDatabaseBackendImpl::objectStoreNames() const > { > RefPtr<DOMStringList> objectStoreNames = DOMStringList::create(); >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h >index 2a6fb3b77216e7c3c566393ed6a5e57e8156dbd4..5b112155ba036708f2f6c26244cf08c3b5765368 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h >@@ -58,6 +58,7 @@ public: > void openConnection(PassRefPtr<IDBCallbacks>); > void deleteDatabase(PassRefPtr<IDBCallbacks>); > >+ virtual IDBDatabaseMetaData metaData() const; > virtual String name() const { return m_name; } > virtual String version() const { return m_version; } > virtual PassRefPtr<DOMStringList> objectStoreNames() const; >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h >index e072a0f3959d70d51a50c26b1eb21520c596eb1f..9c3a1c35641b9012f0db55987a31f4e4886cc114 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h >@@ -41,6 +41,7 @@ class IDBDatabaseCallbacks; > class IDBKeyPath; > class IDBObjectStoreBackendInterface; > class IDBTransactionBackendInterface; >+struct IDBDatabaseMetaData; > > typedef int ExceptionCode; > >@@ -52,6 +53,7 @@ class IDBDatabaseBackendInterface : public ThreadSafeRefCounted<IDBDatabaseBacke > public: > virtual ~IDBDatabaseBackendInterface() { } > >+ virtual IDBDatabaseMetaData metaData() const = 0; > virtual String name() const = 0; > virtual String version() const = 0; > virtual PassRefPtr<DOMStringList> objectStoreNames() const = 0; >diff --git a/Source/WebCore/Modules/indexeddb/IDBIndex.cpp b/Source/WebCore/Modules/indexeddb/IDBIndex.cpp >index 57cdb1215a4157186b39c69a6e7239442f7d04a7..51d96c6a2190063753e49f22f458dfbed1e9507e 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBIndex.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBIndex.cpp >@@ -42,10 +42,12 @@ namespace WebCore { > > static const unsigned short defaultDirection = IDBCursor::NEXT; > >-IDBIndex::IDBIndex(PassRefPtr<IDBIndexBackendInterface> backend, IDBObjectStore* objectStore, IDBTransaction* transaction) >- : m_backend(backend) >+IDBIndex::IDBIndex(const IDBIndexMetaData& metaData, PassRefPtr<IDBIndexBackendInterface> backend, IDBObjectStore* objectStore, IDBTransaction* transaction) >+ : m_metaData(metaData) >+ , m_backend(backend) > , m_objectStore(objectStore) > , m_transaction(transaction) >+ , m_deleted(false) > { > ASSERT(m_backend); > ASSERT(m_objectStore); >@@ -59,6 +61,10 @@ IDBIndex::~IDBIndex() > PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, const String& directionString, ExceptionCode& ec) > { > IDB_TRACE("IDBIndex::openCursor"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > unsigned short direction = IDBCursor::stringToDirection(directionString, ec); > if (ec) > return 0; >@@ -105,6 +111,10 @@ PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, Pas > PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) > { > IDB_TRACE("IDBIndex::count"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); > m_backend->count(keyRange, request, m_transaction->backend(), ec); > if (ec) { >@@ -126,6 +136,10 @@ PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, PassRefP > PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, const String& directionString, ExceptionCode& ec) > { > IDB_TRACE("IDBIndex::openKeyCursor"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > > unsigned short direction = IDBCursor::stringToDirection(directionString, ec); > if (ec) >@@ -173,6 +187,10 @@ PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, > PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBIndex::get"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (key && (key->type() == IDBKey::InvalidType)) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -188,6 +206,10 @@ PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, PassRefPtr > PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) > { > IDB_TRACE("IDBIndex::get"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (!keyRange) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -205,6 +227,10 @@ PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, PassRefPtr > PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBIndex::getKey"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (key && (key->type() == IDBKey::InvalidType)) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -220,6 +246,10 @@ PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, PassRef > PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) > { > IDB_TRACE("IDBIndex::getKey"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (!keyRange) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >diff --git a/Source/WebCore/Modules/indexeddb/IDBIndex.h b/Source/WebCore/Modules/indexeddb/IDBIndex.h >index a90ace03da09639a57088c4163dd07ffe27e018b..d2b6e3ff805725dd5635cea337deba13f9fbf6ad 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBIndex.h >+++ b/Source/WebCore/Modules/indexeddb/IDBIndex.h >@@ -30,6 +30,8 @@ > #include "IDBIndexBackendInterface.h" > #include "IDBKeyPath.h" > #include "IDBKeyRange.h" >+#include "IDBMetaData.h" >+#include "IDBObjectStore.h" > #include "IDBRequest.h" > #include "PlatformString.h" > #include <wtf/Forward.h> >@@ -42,18 +44,18 @@ class IDBObjectStore; > > class IDBIndex : public RefCounted<IDBIndex> { > public: >- static PassRefPtr<IDBIndex> create(PassRefPtr<IDBIndexBackendInterface> backend, IDBObjectStore* objectStore, IDBTransaction* transaction) >+ static PassRefPtr<IDBIndex> create(const IDBIndexMetaData& metaData, PassRefPtr<IDBIndexBackendInterface> backend, IDBObjectStore* objectStore, IDBTransaction* transaction) > { >- return adoptRef(new IDBIndex(backend, objectStore, transaction)); >+ return adoptRef(new IDBIndex(metaData, backend, objectStore, transaction)); > } > ~IDBIndex(); > > // Implement the IDL >- String name() const { return m_backend->name(); } >- IDBObjectStore* objectStore() const { return m_objectStore.get(); } >- PassRefPtr<IDBAny> keyPath() const { return m_backend->keyPath(); } >- bool unique() const { return m_backend->unique(); } >- bool multiEntry() const { return m_backend->multiEntry(); } >+ String name() const { return m_metaData.name; } >+ PassRefPtr<IDBObjectStore> objectStore() const { return m_objectStore; } >+ PassRefPtr<IDBAny> keyPath() const { return m_metaData.keyPath; } >+ bool unique() const { return m_metaData.unique; } >+ bool multiEntry() const { return m_metaData.multiEntry; } > > // FIXME: Try to modify the code generator so this is unneeded. > PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, static_cast<IDBKeyRange*>(0), ec); } >@@ -80,12 +82,16 @@ public: > PassRefPtr<IDBRequest> getKey(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&); > PassRefPtr<IDBRequest> getKey(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&); > >+ void markDeleted() { m_deleted = true; } >+ > private: >- IDBIndex(PassRefPtr<IDBIndexBackendInterface>, IDBObjectStore*, IDBTransaction*); >+ IDBIndex(const IDBIndexMetaData&, PassRefPtr<IDBIndexBackendInterface>, IDBObjectStore*, IDBTransaction*); > >+ IDBIndexMetaData m_metaData; > RefPtr<IDBIndexBackendInterface> m_backend; > RefPtr<IDBObjectStore> m_objectStore; > RefPtr<IDBTransaction> m_transaction; >+ bool m_deleted; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp >index 6fc37317caa7e4604148806294834fe8e601d7d1..1966f1676650e2d69217a18c4d2ad50c7b1fb5db 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp >@@ -36,6 +36,7 @@ > #include "IDBDatabaseException.h" > #include "IDBKey.h" > #include "IDBKeyRange.h" >+#include "IDBMetaData.h" > #include "IDBObjectStoreBackendImpl.h" > #include "IDBTracing.h" > >@@ -69,6 +70,11 @@ IDBIndexBackendImpl::~IDBIndexBackendImpl() > { > } > >+IDBIndexMetaData IDBIndexBackendImpl::metaData() const >+{ >+ return IDBIndexMetaData(m_name, m_keyPath, m_unique, m_multiEntry); >+} >+ > void IDBIndexBackendImpl::openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl> index, PassRefPtr<IDBKeyRange> range, unsigned short untypedDirection, IDBCursorBackendInterface::CursorType cursorType, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBTransactionBackendInterface> transaction) > { > IDB_TRACE("IDBIndexBackendImpl::openCursorInternal"); >diff --git a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h >index 20f35c4f3fa39ad04c152b474ac8d1703a045cde..a0d50cdb878dabc48f2bfd13532fdf0e62f01a4d 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h >+++ b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h >@@ -31,6 +31,7 @@ > #include "IDBCursorBackendInterface.h" > #include "IDBIndexBackendInterface.h" > #include "IDBKeyPath.h" >+#include "IDBMetaData.h" > > namespace WebCore { > >@@ -62,6 +63,7 @@ public: > bool addingKeyAllowed(const IDBKey* indexKey, const IDBKey* primaryKey = 0); > > // Implements IDBIndexBackendInterface. >+ virtual IDBIndexMetaData metaData() const; > virtual String name() { return m_name; } > virtual IDBKeyPath keyPath() { return m_keyPath; } > virtual bool unique() { return m_unique; } >diff --git a/Source/WebCore/Modules/indexeddb/IDBMetaData.h b/Source/WebCore/Modules/indexeddb/IDBMetaData.h >new file mode 100644 >index 0000000000000000000000000000000000000000..ed09fe00cb4149806c4f9dce7d008bbda1a2f785 >--- /dev/null >+++ b/Source/WebCore/Modules/indexeddb/IDBMetaData.h >@@ -0,0 +1,87 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of >+ * its contributors may be used to endorse or promote products derived >+ * from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY GOOGLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef IDBMetaData_h >+#define IDBMetaData_h >+ >+#include "IDBKeyPath.h" >+#include "PlatformString.h" >+#include <wtf/HashMap.h> >+#include <wtf/text/StringHash.h> >+ >+#if ENABLE(INDEXED_DATABASE) >+ >+namespace WebCore { >+ >+struct IDBObjectStoreMetaData; >+struct IDBIndexMetaData; >+ >+struct IDBDatabaseMetaData { >+ IDBDatabaseMetaData() { } >+ IDBDatabaseMetaData(const String& name, const String& version) >+ : name(name) >+ , version(version) { } >+ String name; >+ String version; >+ >+ typedef HashMap<String, IDBObjectStoreMetaData> ObjectStoreMap; >+ ObjectStoreMap objectStores; >+}; >+ >+struct IDBObjectStoreMetaData { >+ IDBObjectStoreMetaData() { } >+ IDBObjectStoreMetaData(const String& name, const IDBKeyPath& keyPath, bool autoIncrement) >+ : name(name) >+ , keyPath(keyPath) >+ , autoIncrement(autoIncrement) { } >+ String name; >+ IDBKeyPath keyPath; >+ bool autoIncrement; >+ >+ typedef HashMap<String, IDBIndexMetaData> IndexMap; >+ IndexMap indexes; >+}; >+ >+struct IDBIndexMetaData { >+ IDBIndexMetaData() { } >+ IDBIndexMetaData(const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry) >+ : name(name) >+ , keyPath(keyPath) >+ , unique(unique) >+ , multiEntry(multiEntry) { } >+ String name; >+ IDBKeyPath keyPath; >+ bool unique; >+ bool multiEntry; >+}; >+ >+} >+ >+#endif // ENABLE(INDEXED_DATABASE) >+ >+#endif // IDBTracing_h >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp b/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp >index 6fd7d5d63bd10e4ac9aa9ac03316239d7ffad247..e89b9b31db5040003fe8ebe26e4ea9e3e7a8c498 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp >@@ -30,6 +30,7 @@ > > #include "DOMStringList.h" > #include "IDBAny.h" >+#include "IDBDatabase.h" > #include "IDBDatabaseException.h" > #include "IDBIndex.h" > #include "IDBKey.h" >@@ -44,9 +45,12 @@ namespace WebCore { > > static const unsigned short defaultDirection = IDBCursor::NEXT; > >-IDBObjectStore::IDBObjectStore(PassRefPtr<IDBObjectStoreBackendInterface> idbObjectStore, IDBTransaction* transaction) >- : m_backend(idbObjectStore) >+IDBObjectStore::IDBObjectStore(const IDBObjectStoreMetaData& metaData, PassRefPtr<IDBObjectStoreBackendInterface> idbObjectStore, IDBTransaction* transaction) >+ : m_metaData(metaData) >+ , m_previousMetaData(metaData) >+ , m_backend(idbObjectStore) > , m_transaction(transaction) >+ , m_deleted(false) > { > ASSERT(m_backend); > ASSERT(m_transaction); >@@ -54,34 +58,14 @@ IDBObjectStore::IDBObjectStore(PassRefPtr<IDBObjectStoreBackendInterface> idbObj > relaxAdoptionRequirement(); > } > >-String IDBObjectStore::name() const >-{ >- IDB_TRACE("IDBObjectStore::name"); >- return m_backend->name(); >-} >- >-PassRefPtr<IDBAny> IDBObjectStore::keyPath() const >-{ >- IDB_TRACE("IDBObjectStore::keyPath"); >- return m_backend->keyPath(); >-} >- > PassRefPtr<DOMStringList> IDBObjectStore::indexNames() const > { > IDB_TRACE("IDBObjectStore::indexNames"); >- return m_backend->indexNames(); >-} >- >-IDBTransaction* IDBObjectStore::transaction() const >-{ >- IDB_TRACE("IDBObjectStore::transaction"); >- return m_transaction.get(); >-} >- >-bool IDBObjectStore::autoIncrement() const >-{ >- IDB_TRACE("IDBObjectStore::autoIncrement"); >- return m_backend->autoIncrement(); >+ RefPtr<DOMStringList> indexNames = DOMStringList::create(); >+ for (IDBObjectStoreMetaData::IndexMap::const_iterator it = m_metaData.indexes.begin(); it != m_metaData.indexes.end(); ++it) >+ indexNames->append(it->first); >+ indexNames->sort(); >+ return indexNames.release(); > } > > PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) >@@ -104,6 +88,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, Pass > PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::get"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (!key || (key->type() == IDBKey::InvalidType)) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -118,6 +106,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, Pass > PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::add"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (key && (key->type() == IDBKey::InvalidType)) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -142,6 +134,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, Pass > PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::put"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (key && (key->type() == IDBKey::InvalidType)) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -166,6 +162,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, Pass > PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::delete"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (!keyRange) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -183,6 +183,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* co > PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::delete"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (!key || !key->isValid()) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -200,6 +204,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* co > PassRefPtr<IDBRequest> IDBObjectStore::clear(ScriptExecutionContext* context, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::clear"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); > m_backend->clear(request, m_transaction->backend(), ec); > if (ec) { >@@ -226,6 +234,11 @@ PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, PassRefPtr< > PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const IDBKeyPath& keyPath, const Dictionary& options, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::createIndex"); >+ if (!m_transaction->isVersionChange() || m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } >+ > if (!keyPath.isValid()) { > ec = IDBDatabaseException::IDB_SYNTAX_ERR; > return 0; >@@ -244,16 +257,24 @@ PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const IDBKe > > RefPtr<IDBIndexBackendInterface> indexBackend = m_backend->createIndex(name, keyPath, unique, multiEntry, m_transaction->backend(), ec); > ASSERT(!indexBackend != !ec); // If we didn't get an index, we should have gotten an exception code. And vice versa. >- if (!indexBackend) >+ if (ec) > return 0; >- RefPtr<IDBIndex> index = IDBIndex::create(indexBackend.release(), this, m_transaction.get()); >+ >+ IDBIndexMetaData metaData(name, keyPath, unique, multiEntry); >+ RefPtr<IDBIndex> index = IDBIndex::create(metaData, indexBackend.release(), this, m_transaction.get()); > m_indexMap.set(name, index); >+ m_metaData.indexes.set(name, metaData); >+ > return index.release(); > } > > PassRefPtr<IDBIndex> IDBObjectStore::index(const String& name, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::index"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > if (m_transaction->isFinished()) { > ec = IDBDatabaseException::NOT_ALLOWED_ERR; > return 0; >@@ -265,22 +286,46 @@ PassRefPtr<IDBIndex> IDBObjectStore::index(const String& name, ExceptionCode& ec > > RefPtr<IDBIndexBackendInterface> indexBackend = m_backend->index(name, ec); > ASSERT(!indexBackend != !ec); // If we didn't get an index, we should have gotten an exception code. And vice versa. >- if (!indexBackend) >+ if (ec) >+ return 0; >+ >+ IDBObjectStoreMetaData::IndexMap::const_iterator mdit = m_metaData.indexes.find(name); >+ // FIXME: This can change into an ASSERT once http://webkit.org/b/80547 is fixed. >+ if (mdit == m_metaData.indexes.end()) > return 0; > >- RefPtr<IDBIndex> index = IDBIndex::create(indexBackend.release(), this, m_transaction.get()); >+ RefPtr<IDBIndex> index = IDBIndex::create(mdit->second, indexBackend.release(), this, m_transaction.get()); > m_indexMap.set(name, index); > return index.release(); > } > > void IDBObjectStore::deleteIndex(const String& name, ExceptionCode& ec) > { >+ if (!m_transaction->isVersionChange() || m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return; >+ } >+ > m_backend->deleteIndex(name, m_transaction->backend(), ec); >+ if (!ec) { >+ IDBIndexMap::iterator it = m_indexMap.find(name); >+ if (it != m_indexMap.end()) { >+ it->second->markDeleted(); >+ m_indexMap.remove(name); >+ } >+ >+ ASSERT(m_metaData.indexes.contains(name)); >+ m_metaData.indexes.remove(name); >+ } > } > > PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> range, const String& directionString, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::openCursor"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > unsigned short direction = IDBCursor::stringToDirection(directionString, ec); > if (ec) > return 0; >@@ -327,6 +372,10 @@ PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* contex > PassRefPtr<IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> range, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::count"); >+ if (m_deleted) { >+ ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >+ return 0; >+ } > RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get()); > m_backend->count(range, request, m_transaction->backend(), ec); > if (ec) { >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.h b/Source/WebCore/Modules/indexeddb/IDBObjectStore.h >index e11fbd080d2bed97513c78576124908c0207bdfb..394107b91480c9a33951af316a3820d89c8db41d 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStore.h >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStore.h >@@ -31,6 +31,7 @@ > #include "IDBIndex.h" > #include "IDBKey.h" > #include "IDBKeyRange.h" >+#include "IDBMetaData.h" > #include "IDBObjectStoreBackendInterface.h" > #include "IDBRequest.h" > #include "IDBTransaction.h" >@@ -49,18 +50,18 @@ class IDBAny; > > class IDBObjectStore : public RefCounted<IDBObjectStore> { > public: >- static PassRefPtr<IDBObjectStore> create(PassRefPtr<IDBObjectStoreBackendInterface> idbObjectStore, IDBTransaction* transaction) >+ static PassRefPtr<IDBObjectStore> create(const IDBObjectStoreMetaData& metaData, PassRefPtr<IDBObjectStoreBackendInterface> backend, IDBTransaction* transaction) > { >- return adoptRef(new IDBObjectStore(idbObjectStore, transaction)); >+ return adoptRef(new IDBObjectStore(metaData, backend, transaction)); > } > ~IDBObjectStore() { } > > // Implement the IDBObjectStore IDL >- String name() const; >- PassRefPtr<IDBAny> keyPath() const; >+ String name() const { return m_metaData.name; } >+ PassRefPtr<IDBAny> keyPath() const { return m_metaData.keyPath; } > PassRefPtr<DOMStringList> indexNames() const; >- IDBTransaction* transaction() const; >- bool autoIncrement() const; >+ PassRefPtr<IDBTransaction> transaction() const { return m_transaction; } >+ bool autoIncrement() const { return m_metaData.autoIncrement; } > > PassRefPtr<IDBRequest> add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return add(context, value, 0, ec); } > PassRefPtr<IDBRequest> put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return put(context, value, 0, ec); } >@@ -94,14 +95,19 @@ public: > PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&); > PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&); > >+ void markDeleted() { m_deleted = true; } > void transactionFinished(); >+ void resetMetaData() { m_metaData = m_previousMetaData; } > > private: >- IDBObjectStore(PassRefPtr<IDBObjectStoreBackendInterface>, IDBTransaction*); >+ IDBObjectStore(const IDBObjectStoreMetaData&, PassRefPtr<IDBObjectStoreBackendInterface>, IDBTransaction*); > void removeTransactionFromPendingList(); > >+ IDBObjectStoreMetaData m_metaData; >+ IDBObjectStoreMetaData m_previousMetaData; > RefPtr<IDBObjectStoreBackendInterface> m_backend; > RefPtr<IDBTransaction> m_transaction; >+ bool m_deleted; > > typedef HashMap<String, RefPtr<IDBIndex> > IDBIndexMap; > IDBIndexMap m_indexMap; >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp >index ac4388701f9744491b7db1eb951b895881de2e77..ef720a4ba62e7b5fc1120852a0040ba7433fa343 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp >@@ -74,6 +74,14 @@ IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingSto > { > } > >+IDBObjectStoreMetaData IDBObjectStoreBackendImpl::metaData() const >+{ >+ IDBObjectStoreMetaData metaData(m_name, m_keyPath, m_autoIncrement); >+ for (IndexMap::const_iterator it = m_indexes.begin(); it != m_indexes.end(); ++it) >+ metaData.indexes.set(it->first, it->second->metaData()); >+ return metaData; >+} >+ > PassRefPtr<DOMStringList> IDBObjectStoreBackendImpl::indexNames() const > { > RefPtr<DOMStringList> indexNames = DOMStringList::create(); >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h >index a5de7e5d2d623dde0f00fcfd4e9a6eb3f088c639..482aa82763b2609c6579176653404334726fbce3 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h >@@ -27,6 +27,7 @@ > #define IDBObjectStoreBackendImpl_h > > #include "IDBKeyPath.h" >+#include "IDBMetaData.h" > #include "IDBObjectStoreBackendInterface.h" > #include <wtf/HashMap.h> > #include <wtf/text/StringHash.h> >@@ -40,6 +41,7 @@ class IDBDatabaseBackendImpl; > class IDBIndexBackendImpl; > class IDBTransactionBackendInterface; > class ScriptExecutionContext; >+struct IDBObjectStoreMetaData; > > class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface { > public: >@@ -61,6 +63,7 @@ public: > } > void setId(int64_t id) { m_id = id; } > >+ virtual IDBObjectStoreMetaData metaData() const; > virtual String name() const { return m_name; } > virtual IDBKeyPath keyPath() const { return m_keyPath; } > virtual PassRefPtr<DOMStringList> indexNames() const; >diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >index f5c744b15a772c75b0372eec4c20c923e2fda8c2..0ca828751e334be1823e4325ff2f76384aa71344 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >@@ -150,25 +150,37 @@ PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep > return it->second; > > RefPtr<IDBObjectStoreBackendInterface> objectStoreBackend = m_backend->objectStore(name, ec); >- if (!objectStoreBackend) { >- ASSERT(ec); >+ ASSERT(!objectStoreBackend != !ec); // If we didn't get a store, we should have gotten an exception code. And vice versa. >+ if (ec) > return 0; >- } >- RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(objectStoreBackend, this); >+ >+ const IDBDatabaseMetaData& metaData = m_database->metaData(); >+ IDBDatabaseMetaData::ObjectStoreMap::const_iterator mdit = metaData.objectStores.find(name); >+ ASSERT(mdit != metaData.objectStores.end()); >+ >+ RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(mdit->second, objectStoreBackend, this); > objectStoreCreated(name, objectStore); > return objectStore.release(); > } > >-void IDBTransaction::objectStoreCreated(const String& name, PassRefPtr<IDBObjectStore> objectStore) >+void IDBTransaction::objectStoreCreated(const String& name, PassRefPtr<IDBObjectStore> prpObjectStore) > { > ASSERT(!m_transactionFinished); >+ RefPtr<IDBObjectStore> objectStore = prpObjectStore; > m_objectStoreMap.set(name, objectStore); >+ m_objectStoreCleanupSet.add(objectStore); > } > > void IDBTransaction::objectStoreDeleted(const String& name) > { > ASSERT(!m_transactionFinished); >- m_objectStoreMap.remove(name); >+ IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); >+ if (it != m_objectStoreMap.end()) { >+ RefPtr<IDBObjectStore> objectStore = it->second; >+ m_objectStoreMap.remove(name); >+ objectStore->markDeleted(); >+ m_objectStoreCleanupSet.add(objectStore); >+ } > } > > void IDBTransaction::abort() >@@ -230,8 +242,11 @@ void IDBTransaction::onAbort() > request->abort(); > } > >- if (m_mode == IDBTransaction::VERSION_CHANGE) >+ if (m_mode == IDBTransaction::VERSION_CHANGE) { > m_database->clearVersionChangeTransaction(this); >+ for (IDBObjectStoreSet::iterator it = m_objectStoreCleanupSet.begin(); it != m_objectStoreCleanupSet.end(); ++it) >+ (*it)->resetMetaData(); >+ } > closeOpenCursors(); > > if (m_contextStopped || !scriptExecutionContext()) >diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.h b/Source/WebCore/Modules/indexeddb/IDBTransaction.h >index 1cebe9c193d927bc1596267eb73568b71fb59e72..ca643e56acc5edad5884046358debfe42cfaac23 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBTransaction.h >+++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.h >@@ -35,6 +35,7 @@ > #include "EventListener.h" > #include "EventNames.h" > #include "EventTarget.h" >+#include "IDBMetaData.h" > #include "IDBTransactionBackendInterface.h" > #include "IDBTransactionCallbacks.h" > #include <wtf/HashSet.h> >@@ -68,6 +69,7 @@ public: > > IDBTransactionBackendInterface* backend() const; > bool isFinished() const; >+ bool isVersionChange() const { return m_mode == VERSION_CHANGE; } > > const String& mode() const; > IDBDatabase* db() const; >@@ -140,6 +142,9 @@ private: > typedef HashMap<String, RefPtr<IDBObjectStore> > IDBObjectStoreMap; > IDBObjectStoreMap m_objectStoreMap; > >+ typedef HashSet<RefPtr<IDBObjectStore> > IDBObjectStoreSet; >+ IDBObjectStoreSet m_objectStoreCleanupSet; >+ > HashSet<IDBCursor*> m_openCursors; > > EventTargetData m_eventTargetData; >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 992702721e6b10ee5115bdcc5a435dc598a51b8f..da3c4f3c5656eeaf55160021e0b85453f10c6e3a 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -1484,6 +1484,7 @@ > 'Modules/indexeddb/IDBLevelDBCoding.h', > 'Modules/indexeddb/IDBLevelDBBackingStore.cpp', > 'Modules/indexeddb/IDBLevelDBBackingStore.h', >+ 'Modules/indexeddb/IDBMetaData.h', > 'Modules/indexeddb/IDBObjectStore.cpp', > 'Modules/indexeddb/IDBObjectStore.h', > 'Modules/indexeddb/IDBObjectStoreBackendImpl.cpp', >diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp >index 99204b886ab7ec1cf4d24a593ccdcd027d549901..52c6118bec11dd3fcbe7d633feecb58148d12f96 100644 >--- a/Source/WebKit/chromium/WebKit.gyp >+++ b/Source/WebKit/chromium/WebKit.gyp >@@ -181,6 +181,7 @@ > 'public/WebIDBKey.h', > 'public/WebIDBKeyPath.h', > 'public/WebIDBKeyRange.h', >+ 'public/WebIDBMetaData.h', > 'public/WebIDBObjectStore.h', > 'public/WebIDBTransaction.h', > 'public/WebIDBTransactionCallbacks.h', >@@ -558,6 +559,7 @@ > 'src/WebIDBKey.cpp', > 'src/WebIDBKeyPath.cpp', > 'src/WebIDBKeyRange.cpp', >+ 'src/WebIDBMetaData.cpp', > 'src/WebIDBObjectStoreImpl.cpp', > 'src/WebIDBObjectStoreImpl.h', > 'src/WebIDBTransactionImpl.cpp', >diff --git a/Source/WebKit/chromium/public/WebIDBDatabase.h b/Source/WebKit/chromium/public/WebIDBDatabase.h >index b398534165543a197a61797d54749da85e3a356e..696f16c47ce2cb4fc9e6849f0f43a80bf2dcd84a 100644 >--- a/Source/WebKit/chromium/public/WebIDBDatabase.h >+++ b/Source/WebKit/chromium/public/WebIDBDatabase.h >@@ -28,6 +28,7 @@ > > #include "WebDOMStringList.h" > #include "WebExceptionCode.h" >+#include "WebIDBMetaData.h" > #include "platform/WebCommon.h" > > namespace WebKit { >@@ -44,6 +45,11 @@ class WebIDBDatabase { > public: > virtual ~WebIDBDatabase() { } > >+ virtual WebIDBDatabaseMetaData metaData() const >+ { >+ WEBKIT_ASSERT_NOT_REACHED(); >+ return WebIDBDatabaseMetaData::create(); >+ } > virtual WebString name() const > { > WEBKIT_ASSERT_NOT_REACHED(); >diff --git a/Source/WebKit/chromium/public/WebIDBMetaData.h b/Source/WebKit/chromium/public/WebIDBMetaData.h >new file mode 100644 >index 0000000000000000000000000000000000000000..beee4b71582584b5825c2e7d5da35c3f9066f043 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebIDBMetaData.h >@@ -0,0 +1,114 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef WebIDBMetaData_h >+#define WebIDBMetaData_h >+ >+#include "platform/WebCommon.h" >+#include "platform/WebPrivateOwnPtr.h" >+#include "platform/WebString.h" >+#include "platform/WebVector.h" >+ >+namespace WebCore { >+struct IDBDatabaseMetaData; >+struct IDBIndexMetaData; >+struct IDBObjectStoreMetaData; >+} >+ >+namespace WebKit { >+ >+class WebIDBIndexMetaData; >+class WebIDBKeyPath; >+class WebIDBObjectStoreMetaData; >+ >+class WebIDBDatabaseMetaData { >+public: >+ WEBKIT_EXPORT static WebIDBDatabaseMetaData create(); >+ WEBKIT_EXPORT static WebIDBDatabaseMetaData create(const WebString& name, const WebString& version, const WebVector<WebIDBObjectStoreMetaData>& object_stores); >+ WEBKIT_EXPORT WebIDBDatabaseMetaData(const WebIDBDatabaseMetaData&); >+ >+ WEBKIT_EXPORT WebString name() const; >+ WEBKIT_EXPORT WebString version() const; >+ WEBKIT_EXPORT WebVector<WebIDBObjectStoreMetaData> objectStores() const; >+ >+#if WEBKIT_IMPLEMENTATION >+ WebIDBDatabaseMetaData(); >+ WebIDBDatabaseMetaData(const WebCore::IDBDatabaseMetaData&); >+ ~WebIDBDatabaseMetaData(); >+ WebIDBDatabaseMetaData& operator=(const WebCore::IDBDatabaseMetaData&); >+ operator const WebCore::IDBDatabaseMetaData&() const; >+#endif >+ >+private: >+ WebPrivateOwnPtr<WebCore::IDBDatabaseMetaData> m_private; >+}; >+ >+class WebIDBObjectStoreMetaData { >+public: >+ WEBKIT_EXPORT static WebIDBObjectStoreMetaData create(const WebString& name, const WebIDBKeyPath&, bool autoIncrement, const WebVector<WebIDBIndexMetaData>& indexes); >+ WEBKIT_EXPORT WebIDBObjectStoreMetaData(const WebIDBObjectStoreMetaData&); >+ >+ WEBKIT_EXPORT WebString name() const; >+ WEBKIT_EXPORT WebIDBKeyPath keyPath() const; >+ WEBKIT_EXPORT bool autoIncrement() const; >+ WEBKIT_EXPORT WebVector<WebIDBIndexMetaData> indexes() const; >+ >+#if WEBKIT_IMPLEMENTATION >+ WebIDBObjectStoreMetaData(); >+ WebIDBObjectStoreMetaData(const WebCore::IDBObjectStoreMetaData&); >+ ~WebIDBObjectStoreMetaData(); >+ WebIDBObjectStoreMetaData& operator=(const WebCore::IDBObjectStoreMetaData&); >+ operator const WebCore::IDBObjectStoreMetaData&() const; >+#endif >+ >+private: >+ WebPrivateOwnPtr<WebCore::IDBObjectStoreMetaData> m_private; >+}; >+ >+class WebIDBIndexMetaData { >+public: >+ WEBKIT_EXPORT static WebIDBIndexMetaData create(const WebString& name, const WebIDBKeyPath&, bool unique, bool multiEntry); >+ WEBKIT_EXPORT WebIDBIndexMetaData(const WebIDBIndexMetaData&); >+ >+ WEBKIT_EXPORT WebString name() const; >+ WEBKIT_EXPORT WebIDBKeyPath keyPath() const; >+ WEBKIT_EXPORT bool unique() const; >+ WEBKIT_EXPORT bool multiEntry() const; >+ >+#if WEBKIT_IMPLEMENTATION >+ WebIDBIndexMetaData(); >+ WebIDBIndexMetaData(const WebCore::IDBIndexMetaData&); >+ ~WebIDBIndexMetaData(); >+ WebIDBIndexMetaData& operator=(const WebCore::IDBIndexMetaData&); >+ operator const WebCore::IDBIndexMetaData&() const; >+#endif >+ >+private: >+ WebPrivateOwnPtr<WebCore::IDBIndexMetaData> m_private; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebIDBKeyPath_h >diff --git a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp >index 6e535499a38c4a93509a6e4f556cf98ac8f20073..b350e76d900158207477bbeb89d656354985ef87 100644 >--- a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp >+++ b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp >@@ -31,6 +31,7 @@ > #include "DOMStringList.h" > #include "IDBCallbacks.h" > #include "IDBDatabaseCallbacks.h" >+#include "IDBMetaData.h" > #include "IDBObjectStoreBackendProxy.h" > #include "IDBTransactionBackendProxy.h" > #include "WebDOMStringList.h" >@@ -60,6 +61,11 @@ IDBDatabaseBackendProxy::~IDBDatabaseBackendProxy() > { > } > >+IDBDatabaseMetaData IDBDatabaseBackendProxy::metaData() const >+{ >+ return m_webIDBDatabase->metaData(); >+} >+ > String IDBDatabaseBackendProxy::name() const > { > return m_webIDBDatabase->name(); >diff --git a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h >index b78ac6992cdcff1387a9ec08b3868eb6cfc43392..2c6089125690848de04aae198e4f8a6ad7f604ae 100644 >--- a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h >+++ b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h >@@ -42,6 +42,7 @@ public: > static PassRefPtr<WebCore::IDBDatabaseBackendInterface> create(PassOwnPtr<WebIDBDatabase>); > virtual ~IDBDatabaseBackendProxy(); > >+ virtual WebCore::IDBDatabaseMetaData metaData() const; > virtual String name() const; > virtual String version() const; > virtual PassRefPtr<WebCore::DOMStringList> objectStoreNames() const; >diff --git a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp >index 4be43dc14d817d959aef58a16aecf485bcb5b6ba..75a7a82f41faf509cb189c48eeffc3e9043718a1 100644 >--- a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp >+++ b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp >@@ -32,9 +32,11 @@ > #include "IDBCallbacksProxy.h" > #include "IDBDatabaseBackendInterface.h" > #include "IDBDatabaseCallbacksProxy.h" >+#include "IDBMetaData.h" > #include "IDBTransactionBackendInterface.h" > #include "WebIDBCallbacks.h" > #include "WebIDBDatabaseCallbacks.h" >+#include "WebIDBMetaData.h" > #include "WebIDBObjectStoreImpl.h" > #include "WebIDBTransactionImpl.h" > >@@ -51,6 +53,11 @@ WebIDBDatabaseImpl::~WebIDBDatabaseImpl() > { > } > >+WebIDBDatabaseMetaData WebIDBDatabaseImpl::metaData() const >+{ >+ return m_databaseBackend->metaData(); >+} >+ > WebString WebIDBDatabaseImpl::name() const > { > return m_databaseBackend->name(); >diff --git a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h >index 96571bbe9c1d96cbd3f9c7d3ad83179b96193dd9..b01ab092c6385a949a7fddec5a2a453161cefeff 100644 >--- a/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h >+++ b/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h >@@ -40,6 +40,7 @@ namespace WebKit { > > class IDBDatabaseCallbacksProxy; > class WebIDBDatabaseCallbacks; >+class WebIDBDatabaseMetaData; > class WebIDBObjectStore; > class WebIDBTransaction; > >@@ -49,6 +50,7 @@ public: > WebIDBDatabaseImpl(WTF::PassRefPtr<WebCore::IDBDatabaseBackendInterface>); > virtual ~WebIDBDatabaseImpl(); > >+ virtual WebIDBDatabaseMetaData metaData() const; > virtual WebString name() const; > virtual WebString version() const; > virtual WebDOMStringList objectStoreNames() const; >diff --git a/Source/WebKit/chromium/src/WebIDBMetaData.cpp b/Source/WebKit/chromium/src/WebIDBMetaData.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..0caa95dde42deec11b64810245193aa51198eefa >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebIDBMetaData.cpp >@@ -0,0 +1,227 @@ >+/* >+ * Copyright (C) 2012 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WebIDBMetaData.h" >+ >+#if ENABLE(INDEXED_DATABASE) >+ >+#include "IDBMetaData.h" >+#include "WebIDBKeyPath.h" >+#include "platform/WebString.h" >+#include "platform/WebVector.h" >+ >+using namespace WebCore; >+ >+namespace WebKit { >+ >+WebIDBDatabaseMetaData WebIDBDatabaseMetaData::create() >+{ >+ return WebIDBDatabaseMetaData(IDBDatabaseMetaData()); >+} >+ >+WebIDBDatabaseMetaData WebIDBDatabaseMetaData::create(const WebString& name, const WebString& version, const WebVector<WebIDBObjectStoreMetaData>& objectStores) >+{ >+ IDBDatabaseMetaData metaData(name, version); >+ for (size_t i = 0; i < objectStores.size(); ++i) >+ metaData.objectStores.set(objectStores[i].name(), objectStores[i]); >+ return WebIDBDatabaseMetaData(metaData); >+} >+ >+WebIDBDatabaseMetaData::WebIDBDatabaseMetaData() >+ : m_private(new IDBDatabaseMetaData()) >+{ >+} >+ >+WebIDBDatabaseMetaData::WebIDBDatabaseMetaData(const WebIDBDatabaseMetaData& other) >+ : m_private(new IDBDatabaseMetaData(other)) >+{ >+} >+ >+WebIDBDatabaseMetaData::~WebIDBDatabaseMetaData() >+{ >+ m_private.reset(0); >+} >+ >+WebString WebIDBDatabaseMetaData::name() const >+{ >+ return m_private->name; >+} >+ >+WebString WebIDBDatabaseMetaData::version() const >+{ >+ return m_private->version; >+} >+ >+WebVector<WebIDBObjectStoreMetaData> WebIDBDatabaseMetaData::objectStores() const >+{ >+ size_t count = static_cast<size_t>(m_private->objectStores.size()); >+ WebVector<WebIDBObjectStoreMetaData> objectStores(count); >+ size_t i = 0; >+ for (IDBDatabaseMetaData::ObjectStoreMap::const_iterator it = m_private->objectStores.begin(); it != m_private->objectStores.end(); ++it) >+ objectStores[i++] = it->second; >+ return objectStores; >+} >+ >+WebIDBDatabaseMetaData::WebIDBDatabaseMetaData(const WebCore::IDBDatabaseMetaData& metadata) >+ : m_private(new IDBDatabaseMetaData(metadata)) >+{ >+} >+ >+WebIDBDatabaseMetaData& WebIDBDatabaseMetaData::operator=(const WebCore::IDBDatabaseMetaData& metadata) >+{ >+ m_private.reset(new IDBDatabaseMetaData(metadata)); >+ return *this; >+} >+ >+WebIDBDatabaseMetaData::operator const WebCore::IDBDatabaseMetaData&() const >+{ >+ return *(m_private.get()); >+} >+ >+WebIDBObjectStoreMetaData WebIDBObjectStoreMetaData::create(const WebString& name, const WebIDBKeyPath& keyPath, bool autoIncrement, const WebVector<WebIDBIndexMetaData>& indexes) >+{ >+ IDBObjectStoreMetaData metaData(name, WebIDBKeyPath(keyPath), autoIncrement); >+ for (size_t i = 0; i < indexes.size(); ++i) >+ metaData.indexes.set(indexes[i].name(), indexes[i]); >+ return WebIDBObjectStoreMetaData(metaData); >+} >+ >+WebIDBObjectStoreMetaData::WebIDBObjectStoreMetaData() >+ : m_private(new IDBObjectStoreMetaData()) >+{ >+} >+ >+WebIDBObjectStoreMetaData::WebIDBObjectStoreMetaData(const WebIDBObjectStoreMetaData& other) >+ : m_private(new IDBObjectStoreMetaData(other)) >+{ >+} >+ >+WebIDBObjectStoreMetaData::~WebIDBObjectStoreMetaData() >+{ >+ m_private.reset(0); >+} >+ >+WebString WebIDBObjectStoreMetaData::name() const >+{ >+ return m_private->name; >+} >+ >+WebIDBKeyPath WebIDBObjectStoreMetaData::keyPath() const >+{ >+ return WebIDBKeyPath(m_private->keyPath); >+} >+ >+bool WebIDBObjectStoreMetaData::autoIncrement() const >+{ >+ return m_private->autoIncrement; >+} >+ >+WebVector<WebIDBIndexMetaData> WebIDBObjectStoreMetaData::indexes() const >+{ >+ size_t count = static_cast<size_t>(m_private->indexes.size()); >+ WebVector<WebIDBIndexMetaData> indexes(count); >+ size_t i = 0; >+ for (IDBObjectStoreMetaData::IndexMap::const_iterator it = m_private->indexes.begin(); it != m_private->indexes.end(); ++it) >+ indexes[i++] = it->second; >+ return indexes; >+} >+ >+WebIDBObjectStoreMetaData::WebIDBObjectStoreMetaData(const WebCore::IDBObjectStoreMetaData& metadata) >+ : m_private(new IDBObjectStoreMetaData(metadata)) >+{ >+} >+ >+WebIDBObjectStoreMetaData& WebIDBObjectStoreMetaData::operator=(const WebCore::IDBObjectStoreMetaData& metadata) >+{ >+ m_private.reset(new IDBObjectStoreMetaData(metadata)); >+ return *this; >+} >+ >+WebIDBObjectStoreMetaData::operator const WebCore::IDBObjectStoreMetaData&() const >+{ >+ return *(m_private.get()); >+} >+ >+WebIDBIndexMetaData WebIDBIndexMetaData::create(const WebString& name, const WebIDBKeyPath& keyPath, bool unique, bool multiEntry) >+{ >+ return IDBIndexMetaData(name, keyPath, unique, multiEntry); >+} >+ >+WebIDBIndexMetaData::WebIDBIndexMetaData() >+ : m_private(new IDBIndexMetaData()) >+{ >+} >+ >+WebIDBIndexMetaData::WebIDBIndexMetaData(const WebIDBIndexMetaData& other) >+ : m_private(new IDBIndexMetaData(other)) >+{ >+} >+ >+WebIDBIndexMetaData::~WebIDBIndexMetaData() >+{ >+ m_private.reset(0); >+} >+ >+WebString WebIDBIndexMetaData::name() const >+{ >+ return m_private->name; >+} >+ >+WebIDBKeyPath WebIDBIndexMetaData::keyPath() const >+{ >+ return WebIDBKeyPath(m_private->keyPath); >+} >+ >+bool WebIDBIndexMetaData::unique() const >+{ >+ return m_private->unique; >+} >+ >+bool WebIDBIndexMetaData::multiEntry() const >+{ >+ return m_private->multiEntry; >+} >+ >+ >+WebIDBIndexMetaData::WebIDBIndexMetaData(const WebCore::IDBIndexMetaData& metadata) >+ : m_private(new IDBIndexMetaData(metadata)) >+{ >+} >+ >+WebIDBIndexMetaData& WebIDBIndexMetaData::operator=(const WebCore::IDBIndexMetaData& metadata) >+{ >+ m_private.reset(new IDBIndexMetaData(metadata)); >+ return *this; >+} >+ >+WebIDBIndexMetaData::operator const WebCore::IDBIndexMetaData&() const >+{ >+ return *(m_private.get()); >+} >+ >+} // namespace WebKit >+ >+#endif // ENABLE(INDEXED_DATABASE) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 8f3674e9f7a88a7499d2e97fbe22417173b3c0ae..aa86c1c90fbadf9fd86187a35473751b3ab03ebc 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,49 @@ >+2012-06-07 Joshua Bell <jsbell@chromium.org> >+ >+ IndexedDB: Snapshot metadata in front end to avoid IPC round-trips >+ https://bugs.webkit.org/show_bug.cgi?id=88467 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * storage/indexeddb/deleted-objects-expected.txt: Added. >+ * storage/indexeddb/deleted-objects.html: Added. >+ * storage/indexeddb/metadata-expected.txt: Added. >+ * storage/indexeddb/metadata.html: Added. >+ * storage/indexeddb/mozilla/index-prev-no-duplicate-expected.txt: >+ * storage/indexeddb/mozilla/index-prev-no-duplicate.html: This test was >+ creating a transaction inside the setVersion callback and assuming the >+ setVersion's schema changes were already present. This will be prevented >+ by a future change (webkit.org/b/80547) but it trips up this change. >+ * storage/indexeddb/resources/deleted-objects.js: Added. >+ (test): >+ (openDatabase.request.onsuccess.request.onsuccess): >+ (openDatabase.request.onsuccess): >+ (openDatabase): >+ * storage/indexeddb/resources/metadata.js: Added. >+ (test): >+ (firstOpen.request.onsuccess.request.onsuccess.trans.oncomplete): >+ (firstOpen.request.onsuccess.request.onsuccess): >+ (firstOpen.request.onsuccess): >+ (firstOpen): >+ (secondOpen.request.onsuccess.request.onsuccess.trans.oncomplete): >+ (secondOpen.request.onsuccess.request.onsuccess): >+ (secondOpen.request.onsuccess): >+ (secondOpen): >+ (thirdOpen.request.onsuccess.request.onsuccess.trans.onabort): >+ (thirdOpen.request.onsuccess.request.onsuccess): >+ (thirdOpen.request.onsuccess): >+ (thirdOpen): >+ (fourthOpen.request.onsuccess.request.onsuccess.trans.oncomplete): >+ (fourthOpen.request.onsuccess.request.onsuccess): >+ (fourthOpen.request.onsuccess): >+ (fourthOpen): >+ (checkState): >+ * storage/indexeddb/resources/transaction-basics.js: Operations on >+ a deleted object store are now prevented per spec. >+ (addRemoveIDBObjects): >+ (addRemoveAddIDBObjects): >+ * storage/indexeddb/transaction-basics-expected.txt: >+ > 2012-06-07 Raymes Khoury <raymes@chromium.org> > > Incorrect rect-based hit-test result for culled-inline elements >diff --git a/LayoutTests/storage/indexeddb/deleted-objects-expected.txt b/LayoutTests/storage/indexeddb/deleted-objects-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..9f66afe3a08afb4917ad3364935832cc1e212593 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/deleted-objects-expected.txt >@@ -0,0 +1,87 @@ >+Test that IndexedDB objects that have been deleted throw exceptions >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB; >+ >+dbname = self.location.pathname >+request = indexedDB.deleteDatabase(dbname) >+ >+openDatabase(): >+request = indexedDB.open(dbname) >+connection = request.result >+request = connection.setVersion('1') >+ >+deletedStore = connection.createObjectStore('deletedStore') >+store = connection.createObjectStore('store') >+deletedIndex = store.createIndex('deletedIndex', 'path') >+ >+connection.deleteObjectStore('deletedStore') >+store.deleteIndex('deletedIndex') >+ >+Expecting exception from deletedStore.put(0, 0) >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.add(0, 0) >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.delete(0) >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.get(0) >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.clear() >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.openCursor() >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.createIndex('name', 'path') >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.index('name') >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.deleteIndex('name') >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedStore.count() >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+ >+Expecting exception from deletedIndex.openCursor() >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedIndex.openKeyCursor() >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedIndex.get(0) >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedIndex.getKey(0) >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+Expecting exception from deletedIndex.count() >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/storage/indexeddb/deleted-objects.html b/LayoutTests/storage/indexeddb/deleted-objects.html >new file mode 100644 >index 0000000000000000000000000000000000000000..393f52f509c540c4b70cbb48a219b3fa8d1a71e8 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/deleted-objects.html >@@ -0,0 +1,10 @@ >+<html> >+<head> >+<script src="../../fast/js/resources/js-test-pre.js"></script> >+<script src="resources/shared.js"></script> >+</head> >+<body> >+<script src="resources/deleted-objects.js"></script> >+<script src="../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/storage/indexeddb/metadata-expected.txt b/LayoutTests/storage/indexeddb/metadata-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..8436d475aa427bacfaff1347a3641f85f978d278 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/metadata-expected.txt >@@ -0,0 +1,88 @@ >+Test IndexedDB database metadata mutation/snapshotting >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB; >+ >+dbname = self.location.pathname >+request = indexedDB.deleteDatabase(dbname) >+ >+firstOpen(): >+request = indexedDB.open(dbname) >+connection1 = request.result >+request = connection1.setVersion('1') >+trans = request.result >+connection1store1 = connection1.createObjectStore('store1') >+connection1store1.createIndex('index1', 'path') >+PASS connection1.version is "1" >+PASS connection1.objectStoreNames.length is 1 >+PASS connection1store1.indexNames.length is 1 >+Connection's properties should be snapshotted on close >+connection1.close() >+ >+secondOpen(): >+request = indexedDB.open(dbname) >+connection2 = request.result >+request = connection2.setVersion('2') >+trans = request.result >+connection2.createObjectStore('store2') >+connection2store1 = trans.objectStore('store1') >+connection2store1.createIndex('index2', 'path') >+PASS connection2.version is "2" >+PASS connection2.objectStoreNames.length is 2 >+PASS connection2store1.indexNames.length is 2 >+Connection's properties should be snapshotted on close >+connection2.close() >+ >+thirdOpen(): >+request = indexedDB.open(dbname) >+connection3 = request.result >+request = connection3.setVersion('3') >+trans = request.result >+connection3.createObjectStore('store3') >+connection3store1 = trans.objectStore('store1') >+connection3store1.createIndex('index3', 'path') >+PASS connection3.version is "3" >+PASS connection3.objectStoreNames.length is 3 >+PASS connection3store1.indexNames.length is 3 >+Connection's properties should be reverted on abort >+trans.abort() >+Connection's properties should be snapshotted on close >+connection3.close() >+ >+fourthOpen(): >+request = indexedDB.open(dbname) >+connection4 = request.result >+request = connection4.setVersion('4') >+trans = request.result >+connection4.createObjectStore('store4') >+connection4store1 = trans.objectStore('store1') >+connection4store1.createIndex('index4', 'path') >+PASS connection4.version is "4" >+PASS connection4.objectStoreNames.length is 3 >+PASS connection4store1.indexNames.length is 3 >+Connection's properties should be snapshotted on close >+connection4.close() >+ >+checkState(): >+PASS connection1.version is "1" >+PASS connection1.objectStoreNames.length is 1 >+PASS connection1store1.indexNames.length is 1 >+ >+PASS connection2.version is "2" >+PASS connection2.objectStoreNames.length is 2 >+PASS connection2store1.indexNames.length is 2 >+ >+PASS connection3.version is "2" >+PASS connection3.objectStoreNames.length is 2 >+PASS connection3store1.indexNames.length is 2 >+ >+PASS connection4.version is "4" >+PASS connection4.objectStoreNames.length is 3 >+PASS connection4store1.indexNames.length is 3 >+ >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/storage/indexeddb/metadata.html b/LayoutTests/storage/indexeddb/metadata.html >new file mode 100644 >index 0000000000000000000000000000000000000000..542cfe59ec45ec074e83eb38bf58bf2b1b852e3f >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/metadata.html >@@ -0,0 +1,10 @@ >+<html> >+<head> >+<script src="../../fast/js/resources/js-test-pre.js"></script> >+<script src="resources/shared.js"></script> >+</head> >+<body> >+<script src="resources/metadata.js"></script> >+<script src="../../fast/js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate-expected.txt b/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate-expected.txt >index b7805f1faa45a7a9d8dde2966b7aec7f3bec8317..4a0b822ec77b0075a56823e48b4252efbf4ac899 100644 >--- a/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate-expected.txt >+++ b/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate-expected.txt >@@ -16,7 +16,7 @@ PASS IDBKeyRange == null is false > indexedDB.open(name, description) > openSuccess(): > db = event.target.result >-request = db.setVersion('1') >+setVersionRequest = db.setVersion('1') > Deleted all object stores. > objectStore = db.createObjectStore(objectStoreName); > First, add all our data to the object store. >diff --git a/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate.html b/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate.html >index 8a96387bdea869f22d013b3abe6aff221d16ecaf..be9beb73e74f03ac7354596b4f9b52a9c92f2a9f 100644 >--- a/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate.html >+++ b/LayoutTests/storage/indexeddb/mozilla/index-prev-no-duplicate.html >@@ -77,9 +77,9 @@ function openSuccess() > { key: "237-23-7740", value: { name: "Sam", height: 73, weight: 110 } }, > ]; > >- request = evalAndLog("request = db.setVersion('1')"); >- request.onsuccess = createAndPopulateObjectStore; >- request.onerror = unexpectedErrorCallback; >+ setVersionRequest = evalAndLog("setVersionRequest = db.setVersion('1')"); >+ setVersionRequest.onsuccess = createAndPopulateObjectStore; >+ setVersionRequest.onerror = unexpectedErrorCallback; > } > > function createAndPopulateObjectStore() >@@ -109,8 +109,7 @@ function createIndexes() > evalAndLog("objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);"); > } > >- >- testPrev(); >+ setVersionRequest.result.oncomplete = testPrev; > } > > function testPrev() >diff --git a/LayoutTests/storage/indexeddb/resources/deleted-objects.js b/LayoutTests/storage/indexeddb/resources/deleted-objects.js >new file mode 100644 >index 0000000000000000000000000000000000000000..797a05abfcc41b72dbedda5a1235a2cced095025 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/resources/deleted-objects.js >@@ -0,0 +1,64 @@ >+if (this.importScripts) { >+ importScripts('../../../fast/js/resources/js-test-pre.js'); >+ importScripts('shared.js'); >+} >+ >+description("Test that IndexedDB objects that have been deleted throw exceptions"); >+ >+function test() >+{ >+ removeVendorPrefixes(); >+ evalAndLog("dbname = self.location.pathname"); >+ evalAndLog("request = indexedDB.deleteDatabase(dbname)"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = openDatabase; >+} >+ >+function openDatabase() >+{ >+ debug(""); >+ debug("openDatabase():"); >+ evalAndLog("request = indexedDB.open(dbname)"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("connection = request.result"); >+ evalAndLog("request = connection.setVersion('1')"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ trans = request.result; >+ >+ debug(""); >+ evalAndLog("deletedStore = connection.createObjectStore('deletedStore')"); >+ evalAndLog("store = connection.createObjectStore('store')"); >+ evalAndLog("deletedIndex = store.createIndex('deletedIndex', 'path')"); >+ >+ debug(""); >+ evalAndLog("connection.deleteObjectStore('deletedStore')"); >+ evalAndLog("store.deleteIndex('deletedIndex')"); >+ >+ debug(""); >+ evalAndExpectException("deletedStore.put(0, 0)", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.add(0, 0)", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.delete(0)", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.get(0)", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.clear()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.openCursor()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.createIndex('name', 'path')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.index('name')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.deleteIndex('name')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedStore.count()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ >+ debug(""); >+ evalAndExpectException("deletedIndex.openCursor()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedIndex.openKeyCursor()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedIndex.get(0)", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedIndex.getKey(0)", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ evalAndExpectException("deletedIndex.count()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); >+ >+ trans.onabort = unexpectedAbortCallback; >+ trans.oncomplete = finishJSTest; >+ }; >+ }; >+} >+ >+test(); >diff --git a/LayoutTests/storage/indexeddb/resources/metadata.js b/LayoutTests/storage/indexeddb/resources/metadata.js >new file mode 100644 >index 0000000000000000000000000000000000000000..14c47c711eefb5826876a1c2ec3eecf0007eec44 >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/resources/metadata.js >@@ -0,0 +1,166 @@ >+if (this.importScripts) { >+ importScripts('../../../fast/js/resources/js-test-pre.js'); >+ importScripts('shared.js'); >+} >+ >+description("Test IndexedDB database metadata mutation/snapshotting"); >+ >+function test() >+{ >+ removeVendorPrefixes(); >+ evalAndLog("dbname = self.location.pathname"); >+ evalAndLog("request = indexedDB.deleteDatabase(dbname)"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = firstOpen; >+} >+ >+function firstOpen() >+{ >+ debug(""); >+ debug("firstOpen():"); >+ evalAndLog("request = indexedDB.open(dbname)"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("connection1 = request.result"); >+ evalAndLog("request = connection1.setVersion('1')"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("trans = request.result"); >+ evalAndLog("connection1store1 = connection1.createObjectStore('store1')"); >+ evalAndLog("connection1store1.createIndex('index1', 'path')"); >+ >+ shouldBeEqualToString("connection1.version", "1"); >+ shouldBe("connection1.objectStoreNames.length", "1"); >+ shouldBe("connection1store1.indexNames.length", "1"); >+ >+ trans.onabort = unexpectedAbortCallback; >+ trans.oncomplete = function() { >+ debug("Connection's properties should be snapshotted on close"); >+ evalAndLog("connection1.close()"); >+ secondOpen(); >+ }; >+ }; >+ }; >+} >+ >+function secondOpen() >+{ >+ debug(""); >+ debug("secondOpen():"); >+ evalAndLog("request = indexedDB.open(dbname)"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("connection2 = request.result"); >+ evalAndLog("request = connection2.setVersion('2')"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("trans = request.result"); >+ evalAndLog("connection2.createObjectStore('store2')"); >+ evalAndLog("connection2store1 = trans.objectStore('store1')"); >+ evalAndLog("connection2store1.createIndex('index2', 'path')"); >+ >+ shouldBeEqualToString("connection2.version", "2"); >+ shouldBe("connection2.objectStoreNames.length", "2"); >+ shouldBe("connection2store1.indexNames.length", "2"); >+ >+ trans.onabort = unexpectedAbortCallback; >+ trans.oncomplete = function() { >+ debug("Connection's properties should be snapshotted on close"); >+ evalAndLog("connection2.close()"); >+ thirdOpen(); >+ }; >+ }; >+ }; >+} >+ >+function thirdOpen() >+{ >+ debug(""); >+ debug("thirdOpen():"); >+ evalAndLog("request = indexedDB.open(dbname)"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("connection3 = request.result"); >+ evalAndLog("request = connection3.setVersion('3')"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("trans = request.result"); >+ evalAndLog("connection3.createObjectStore('store3')"); >+ evalAndLog("connection3store1 = trans.objectStore('store1')"); >+ evalAndLog("connection3store1.createIndex('index3', 'path')"); >+ >+ shouldBeEqualToString("connection3.version", "3"); >+ shouldBe("connection3.objectStoreNames.length", "3"); >+ shouldBe("connection3store1.indexNames.length", "3"); >+ >+ trans.oncomplete = unexpectedCompleteCallback; >+ trans.onabort = function() { >+ debug("Connection's properties should be snapshotted on close"); >+ evalAndLog("connection3.close()"); >+ fourthOpen(); >+ }; >+ debug("Connection's properties should be reverted on abort"); >+ evalAndLog("trans.abort()"); >+ }; >+ }; >+} >+ >+function fourthOpen() >+{ >+ debug(""); >+ debug("fourthOpen():"); >+ evalAndLog("request = indexedDB.open(dbname)"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("connection4 = request.result"); >+ evalAndLog("request = connection4.setVersion('4')"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function() { >+ evalAndLog("trans = request.result"); >+ evalAndLog("connection4.createObjectStore('store4')"); >+ evalAndLog("connection4store1 = trans.objectStore('store1')"); >+ evalAndLog("connection4store1.createIndex('index4', 'path')"); >+ >+ shouldBeEqualToString("connection4.version", "4"); >+ shouldBe("connection4.objectStoreNames.length", "3"); >+ shouldBe("connection4store1.indexNames.length", "3"); >+ >+ trans.onabort = unexpectedAbortCallback; >+ trans.oncomplete = function() { >+ debug("Connection's properties should be snapshotted on close"); >+ evalAndLog("connection4.close()"); >+ checkState(); >+ }; >+ }; >+ }; >+} >+ >+function checkState() >+{ >+ debug(""); >+ debug("checkState():"); >+ >+ shouldBeEqualToString("connection1.version", "1"); >+ shouldBe("connection1.objectStoreNames.length", "1"); >+ shouldBe("connection1store1.indexNames.length", "1"); >+ debug(""); >+ >+ shouldBeEqualToString("connection2.version", "2"); >+ shouldBe("connection2.objectStoreNames.length", "2"); >+ shouldBe("connection2store1.indexNames.length", "2"); >+ debug(""); >+ >+ shouldBeEqualToString("connection3.version", "2"); >+ shouldBe("connection3.objectStoreNames.length", "2"); >+ shouldBe("connection3store1.indexNames.length", "2"); >+ debug(""); >+ >+ shouldBeEqualToString("connection4.version", "4"); >+ shouldBe("connection4.objectStoreNames.length", "3"); >+ shouldBe("connection4store1.indexNames.length", "3"); >+ debug(""); >+ >+ finishJSTest(); >+} >+ >+test(); >diff --git a/LayoutTests/storage/indexeddb/resources/transaction-basics.js b/LayoutTests/storage/indexeddb/resources/transaction-basics.js >index 8fa70162b81b9f1e7a26a1145a4084ad7d0484fd..3b3b754c9eb19fe48ee0a2999c59bcf01ce7155f 100644 >--- a/LayoutTests/storage/indexeddb/resources/transaction-basics.js >+++ b/LayoutTests/storage/indexeddb/resources/transaction-basics.js >@@ -48,7 +48,7 @@ function addRemoveIDBObjects() > var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); > > evalAndLog("db.deleteObjectStore('storeFail')"); >- evalAndLog("store.deleteIndex('indexFail')"); >+ evalAndExpectException("store.deleteIndex('indexFail')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); > > trans.abort(); > } >@@ -74,7 +74,7 @@ function addRemoveAddIDBObjects() > var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); > > evalAndLog("db.deleteObjectStore('storeFail')"); >- evalAndLog("store.deleteIndex('indexFail')"); >+ evalAndExpectException("store.deleteIndex('indexFail')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'"); > > var store = evalAndLog("store = db.createObjectStore('storeFail', null)"); > var index = evalAndLog("index = store.createIndex('indexFail', 'x')"); >diff --git a/LayoutTests/storage/indexeddb/transaction-basics-expected.txt b/LayoutTests/storage/indexeddb/transaction-basics-expected.txt >index 5fc251555e7cf90f55d2edcb55fd65402d32ccbe..59206d9ab2805e3736d68b12ff4639cbaf821fcd 100644 >--- a/LayoutTests/storage/indexeddb/transaction-basics-expected.txt >+++ b/LayoutTests/storage/indexeddb/transaction-basics-expected.txt >@@ -20,7 +20,10 @@ PASS trans is non-null. > store = db.createObjectStore('storeFail', null) > index = store.createIndex('indexFail', 'x') > db.deleteObjectStore('storeFail') >-store.deleteIndex('indexFail') >+Expecting exception from store.deleteIndex('indexFail') >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' > > testSetVersionAbort2(): > PASS self.db.objectStoreNames is [] >@@ -33,7 +36,10 @@ PASS trans is non-null. > store = db.createObjectStore('storeFail', null) > index = store.createIndex('indexFail', 'x') > db.deleteObjectStore('storeFail') >-store.deleteIndex('indexFail') >+Expecting exception from store.deleteIndex('indexFail') >+PASS Exception was thrown. >+PASS code is DOMException.INVALID_STATE_ERR >+PASS ename is 'InvalidStateError' > store = db.createObjectStore('storeFail', null) > index = store.createIndex('indexFail', 'x') >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 88467
:
146139
|
146368
|
146420
|
146616
|
147127
|
147359
|
147921
|
148463
|
148681
|
148690
|
148838
|
149096