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-20120621105307.patch (text/plain), 57.68 KB, created by
Joshua Bell
on 2012-06-21 10:53:08 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Joshua Bell
Created:
2012-06-21 10:53:08 PDT
Size:
57.68 KB
patch
obsolete
>Subversion Revision: 120906 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9bd33ccc095b39c139349452f68b33004b934c66..95b6cac49c88ce2b0bb56e5e10aec33ec08cb6ff 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,97 @@ >+2012-06-19 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!). >+ >+ Define a new type (IDBDatabaseMetadata) that captures the "schema" of an >+ IDB database (name, version, properties of stores, properties of indexes). >+ Add a method for the front end to request this from the back end once up >+ front to avoid later calls (which may be slow IPC calls in ports). Implement >+ IDB spec logic that the metadata should be frozen for a particular IDBDatabase >+ connection, and only change within a version change transaction, and the spec's >+ funky requirement for aborted version change transactions. >+ >+ Test: storage/indexeddb/metadata.html >+ >+ * Modules/indexeddb/IDBDatabase.cpp: >+ (WebCore::IDBDatabase::IDBDatabase): Fetch metadata from back end when connection is created. >+ (WebCore::IDBDatabase::transactionCreated): >+ (WebCore::IDBDatabase::transactionFinished): Update metadata at the end of a transaction in >+ case it was rolled back. >+ (WebCore::IDBDatabase::objectStoreNames): Move implementation to front-end. >+ (WebCore): >+ (WebCore::IDBDatabase::createObjectStore): Update local copy of metadata. >+ (WebCore::IDBDatabase::deleteObjectStore): Update local copy of metadata. >+ * Modules/indexeddb/IDBDatabase.h: >+ (WebCore::IDBDatabase::name): Move implementation to front-end. >+ (WebCore::IDBDatabase::version): Move implementation to front-end. >+ (IDBDatabase): >+ (WebCore::IDBDatabase::metadata): >+ * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: >+ (WebCore::IDBDatabaseBackendImpl::metadata): Construct a metadata snapshot. >+ (WebCore): >+ * Modules/indexeddb/IDBDatabaseBackendImpl.h: >+ (IDBDatabaseBackendImpl): >+ * Modules/indexeddb/IDBDatabaseBackendInterface.h: >+ (WebCore): >+ (IDBDatabaseBackendInterface): >+ * Modules/indexeddb/IDBIndex.cpp: Store a copy of the metadata, which will never >+ change during the lifetime of the index. >+ (WebCore::IDBIndex::IDBIndex): >+ * Modules/indexeddb/IDBIndex.h: >+ (WebCore::IDBIndex::create): >+ (WebCore::IDBIndex::name): Move implementation to front-end. >+ (WebCore::IDBIndex::objectStore): Return RefPtr (unrelated tidying). >+ (WebCore::IDBIndex::keyPath): Move implementation to front-end. >+ (WebCore::IDBIndex::unique): Move implementation to front-end. >+ (WebCore::IDBIndex::multiEntry): Move implementation to front-end. >+ (IDBIndex): >+ * Modules/indexeddb/IDBIndexBackendImpl.cpp: >+ (WebCore::IDBIndexBackendImpl::metadata): Construct a metadata snapshot. >+ (WebCore): >+ * Modules/indexeddb/IDBIndexBackendImpl.h: >+ (IDBIndexBackendImpl): >+ * Modules/indexeddb/IDBMetadata.h: Added new structs. >+ (WebCore): >+ (WebCore::IDBDatabaseMetadata::IDBDatabaseMetadata): >+ (IDBDatabaseMetadata): >+ (WebCore::IDBObjectStoreMetadata::IDBObjectStoreMetadata): >+ (IDBObjectStoreMetadata): >+ (WebCore::IDBIndexMetadata::IDBIndexMetadata): >+ (IDBIndexMetadata): >+ * Modules/indexeddb/IDBObjectStore.cpp: >+ (WebCore::IDBObjectStore::IDBObjectStore): Store a "live" copy of the metadata, and >+ and copy in case of an aborted version change transaction. >+ (WebCore::IDBObjectStore::indexNames): Move implementation to front-end. >+ (WebCore::IDBObjectStore::createIndex): Update metadata to include new index. >+ (WebCore::IDBObjectStore::index): Pass along metadata to instance constructor. >+ (WebCore::IDBObjectStore::deleteIndex): Delete index from metadata. >+ * Modules/indexeddb/IDBObjectStore.h: >+ (WebCore::IDBObjectStore::create): >+ (WebCore::IDBObjectStore::name): Move implementation to front-end. >+ (WebCore::IDBObjectStore::keyPath): Move implementation to front-end. >+ (WebCore::IDBObjectStore::transaction): Return RefPtr (unrelated tidying). >+ (WebCore::IDBObjectStore::autoIncrement): Move implementation to front-end. >+ (WebCore::IDBObjectStore::metadata): Allow copying the metadata, in case of abort. >+ (WebCore::IDBObjectStore::resetMetadata): Allow setting the metadata, in case of abort. >+ (IDBObjectStore): >+ * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: >+ (WebCore::IDBObjectStoreBackendImpl::metadata): Construct a metadata snapshot. >+ (WebCore): >+ * Modules/indexeddb/IDBObjectStoreBackendImpl.h: >+ (WebCore): >+ (IDBObjectStoreBackendImpl): >+ * Modules/indexeddb/IDBTransaction.cpp: >+ (WebCore::IDBTransaction::objectStore): Pass along metadata to instance constructor. >+ (WebCore::IDBTransaction::objectStoreCreated): Track stores changed during transaction. >+ (WebCore::IDBTransaction::objectStoreDeleted):Track stores changed during transaction. >+ (WebCore::IDBTransaction::onAbort): Revert stores metadata potentially changed during transaction. >+ * Modules/indexeddb/IDBTransaction.h: >+ (IDBTransaction): >+ * WebCore.gypi: >+ > 2012-06-21 Taiju Tsuiki <tzik@chromium.org> > > Web Inspector: Move requestId allocation from FileSystem frontend to backend >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index f7556accc01f68acd8e55fd4ff88dabcd655cfb1..40284aad8545cf5e01e8f36c0084a5848f05694b 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,33 @@ >+2012-06-19 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!). >+ >+ Add conversions to/from WebCore IDB metadata type and plumbing for routing the >+ IDBDatabaseBackendInterface::metadata() call through the public API.. >+ >+ * WebKit.gyp: New file added. >+ * public/WebIDBMetadata.h: Conversion functions. >+ (WebCore): >+ (WebIDBMetadata): >+ * src/IDBDatabaseBackendProxy.cpp: Plumbing. >+ (WebKit::IDBDatabaseBackendProxy::metadata): >+ (WebKit): >+ * src/IDBDatabaseBackendProxy.h: Plumbing. >+ (IDBDatabaseBackendProxy): >+ * src/WebIDBDatabaseImpl.cpp: Plumbing. >+ (WebKit::WebIDBDatabaseImpl::metadata): >+ (WebKit): >+ * src/WebIDBDatabaseImpl.h: Plumbing. >+ (WebKit): >+ (WebIDBDatabaseImpl): >+ * src/WebIDBMetadata.cpp: Added - conversion functions. >+ (WebKit): >+ (WebKit::WebIDBMetadata::WebIDBMetadata): >+ (WebKit::WebIDBMetadata::operator IDBDatabaseMetadata): >+ > 2012-06-20 Zeev Lieber <zlieber@chromium.org> > > [Chromium] Damage tracker is not used without partial swap, causing valid render passes to be removed >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >index 2008ed8b4fcbcbb573364da97ea80d09bddb183a..0a49400bb8655eae904fce69d9ed7b4086bb7fca 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >@@ -64,6 +64,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() >@@ -81,6 +82,7 @@ void IDBDatabase::transactionCreated(IDBTransaction* transaction) > if (transaction->isVersionChange()) { > ASSERT(!m_versionChangeTransaction); > m_versionChangeTransaction = transaction; >+ m_metadata = m_backend->metadata(); > } > } > >@@ -93,12 +95,22 @@ void IDBDatabase::transactionFinished(IDBTransaction* transaction) > if (transaction->isVersionChange()) { > ASSERT(m_versionChangeTransaction == transaction); > m_versionChangeTransaction = 0; >+ m_metadata = m_backend->metadata(); > } > > if (m_closePending && m_transactions.isEmpty()) > closeConnection(); > } > >+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) > { > if (!m_versionChangeTransaction) { >@@ -136,7 +148,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(); > } >@@ -149,8 +164,10 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionCode& ec) > } > > m_backend->deleteObjectStore(name, m_versionChangeTransaction->backend(), ec); >- if (!ec) >+ 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 adad32d86ac64785f0ddb61907feaccc9c0d9146..a248cd80deb837a3b15bdaa38d1df130ed3a31aa 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 transactionFinished(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(); } >+ const String name() const { return m_metadata.name; } >+ const 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 registerFrontendCallbacks(); >+ 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>); >@@ -105,6 +107,7 @@ private: > > void closeConnection(); > >+ IDBDatabaseMetadata m_metadata; > RefPtr<IDBDatabaseBackendInterface> m_backend; > RefPtr<IDBTransaction> m_versionChangeTransaction; > HashSet<IDBTransaction*> m_transactions; >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp >index 78e0ee08a27df8791eb27ce8f6095317ade5f5bb..b636d80a69fb565ba0625d81628bf24e14655604 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 15571a8c480331237620d6aaf4762d5470e837e3..36eb241febb8773892ea9893c5ae536fd8692bdb 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 424807474b8ccf0ba98746f90ff6700d4667b439..d581777f95173b3d5de15cbc11c30c0f14460ef1 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 34df18944420e9b603f4b2389e85db2aea2498ca..31e7f5d4e762fccdbda431679499dabaaabad0f4 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBIndex.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBIndex.cpp >@@ -42,8 +42,9 @@ 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) >diff --git a/Source/WebCore/Modules/indexeddb/IDBIndex.h b/Source/WebCore/Modules/indexeddb/IDBIndex.h >index c7e5f78cfb5761676f60609ce3696e49084a8fc2..8201d5d333db91d5f300820944c07f6b88b98d8e 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(); } >+ const 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); } >@@ -83,8 +85,9 @@ public: > 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; >diff --git a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp >index 98614dfb350d42b268bc42e8b6382d384027d1ff..a087e6aaf2f524235f8507a6ef48e5b2ec7d9ee7 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" > >@@ -67,6 +68,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 d8b197d17e401be0b8a3d357d0ddd073f02fed26..6410cbac3fc6490a9e45fd87bbd0c916133e1fc7 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h >+++ b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h >@@ -32,6 +32,7 @@ > #include "IDBDatabaseBackendImpl.h" > #include "IDBIndexBackendInterface.h" > #include "IDBKeyPath.h" >+#include "IDBMetadata.h" > > namespace WebCore { > >@@ -63,6 +64,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..7cbef73bce5d031f1ab47ed31ba8a23bd81668f6 >--- /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 b5d7814cc210e66d4dd8d288571bd018a3c0238f..5cfda05e5be57f5e485b95dfe3b22c23d5246e63 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,8 +45,9 @@ 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_backend(idbObjectStore) > , m_transaction(transaction) > , m_deleted(false) > { >@@ -55,34 +57,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) >@@ -279,8 +261,10 @@ PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const IDBKe > 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(); > } >@@ -306,7 +290,10 @@ PassRefPtr<IDBIndex> IDBObjectStore::index(const String& name, ExceptionCode& ec > if (ec) > return 0; > >- RefPtr<IDBIndex> index = IDBIndex::create(indexBackend.release(), this, m_transaction.get()); >+ IDBObjectStoreMetadata::IndexMap::const_iterator mdit = m_metadata.indexes.find(name); >+ ASSERT(mdit != m_metadata.indexes.end()); >+ >+ RefPtr<IDBIndex> index = IDBIndex::create(mdit->second, indexBackend.release(), this, m_transaction.get()); > m_indexMap.set(name, index); > return index.release(); > } >@@ -325,6 +312,9 @@ void IDBObjectStore::deleteIndex(const String& name, ExceptionCode& ec) > it->second->markDeleted(); > m_indexMap.remove(name); > } >+ >+ ASSERT(m_metadata.indexes.contains(name)); >+ m_metadata.indexes.remove(name); > } > } > >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.h b/Source/WebCore/Modules/indexeddb/IDBObjectStore.h >index 834bd50fc0531dca7edd75a0ac2e68b4a2f8213b..8181eb931fa70cc590042f22562cf78dc2ccf4c1 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; >+ 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); } >@@ -97,10 +98,14 @@ public: > void markDeleted() { m_deleted = true; } > void transactionFinished(); > >+ IDBObjectStoreMetadata metadata() const { return m_metadata; } >+ void setMetadata(const IDBObjectStoreMetadata& metadata) { m_metadata = metadata; } >+ > private: >- IDBObjectStore(PassRefPtr<IDBObjectStoreBackendInterface>, IDBTransaction*); >+ IDBObjectStore(const IDBObjectStoreMetadata&, PassRefPtr<IDBObjectStoreBackendInterface>, IDBTransaction*); > void removeTransactionFromPendingList(); > >+ IDBObjectStoreMetadata m_metadata; > RefPtr<IDBObjectStoreBackendInterface> m_backend; > RefPtr<IDBTransaction> m_transaction; > bool m_deleted; >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp >index d9af2b9733ff8316e578a591680494c802c9d371..9c7366e4b9b5e77e535465df5beb9f7cd5774f83 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp >@@ -72,6 +72,14 @@ IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(const IDBDatabaseBackendImp > { > } > >+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 bacd9dfc12c3e32cb8b2478552d53f01182c208d..07ab9fce3dd84fb80b75084fca32b4ac0677e2a5 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h >@@ -28,6 +28,7 @@ > > #include "IDBDatabaseBackendImpl.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 641e576416d6716f2df2be9f128256c0595726bf..7087c657e06686c17d15b36d88c69249d23e9b59 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >@@ -158,25 +158,34 @@ PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep > 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); >+ if (isVersionChange()) >+ m_objectStoreCleanupMap.set(objectStore, objectStore->metadata()); > } > > void IDBTransaction::objectStoreDeleted(const String& name) > { > ASSERT(!m_transactionFinished); >+ ASSERT(isVersionChange()); > IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); > if (it != m_objectStoreMap.end()) { > RefPtr<IDBObjectStore> objectStore = it->second; > m_objectStoreMap.remove(name); > objectStore->markDeleted(); >+ m_objectStoreCleanupMap.set(objectStore, objectStore->metadata()); > } > } > >@@ -239,6 +248,11 @@ void IDBTransaction::onAbort() > request->abort(); > } > >+ if (isVersionChange()) { >+ for (IDBObjectStoreMetadataMap::iterator it = m_objectStoreCleanupMap.begin(); it != m_objectStoreCleanupMap.end(); ++it) >+ it->first->setMetadata(it->second); >+ } >+ m_objectStoreCleanupMap.clear(); > closeOpenCursors(); > m_database->transactionFinished(this); > >@@ -251,6 +265,7 @@ void IDBTransaction::onAbort() > void IDBTransaction::onComplete() > { > ASSERT(!m_transactionFinished); >+ m_objectStoreCleanupMap.clear(); > closeOpenCursors(); > m_database->transactionFinished(this); > >diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.h b/Source/WebCore/Modules/indexeddb/IDBTransaction.h >index 4f95f5b19d09498b8c03ac62e816e978388232d2..0b2dec6ec08f1d1e2b960edb0116fcf89d1cf96d 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> >@@ -143,6 +144,9 @@ private: > typedef HashMap<String, RefPtr<IDBObjectStore> > IDBObjectStoreMap; > IDBObjectStoreMap m_objectStoreMap; > >+ typedef HashMap<RefPtr<IDBObjectStore>, IDBObjectStoreMetadata> IDBObjectStoreMetadataMap; >+ IDBObjectStoreMetadataMap m_objectStoreCleanupMap; >+ > HashSet<IDBCursor*> m_openCursors; > > EventTargetData m_eventTargetData; >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index b4f141a1cb26567bfe84911e84e2ccc83babedea..7a474c409c1fe3b4671e5a25899ae26188bb42be 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -1491,6 +1491,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/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 492fc12335a4a7fc5cb0865c78fa6a5e059a7fcb..b9527adce4b186d9ebde7029b1b9db972e4d8835 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -12746,6 +12746,7 @@ > BCC5BDFE0C0E93110011C2DB /* JSCSSStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleSheet.cpp; sourceTree = "<group>"; }; > BCC5BDFF0C0E93110011C2DB /* JSCSSStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleSheet.h; sourceTree = "<group>"; }; > BCC64F600DCFB84E0081EF3B /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = sourcecode.javascript; name = English; path = English.lproj/localizedStrings.js; sourceTree = SOURCE_ROOT; }; >+ BCC65145159294C300ACC9E4 /* IDBMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IDBMetadata.h; path = Modules/indexeddb/IDBMetadata.h; sourceTree = "<group>"; }; > BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ColorData.gperf; sourceTree = "<group>"; }; > BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLCollectionCustom.cpp; sourceTree = "<group>"; }; > BCCBAD3E0C18C14200CE890F /* JSHTMLCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLCollection.cpp; sourceTree = "<group>"; }; >@@ -17552,6 +17553,7 @@ > 9712A58D15004EDA0048AF10 /* IDBLevelDBBackingStore.h */, > 9712A58E15004EDA0048AF10 /* IDBLevelDBCoding.cpp */, > 9712A58F15004EDA0048AF10 /* IDBLevelDBCoding.h */, >+ BCC65145159294C300ACC9E4 /* IDBMetadata.h */, > 9712A59015004EDA0048AF10 /* IDBObjectStore.cpp */, > 9712A59115004EDA0048AF10 /* IDBObjectStore.h */, > 9712A59215004EDA0048AF10 /* IDBObjectStore.idl */, >diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp >index 74db258be20feba676d8d0e4706631ecf714b80f..6fa43f1014547bb62f82d589e8f6c383421ee6fc 100644 >--- a/Source/WebKit/chromium/WebKit.gyp >+++ b/Source/WebKit/chromium/WebKit.gyp >@@ -561,6 +561,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/WebIDBMetadata.h b/Source/WebKit/chromium/public/WebIDBMetadata.h >index 410d9facf8a71a23dc629892af3bc36e511f4a23..1c33d1b080d75682edced2fdfabea4b1ee4d865f 100644 >--- a/Source/WebKit/chromium/public/WebIDBMetadata.h >+++ b/Source/WebKit/chromium/public/WebIDBMetadata.h >@@ -31,6 +31,10 @@ > #include "platform/WebString.h" > #include "platform/WebVector.h" > >+namespace WebCore { >+struct IDBDatabaseMetadata; >+} >+ > namespace WebKit { > > struct WebIDBMetadata { >@@ -62,6 +66,11 @@ struct WebIDBMetadata { > , unique(false) > , multiEntry(false) { } > }; >+ >+#if WEBKIT_IMPLEMENTATION >+ WebIDBMetadata(const WebCore::IDBDatabaseMetadata&); >+ operator WebCore::IDBDatabaseMetadata() const; >+#endif > }; > > >diff --git a/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp b/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp >index 58661ebab83f5bcf8a4ca89abe7db81084c905f4..107ec63b3b7883e09eea337c5915c35ad40a1d3b 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 e817edf1995da2a867e955906d98970eb344f92b..b05552ccbf117205cce574ce9aad285f9ebbef8e 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 2662f801f75f20e3151e4e8708b5efa736cc7ae6..39803e14593ed734096aa6c7832859cc2b6e25ed 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() > { > } > >+WebIDBMetadata 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 190d7e2dc329b06fb3ae6f8984b31b2d252bab82..5e989e00eedba201bded0a6db7979575be950987 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 WebIDBMetadata 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..735063ef0ff33bb8a6c6d2eeb806570b01fd59cb >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebIDBMetadata.cpp >@@ -0,0 +1,88 @@ >+/* >+ * 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 { >+ >+WebIDBMetadata::WebIDBMetadata(const WebCore::IDBDatabaseMetadata& metadata) >+{ >+ name = metadata.name; >+ version = metadata.version; >+ objectStores = WebVector<ObjectStore>(static_cast<size_t>(metadata.objectStores.size())); >+ >+ size_t i = 0; >+ for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator storeIterator = metadata.objectStores.begin(); storeIterator != metadata.objectStores.end(); ++storeIterator) { >+ const IDBObjectStoreMetadata& objectStore = storeIterator->second; >+ ObjectStore webObjectStore; >+ webObjectStore.name = objectStore.name; >+ webObjectStore.keyPath = objectStore.keyPath; >+ webObjectStore.autoIncrement = objectStore.autoIncrement; >+ webObjectStore.indexes = WebVector<Index>(static_cast<size_t>(objectStore.indexes.size())); >+ >+ size_t j = 0; >+ for (IDBObjectStoreMetadata::IndexMap::const_iterator indexIterator = objectStore.indexes.begin(); indexIterator != objectStore.indexes.end(); ++indexIterator) { >+ const IDBIndexMetadata& index = indexIterator->second; >+ Index webIndex; >+ webIndex.name = index.name; >+ webIndex.keyPath = index.keyPath; >+ webIndex.unique = index.unique; >+ webIndex.multiEntry = index.multiEntry; >+ webObjectStore.indexes[j++] = webIndex; >+ } >+ objectStores[i++] = webObjectStore; >+ } >+} >+ >+WebIDBMetadata::operator IDBDatabaseMetadata() const >+{ >+ IDBDatabaseMetadata db(name, version); >+ for (size_t i = 0; i < objectStores.size(); ++i) { >+ const ObjectStore webObjectStore = objectStores[i]; >+ IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.keyPath, webObjectStore.autoIncrement); >+ >+ for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) { >+ const Index webIndex = webObjectStore.indexes[j]; >+ IDBIndexMetadata index(webIndex.name, webIndex.keyPath, webIndex.unique, webIndex.multiEntry); >+ objectStore.indexes.set(index.name, index); >+ } >+ db.objectStores.set(objectStore.name, objectStore); >+ } >+ return db; >+} >+ >+} // namespace WebKit >+ >+#endif // ENABLE(INDEXED_DATABASE) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f5592e23902ca9e8d9ad9e86814643eae589e601..ada9cfd502052c84e77b4f3ed1552aff6d909f77 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,32 @@ >+2012-06-19 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/metadata-expected.txt: Added. >+ * storage/indexeddb/metadata.html: Added. >+ * 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): >+ > 2012-06-21 Taiju Tsuiki <tzik@chromium.org> > > Web Inspector: Move requestId allocation from FileSystem frontend to backend >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/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();
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