IndexedDB: Refactor IDBDatabaseBackendImpl to use IDBDatabaseMetadata
authoralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2012 01:03:53 +0000 (01:03 +0000)
committeralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2012 01:03:53 +0000 (01:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99773

Reviewed by Tony Chang.

Refactor to begin separating out metadata from stateful backend objects,
in preparation for https://bugs.webkit.org/show_bug.cgi?id=99774.

Also includes some #include dependency cleanup so that the backing store
depends less on the stateful backend objects.

No new tests as this is purely a refactor.

* Modules/indexeddb/IDBBackingStore.h:
(WebCore):
(IDBBackingStore):
* Modules/indexeddb/IDBCursor.h:
* Modules/indexeddb/IDBCursorBackendImpl.h:
(WebCore):
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(WebCore::IDBDatabaseBackendImpl::IDBDatabaseBackendImpl):
(WebCore::IDBDatabaseBackendImpl::openInternal):
(WebCore::IDBDatabaseBackendImpl::metadata):
(WebCore::IDBDatabaseBackendImpl::createObjectStore):
(WebCore::IDBDatabaseBackendImpl::setVersion):
(WebCore::IDBDatabaseBackendImpl::setVersionInternal):
(WebCore::IDBDatabaseBackendImpl::setIntVersionInternal):
(WebCore::IDBDatabaseBackendImpl::processPendingCalls):
(WebCore::IDBDatabaseBackendImpl::openConnection):
(WebCore::IDBDatabaseBackendImpl::runIntVersionChangeTransaction):
(WebCore::IDBDatabaseBackendImpl::openConnectionWithVersion):
(WebCore::IDBDatabaseBackendImpl::deleteDatabase):
(WebCore::IDBDatabaseBackendImpl::loadObjectStores):
(WebCore::IDBDatabaseBackendImpl::resetVersion):
* Modules/indexeddb/IDBDatabaseBackendImpl.h:
(WebCore::IDBDatabaseBackendImpl::id):
(IDBDatabaseBackendImpl):
* Modules/indexeddb/IDBLevelDBBackingStore.cpp:
(WebCore::IDBLevelDBBackingStore::getIDBDatabaseMetaData):
(WebCore::IDBLevelDBBackingStore::deleteDatabase):
* Modules/indexeddb/IDBLevelDBBackingStore.h:
(IDBLevelDBBackingStore):
* Modules/indexeddb/IDBObjectStoreBackendInterface.h:
* Modules/indexeddb/IDBTransaction.h:
(WebCore):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131832 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBBackingStore.h
Source/WebCore/Modules/indexeddb/IDBCursor.h
Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
Source/WebKit/chromium/tests/IDBFakeBackingStore.h

index 11ae737ae95b3f1949c658e140e6eef03ea235b7..7284a54a0580564cc9cd1edd1f099c8c30a08156 100644 (file)
@@ -1,3 +1,51 @@
+2012-10-18  Alec Flett  <alecflett@chromium.org>
+
+        IndexedDB: Refactor IDBDatabaseBackendImpl to use IDBDatabaseMetadata
+        https://bugs.webkit.org/show_bug.cgi?id=99773
+
+        Reviewed by Tony Chang.
+
+        Refactor to begin separating out metadata from stateful backend objects,
+        in preparation for https://bugs.webkit.org/show_bug.cgi?id=99774.
+
+        Also includes some #include dependency cleanup so that the backing store
+        depends less on the stateful backend objects.
+
+        No new tests as this is purely a refactor.
+
+        * Modules/indexeddb/IDBBackingStore.h:
+        (WebCore):
+        (IDBBackingStore):
+        * Modules/indexeddb/IDBCursor.h:
+        * Modules/indexeddb/IDBCursorBackendImpl.h:
+        (WebCore):
+        * Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
+        (WebCore::IDBDatabaseBackendImpl::IDBDatabaseBackendImpl):
+        (WebCore::IDBDatabaseBackendImpl::openInternal):
+        (WebCore::IDBDatabaseBackendImpl::metadata):
+        (WebCore::IDBDatabaseBackendImpl::createObjectStore):
+        (WebCore::IDBDatabaseBackendImpl::setVersion):
+        (WebCore::IDBDatabaseBackendImpl::setVersionInternal):
+        (WebCore::IDBDatabaseBackendImpl::setIntVersionInternal):
+        (WebCore::IDBDatabaseBackendImpl::processPendingCalls):
+        (WebCore::IDBDatabaseBackendImpl::openConnection):
+        (WebCore::IDBDatabaseBackendImpl::runIntVersionChangeTransaction):
+        (WebCore::IDBDatabaseBackendImpl::openConnectionWithVersion):
+        (WebCore::IDBDatabaseBackendImpl::deleteDatabase):
+        (WebCore::IDBDatabaseBackendImpl::loadObjectStores):
+        (WebCore::IDBDatabaseBackendImpl::resetVersion):
+        * Modules/indexeddb/IDBDatabaseBackendImpl.h:
+        (WebCore::IDBDatabaseBackendImpl::id):
+        (IDBDatabaseBackendImpl):
+        * Modules/indexeddb/IDBLevelDBBackingStore.cpp:
+        (WebCore::IDBLevelDBBackingStore::getIDBDatabaseMetaData):
+        (WebCore::IDBLevelDBBackingStore::deleteDatabase):
+        * Modules/indexeddb/IDBLevelDBBackingStore.h:
+        (IDBLevelDBBackingStore):
+        * Modules/indexeddb/IDBObjectStoreBackendInterface.h:
+        * Modules/indexeddb/IDBTransaction.h:
+        (WebCore):
+
 2012-10-18  Peter Kasting  <pkasting@google.com>
 
         [Skia] Set m_hasAlpha correctly in ImageFrame::copyBitmapData.
index cc197c217fe65eda92ce0425454bb436adc79371..d37493b9830cdf266dc18c6265a97a9585676506 100644 (file)
 #if ENABLE(INDEXED_DATABASE)
 
 #include "IDBCursor.h"
-#include "IDBFactoryBackendInterface.h"
-#include "SQLiteDatabase.h"
+#include "IDBKeyPath.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
 class IDBKey;
 class IDBKeyRange;
 class SecurityOrigin;
+struct IDBDatabaseMetadata;
 
 class IDBBackingStore : public RefCounted<IDBBackingStore> {
 public:
@@ -49,7 +50,7 @@ public:
     virtual ~IDBBackingStore() {};
 
     virtual void getDatabaseNames(Vector<String>& foundNames) = 0;
-    virtual bool getIDBDatabaseMetaData(const String& name, String& foundStringVersion, int64_t& foundIntVersion, int64_t& foundId, int64_t& maxObjectStoreId) = 0;
+    virtual bool getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata* foundMetadata) = 0;
     virtual bool createIDBDatabaseMetaData(const String& name, const String& stringVersion, int64_t intVersion, int64_t& rowId) = 0;
     virtual bool updateIDBDatabaseIntVersion(Transaction*, int64_t rowId, int64_t intVersion) = 0;
     virtual bool updateIDBDatabaseMetaData(Transaction*, int64_t rowId, const String& version) = 0;
index fe725c9ba7871945a0b3783f864fa95300822fc6..5589c222fc57a8b52f6e3f65ebb69c2e7f2225e0 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "IDBKey.h"
 #include "IDBTransaction.h"
+#include "ScriptValue.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
index 3b92f117ef1e4e2f971e7209c8cd540387e00ede..1f74c3391e2f99f0c6a3623be0d691cc83133e8a 100644 (file)
@@ -32,6 +32,8 @@
 #include "IDBBackingStore.h"
 #include "IDBCursor.h"
 #include "IDBCursorBackendInterface.h"
+#include "IDBTransactionBackendImpl.h"
+#include "SerializedScriptValue.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -42,8 +44,6 @@ class IDBDatabaseBackendImpl;
 class IDBIndexBackendImpl;
 class IDBKeyRange;
 class IDBObjectStoreBackendImpl;
-class IDBTransactionBackendImpl;
-class SerializedScriptValue;
 
 class IDBCursorBackendImpl : public IDBCursorBackendInterface {
 public:
index 4e895417d461bd68fc1180345c769196b4b1885c..d5fbd6dd4a7240d116d531e69abeeb8bf49ae96f 100644 (file)
@@ -133,28 +133,24 @@ const char* NoStringVersion = "";
 
 IDBDatabaseBackendImpl::IDBDatabaseBackendImpl(const String& name, IDBBackingStore* backingStore, IDBFactoryBackendImpl* factory, const String& uniqueIdentifier)
     : m_backingStore(backingStore)
-    , m_id(InvalidId)
-    , m_name(name)
-    , m_version(NoStringVersion)
-    , m_intVersion(IDBDatabaseMetadata::NoIntVersion)
-    , m_maxObjectStoreId(InvalidId)
+    , m_metadata(name, InvalidId, NoStringVersion, IDBDatabaseMetadata::NoIntVersion, InvalidId)
     , m_identifier(uniqueIdentifier)
     , m_factory(factory)
     , m_transactionCoordinator(IDBTransactionCoordinator::create())
     , m_closingConnection(false)
 {
-    ASSERT(!m_name.isNull());
+    ASSERT(!m_metadata.name.isNull());
 }
 
 bool IDBDatabaseBackendImpl::openInternal()
 {
-    bool success = m_backingStore->getIDBDatabaseMetaData(m_name, m_version, m_intVersion, m_id, m_maxObjectStoreId);
-    ASSERT_WITH_MESSAGE(success == (m_id != InvalidId), "success = %s, m_id = %lld", success ? "true" : "false", static_cast<long long>(m_id));
+    bool success = m_backingStore->getIDBDatabaseMetaData(m_metadata.name, &m_metadata);
+    ASSERT_WITH_MESSAGE(success == (m_metadata.id != InvalidId), "success = %s, m_id = %lld", success ? "true" : "false", static_cast<long long>(m_metadata.id));
     if (success) {
         loadObjectStores();
         return true;
     }
-    return m_backingStore->createIDBDatabaseMetaData(m_name, m_version, m_intVersion, m_id);
+    return m_backingStore->createIDBDatabaseMetaData(m_metadata.name, m_metadata.version, m_metadata.intVersion, m_metadata.id);
 }
 
 IDBDatabaseBackendImpl::~IDBDatabaseBackendImpl()
@@ -168,7 +164,8 @@ PassRefPtr<IDBBackingStore> IDBDatabaseBackendImpl::backingStore() const
 
 IDBDatabaseMetadata IDBDatabaseBackendImpl::metadata() const
 {
-    IDBDatabaseMetadata metadata(m_name, m_id, m_version, m_intVersion, m_maxObjectStoreId);
+    // FIXME: Figure out a way to keep m_metadata.objectStores.get(N).indexes up to date rather than regenerating this every time.
+    IDBDatabaseMetadata metadata(m_metadata);
     for (ObjectStoreMap::const_iterator it = m_objectStores.begin(); it != m_objectStores.end(); ++it)
         metadata.objectStores.set(it->key, it->value->metadata());
     return metadata;
@@ -184,9 +181,9 @@ PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectS
     RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
     ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);
 
-    // FIXME: Fix edge cases around transaction aborts that prevent this from just being ASSERT(id == m_maxObjectStoreId + 1)
-    ASSERT(id > m_maxObjectStoreId);
-    m_maxObjectStoreId = id;
+    // FIXME: Fix edge cases around transaction aborts that prevent this from just being ASSERT(id == m_metadata.maxObjectStoreId + 1)
+    ASSERT(id > m_metadata.maxObjectStoreId);
+    m_metadata.maxObjectStoreId = id;
 
     RefPtr<IDBDatabaseBackendImpl> database = this;
     if (!transaction->scheduleTask(
@@ -275,7 +272,7 @@ void IDBDatabaseBackendImpl::setVersion(const String& version, PassRefPtr<IDBCal
     RefPtr<IDBDatabaseBackendImpl> database = this;
     if (!transaction->scheduleTask(
             createCallbackTask(&IDBDatabaseBackendImpl::setVersionInternal, database, version, callbacks, transaction),
-            createCallbackTask(&IDBDatabaseBackendImpl::resetVersion, database, m_version, m_intVersion))) {
+            createCallbackTask(&IDBDatabaseBackendImpl::resetVersion, database, m_metadata.version, m_metadata.intVersion))) {
         // FIXME: Remove one of the following lines.
         ASSERT_NOT_REACHED();
         ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
@@ -286,9 +283,9 @@ void IDBDatabaseBackendImpl::setVersionInternal(ScriptExecutionContext*, PassRef
 {
     RefPtr<IDBTransactionBackendImpl> transaction = prpTransaction;
     int64_t databaseId = database->id();
-    database->m_version = version;
-    database->m_intVersion = IDBDatabaseMetadata::NoIntVersion;
-    if (!database->m_backingStore->updateIDBDatabaseMetaData(transaction->backingStoreTransaction(), databaseId, database->m_version) || !database->m_backingStore->updateIDBDatabaseIntVersion(transaction->backingStoreTransaction(), databaseId, database->m_intVersion)) {
+    database->m_metadata.version = version;
+    database->m_metadata.intVersion = IDBDatabaseMetadata::NoIntVersion;
+    if (!database->m_backingStore->updateIDBDatabaseMetaData(transaction->backingStoreTransaction(), databaseId, database->m_metadata.version) || !database->m_backingStore->updateIDBDatabaseIntVersion(transaction->backingStoreTransaction(), databaseId, database->m_metadata.intVersion)) {
         RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.");
         callbacks->onError(error);
         transaction->abort(error);
@@ -300,10 +297,10 @@ void IDBDatabaseBackendImpl::setVersionInternal(ScriptExecutionContext*, PassRef
 void IDBDatabaseBackendImpl::setIntVersionInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, int64_t version, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBTransactionBackendImpl> transaction)
 {
     int64_t databaseId = database->id();
-    int64_t oldVersion = database->m_intVersion;
+    int64_t oldVersion = database->m_metadata.intVersion;
     ASSERT(version > oldVersion);
-    database->m_intVersion = version;
-    if (!database->m_backingStore->updateIDBDatabaseIntVersion(transaction->backingStoreTransaction(), databaseId, database->m_intVersion)) {
+    database->m_metadata.intVersion = version;
+    if (!database->m_backingStore->updateIDBDatabaseIntVersion(transaction->backingStoreTransaction(), databaseId, database->m_metadata.intVersion)) {
         RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.");
         callbacks->onError(error);
         transaction->abort(error);
@@ -363,8 +360,8 @@ size_t IDBDatabaseBackendImpl::connectionCount()
 void IDBDatabaseBackendImpl::processPendingCalls()
 {
     if (m_pendingSecondHalfOpenWithVersion) {
-        ASSERT(m_pendingSecondHalfOpenWithVersion->version() == m_intVersion);
-        ASSERT(m_id != InvalidId);
+        ASSERT(m_pendingSecondHalfOpenWithVersion->version() == m_metadata.intVersion);
+        ASSERT(m_metadata.id != InvalidId);
         m_pendingSecondHalfOpenWithVersion->callbacks()->onSuccess(this);
         m_pendingSecondHalfOpenWithVersion.release();
         // Fall through when complete, as pending deletes may be (partially) unblocked.
@@ -445,11 +442,11 @@ void IDBDatabaseBackendImpl::openConnection(PassRefPtr<IDBCallbacks> callbacks,
         m_pendingOpenCalls.append(PendingOpenCall::create(callbacks, databaseCallbacks));
         return;
     }
-    if (m_id == InvalidId && !openInternal()) {
+    if (m_metadata.id == InvalidId && !openInternal()) {
         callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
         return;
     }
-    if (m_version == NoStringVersion && m_intVersion == IDBDatabaseMetadata::NoIntVersion) {
+    if (m_metadata.version == NoStringVersion && m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion) {
         // Spec says: If no version is specified and no database exists, set
         // database version to 1. We infer that the database didn't exist from
         // its lack of either type of version.
@@ -468,7 +465,7 @@ void IDBDatabaseBackendImpl::runIntVersionChangeTransaction(int64_t requestedVer
     for (DatabaseCallbacksSet::const_iterator it = m_databaseCallbacksSet.begin(); it != m_databaseCallbacksSet.end(); ++it) {
         // Front end ensures the event is not fired at connections that have closePending set.
         if (*it != databaseCallbacks)
-            (*it)->onVersionChange(m_intVersion, requestedVersion);
+            (*it)->onVersionChange(m_metadata.intVersion, requestedVersion);
     }
     // The spec dictates we wait until all the version change events are
     // delivered and then check m_databaseCallbacks.empty() before proceeding
@@ -478,7 +475,7 @@ void IDBDatabaseBackendImpl::runIntVersionChangeTransaction(int64_t requestedVer
     // tells us that all the blocked events have been delivered. See
     // https://bugs.webkit.org/show_bug.cgi?id=71130
     if (connectionCount())
-        callbacks->onBlocked(m_intVersion);
+        callbacks->onBlocked(m_metadata.intVersion);
     // FIXME: Add test for m_runningVersionChangeTransaction.
     if (m_runningVersionChangeTransaction || connectionCount()) {
         m_pendingOpenWithVersionCalls.append(PendingOpenWithVersionCall::create(callbacks, databaseCallbacks, requestedVersion));
@@ -493,7 +490,7 @@ void IDBDatabaseBackendImpl::runIntVersionChangeTransaction(int64_t requestedVer
 
     RefPtr<IDBDatabaseBackendImpl> database = this;
     OwnPtr<ScriptExecutionContext::Task> intVersionTask = createCallbackTask(&IDBDatabaseBackendImpl::setIntVersionInternal, database, requestedVersion, callbacks, transaction);
-    OwnPtr<ScriptExecutionContext::Task> resetVersionOnAbortTask = createCallbackTask(&IDBDatabaseBackendImpl::resetVersion, database, m_version, m_intVersion);
+    OwnPtr<ScriptExecutionContext::Task> resetVersionOnAbortTask = createCallbackTask(&IDBDatabaseBackendImpl::resetVersion, database, m_metadata.version, m_metadata.intVersion);
     if (!transaction->scheduleTask(intVersionTask.release(), resetVersionOnAbortTask.release())) {
         // FIXME: Remove one of the following lines.
         ASSERT_NOT_REACHED();
@@ -512,23 +509,23 @@ void IDBDatabaseBackendImpl::openConnectionWithVersion(PassRefPtr<IDBCallbacks>
         m_pendingOpenWithVersionCalls.append(PendingOpenWithVersionCall::create(callbacks, databaseCallbacks, version));
         return;
     }
-    if (m_id == InvalidId) {
+    if (m_metadata.id == InvalidId) {
         if (openInternal())
-            ASSERT(m_intVersion == IDBDatabaseMetadata::NoIntVersion);
+            ASSERT(m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion);
         else {
             callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
             return;
         }
     }
-    if (version > m_intVersion) {
+    if (version > m_metadata.intVersion) {
         runIntVersionChangeTransaction(version, callbacks, databaseCallbacks);
         return;
     }
-    if (version < m_intVersion) {
-        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::VER_ERR, String::format("The requested version (%lld) is less than the existing version (%lld).", static_cast<long long>(version), static_cast<long long>(m_intVersion))));
+    if (version < m_metadata.intVersion) {
+        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::VER_ERR, String::format("The requested version (%lld) is less than the existing version (%lld).", static_cast<long long>(version), static_cast<long long>(m_metadata.intVersion))));
         return;
     }
-    ASSERT(version == m_intVersion);
+    ASSERT(version == m_metadata.intVersion);
     m_databaseCallbacksSet.add(databaseCallbacks);
     callbacks->onSuccess(this);
 }
@@ -553,13 +550,13 @@ void IDBDatabaseBackendImpl::deleteDatabase(PassRefPtr<IDBCallbacks> prpCallback
         return;
     }
     ASSERT(m_backingStore);
-    if (!m_backingStore->deleteDatabase(m_name)) {
+    if (!m_backingStore->deleteDatabase(m_metadata.name)) {
         callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
         return;
     }
-    m_version = NoStringVersion;
-    m_id = InvalidId;
-    m_intVersion = IDBDatabaseMetadata::NoIntVersion;
+    m_metadata.version = NoStringVersion;
+    m_metadata.id = InvalidId;
+    m_metadata.intVersion = IDBDatabaseMetadata::NoIntVersion;
     m_objectStores.clear();
     callbacks->onSuccess();
 }
@@ -611,7 +608,7 @@ void IDBDatabaseBackendImpl::loadObjectStores()
     Vector<IDBKeyPath> keyPaths;
     Vector<bool> autoIncrementFlags;
     Vector<int64_t> maxIndexIds;
-    m_backingStore->getObjectStores(m_id, ids, names, keyPaths, autoIncrementFlags, maxIndexIds);
+    m_backingStore->getObjectStores(m_metadata.id, ids, names, keyPaths, autoIncrementFlags, maxIndexIds);
 
     ASSERT(names.size() == ids.size());
     ASSERT(keyPaths.size() == ids.size());
@@ -638,8 +635,8 @@ void IDBDatabaseBackendImpl::addObjectStoreToMap(ScriptExecutionContext*, PassRe
 
 void IDBDatabaseBackendImpl::resetVersion(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, const String& previousVersion, int64_t previousIntVersion)
 {
-    database->m_version = previousVersion;
-    database->m_intVersion = previousIntVersion;
+    database->m_metadata.version = previousVersion;
+    database->m_metadata.intVersion = previousIntVersion;
 }
 
 } // namespace WebCore
index 97b855dae40c006a21da76cb97b3830cf9741366..11a69d0bfda66b06201d3963c0ee144ab88e35e8 100644 (file)
@@ -53,7 +53,7 @@ public:
     PassRefPtr<IDBBackingStore> backingStore() const;
 
     static const int64_t InvalidId = 0;
-    int64_t id() const { return m_id; }
+    int64_t id() const { return m_metadata.id; }
 
     void openConnection(PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>);
     void openConnectionWithVersion(PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, int64_t version);
@@ -94,11 +94,7 @@ private:
     static void resetVersion(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl>, const String& version, int64_t intVersion);
 
     RefPtr<IDBBackingStore> m_backingStore;
-    int64_t m_id;
-    String m_name;
-    String m_version;
-    int64_t m_intVersion;
-    int64_t m_maxObjectStoreId;
+    IDBDatabaseMetadata m_metadata;
 
     String m_identifier;
     // This might not need to be a RefPtr since the factory's lifetime is that of the page group, but it's better to be conservitive than sorry.
index d6fbb6767d55fd8a51cd168e700069d56662d994..e51350d1cd1df19d90cf6b4ccc8e95b60358d659 100644 (file)
@@ -37,6 +37,7 @@
 #include "IDBKeyPath.h"
 #include "IDBKeyRange.h"
 #include "IDBLevelDBCoding.h"
+#include "IDBMetadata.h"
 #include "LevelDBComparator.h"
 #include "LevelDBDatabase.h"
 #include "LevelDBIterator.h"
@@ -313,25 +314,25 @@ void IDBLevelDBBackingStore::getDatabaseNames(Vector<String>& foundNames)
     }
 }
 
-bool IDBLevelDBBackingStore::getIDBDatabaseMetaData(const String& name, String& foundStringVersion, int64_t& foundIntVersion, int64_t& foundId, int64_t& maxObjectStoreId)
+bool IDBLevelDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata* metadata)
 {
     const Vector<char> key = DatabaseNameKey::encode(m_identifier, name);
 
-    bool ok = getInt(m_db.get(), key, foundId);
+    bool ok = getInt(m_db.get(), key, metadata->id);
     if (!ok)
         return false;
 
-    ok = getString(m_db.get(), DatabaseMetaDataKey::encode(foundId, DatabaseMetaDataKey::UserVersion), foundStringVersion);
+    ok = getString(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserVersion), metadata->version);
     if (!ok)
         return false;
 
-    ok = getVarInt(m_db.get(), DatabaseMetaDataKey::encode(foundId, DatabaseMetaDataKey::UserIntVersion), foundIntVersion);
+    ok = getVarInt(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserIntVersion), metadata->intVersion);
     if (!ok)
         return false;
-    if (foundIntVersion == IDBDatabaseMetadata::DefaultIntVersion)
-        foundIntVersion = IDBDatabaseMetadata::NoIntVersion;
+    if (metadata->intVersion == IDBDatabaseMetadata::DefaultIntVersion)
+        metadata->intVersion = IDBDatabaseMetadata::NoIntVersion;
 
-    maxObjectStoreId = getMaxObjectStoreId(m_db.get(), foundId);
+    metadata->maxObjectStoreId = getMaxObjectStoreId(m_db.get(), metadata->id);
 
     return true;
 }
@@ -405,15 +406,12 @@ bool IDBLevelDBBackingStore::deleteDatabase(const String& name)
     IDB_TRACE("IDBLevelDBBackingStore::deleteDatabase");
     OwnPtr<LevelDBWriteOnlyTransaction> transaction = LevelDBWriteOnlyTransaction::create(m_db.get());
 
-    int64_t databaseId;
-    String version;
-    int64_t intVersion;
-    int64_t maxObjectStoreId;
-    if (!getIDBDatabaseMetaData(name, version, intVersion, databaseId, maxObjectStoreId))
+    IDBDatabaseMetadata metadata;
+    if (!getIDBDatabaseMetaData(name, &metadata))
         return true;
 
-    const Vector<char> startKey = DatabaseMetaDataKey::encode(databaseId, DatabaseMetaDataKey::OriginName);
-    const Vector<char> stopKey = DatabaseMetaDataKey::encode(databaseId + 1, DatabaseMetaDataKey::OriginName);
+    const Vector<char> startKey = DatabaseMetaDataKey::encode(metadata.id, DatabaseMetaDataKey::OriginName);
+    const Vector<char> stopKey = DatabaseMetaDataKey::encode(metadata.id + 1, DatabaseMetaDataKey::OriginName);
     OwnPtr<LevelDBIterator> it = m_db->createIterator();
     for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) < 0; it->next())
         transaction->remove(it->key());
index caa57f514b5998d4e8b42881ad12a1479f3eb88d..0cf3276b32edd955077bf89eb49c194dbc7aaa87 100644 (file)
@@ -45,7 +45,7 @@ public:
     virtual ~IDBLevelDBBackingStore();
 
     virtual void getDatabaseNames(Vector<String>& foundNames);
-    virtual bool getIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundIntVersion, int64_t& foundId, int64_t& maxObjectStoreId);
+    virtual bool getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata*);
     virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId);
     virtual bool updateIDBDatabaseMetaData(IDBBackingStore::Transaction*, int64_t rowId, const String& version);
     virtual bool updateIDBDatabaseIntVersion(IDBBackingStore::Transaction*, int64_t rowId, int64_t intVersion);
index 4353db9ff1cd2b0935de25c6d2d5e9e0ab06be22..c6ea13c5019d8cf830bf1df9063881f1d48d68dd 100644 (file)
@@ -27,6 +27,7 @@
 #define IDBObjectStoreBackendInterface_h
 
 #include "IDBCursor.h"
+#include "IDBTransactionBackendInterface.h"
 #include <wtf/Threading.h>
 #include <wtf/text/WTFString.h>
 
index d673c02d973f3561c27c2fea5733f12d453afaba..89939bf85975b1cb9f7f50b5197f9f6ac31bfc95 100644 (file)
@@ -35,8 +35,6 @@
 #include "EventListener.h"
 #include "EventNames.h"
 #include "EventTarget.h"
-#include "IDBMetadata.h"
-#include "IDBTransactionBackendInterface.h"
 #include "IDBTransactionCallbacks.h"
 #include <wtf/HashSet.h>
 #include <wtf/RefCounted.h>
@@ -47,6 +45,8 @@ class IDBCursor;
 class IDBDatabase;
 class IDBObjectStore;
 class IDBOpenDBRequest;
+class IDBTransactionBackendInterface;
+struct IDBObjectStoreMetadata;
 
 class IDBTransaction : public IDBTransactionCallbacks, public EventTarget, public ActiveDOMObject {
 public:
index cd2a0764973b5a3bee2d5ea043756af0032915c2..2be4e567e7315adcee6a5d16478a28ff2a6c7fbe 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "config.h"
+#include "IDBCallbacks.h"
 #include "IDBCursorBackendInterface.h"
 #include "IDBDatabaseBackendInterface.h"
 #include "IDBDatabaseCallbacks.h"
index c59dce67517e1f63e1d3b336457eb654f32a41d6..45cdd1cb2ede16b2cc756d9acc5d140599771cf4 100644 (file)
@@ -33,7 +33,7 @@ namespace WebCore {
 class IDBFakeBackingStore : public IDBBackingStore {
 public:
     virtual void getDatabaseNames(Vector<String>& foundNames) OVERRIDE { }
-    virtual bool getIDBDatabaseMetaData(const String& name, String& foundStringVersion, int64_t& foundIntVersion, int64_t& foundId, int64_t& maxObjectStoreId) OVERRIDE { return false; }
+    virtual bool getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata*) OVERRIDE { return false; }
     virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) OVERRIDE { return true; }
     virtual bool updateIDBDatabaseMetaData(Transaction*, int64_t rowId, const String& version) OVERRIDE { return false; }
     virtual bool updateIDBDatabaseIntVersion(Transaction*, int64_t rowId, int64_t version) OVERRIDE { return false; }