DatabaseProcess: Pipe through object store IDs and transaction mode for "openTransaction"
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2013 00:12:50 +0000 (00:12 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2013 00:12:50 +0000 (00:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125872

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Make these enums into enum classes.
Add const maximums for each enum class that might be serialized to allow for conversion later:
* Modules/indexeddb/IndexedDB.h:

Add cross-thread copying for these new enum classes.
* platform/CrossThreadCopier.cpp:
(WebCore::::copy):
* platform/CrossThreadCopier.h:

Adopt the new enum classes throughout the rest of WebCore:
* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::continueFunction):
(WebCore::IDBCursor::stringToDirection):
(WebCore::IDBCursor::directionToString):
* Modules/indexeddb/IDBCursor.h:
* Modules/indexeddb/IDBCursorBackend.cpp:
(WebCore::IDBCursorBackend::deleteFunction):
* Modules/indexeddb/IDBCursorBackend.h:
(WebCore::IDBCursorBackend::value):
* Modules/indexeddb/IDBDatabaseBackend.cpp:
(WebCore::IDBDatabaseBackend::createObjectStore):
(WebCore::IDBDatabaseBackend::deleteObjectStore):
(WebCore::IDBDatabaseBackend::createIndex):
(WebCore::IDBDatabaseBackend::deleteIndex):
(WebCore::IDBDatabaseBackend::get):
(WebCore::IDBDatabaseBackend::put):
(WebCore::IDBDatabaseBackend::setIndexKeys):
(WebCore::IDBDatabaseBackend::openCursor):
(WebCore::IDBDatabaseBackend::deleteRange):
(WebCore::IDBDatabaseBackend::clearObjectStore):
(WebCore::IDBDatabaseBackend::transactionStarted):
(WebCore::IDBDatabaseBackend::transactionFinished):
(WebCore::IDBDatabaseBackend::transactionFinishedAndAbortFired):
(WebCore::IDBDatabaseBackend::transactionFinishedAndCompleteFired):
(WebCore::IDBDatabaseBackend::createTransaction):
(WebCore::IDBDatabaseBackend::runIntVersionChangeTransaction):
(WebCore::IDBDatabaseBackend::deleteDatabase):
* Modules/indexeddb/IDBDatabaseBackend.h:
* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::open):
(WebCore::IDBFactory::openInternal):
(WebCore::IDBFactory::deleteDatabase):
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::openKeyCursor):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::openCursor):
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::IDBRequest):
(WebCore::IDBRequest::setResultCursor):
(WebCore::IDBRequest::onSuccess):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::create):
(WebCore::IDBTransaction::IDBTransaction):
(WebCore::IDBTransaction::stringToMode):
(WebCore::IDBTransaction::modeToString):
* Modules/indexeddb/IDBTransaction.h:
* Modules/indexeddb/IDBTransactionBackendOperations.cpp:
(WebCore::PutOperation::perform):
* Modules/indexeddb/IDBTransactionCoordinator.cpp:
(WebCore::IDBTransactionCoordinator::processStartedTransactions):
(WebCore::IDBTransactionCoordinator::canRunTransaction):
* Modules/indexeddb/IDBVersionChangeEvent.h:
(WebCore::IDBVersionChangeEvent::create):
(WebCore::IDBVersionChangeEvent::newVersion):
* Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
(WebCore::objectStoreCursorOptions):
(WebCore::indexCursorOptions):
* Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
(WebCore::IDBServerConnectionLevelDB::get):
(WebCore::IDBServerConnectionLevelDB::openCursor):
(WebCore::IDBServerConnectionLevelDB::count):
(WebCore::IDBServerConnectionLevelDB::deleteRange):
(WebCore::IDBServerConnectionLevelDB::cursorPrefetchIteration):

* WebCore.exp.in:

Source/WebKit2:

Pipe through the objectStoreIDs and mode:
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
(WebKit::DatabaseProcessIDBConnection::openTransaction):
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h:
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in:

Rework postTransactionOperation to take a pre-made AsyncTask to allow for different
transaction operation function signatures:
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::openTransaction): Pipe through the objectStoreIDs and mode:
(WebKit::UniqueIDBDatabase::beginTransaction):
(WebKit::UniqueIDBDatabase::commitTransaction):
(WebKit::UniqueIDBDatabase::resetTransaction):
(WebKit::UniqueIDBDatabase::rollbackTransaction):
(WebKit::UniqueIDBDatabase::postTransactionOperation):
(WebKit::UniqueIDBDatabase::openBackingStoreTransaction):
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:

Pipe through the objectStoreIDs and mode:
* DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::establishTransaction):
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:

* Platform/Logging.h: Add an IDB logging channel.

* Shared/AsyncTask.h:
(WebKit::createAsyncTask): Add a 3-argument variant.

* Shared/WebCrossThreadCopier.cpp:
(WebCore::::copy): Add a Vector<int64_t> copier.
* Shared/WebCrossThreadCopier.h:

Add logging throughout currently implemented methods:
* WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp:
(WebKit::WebIDBServerConnection::getOrEstablishIDBDatabaseMetadata):
(WebKit::WebIDBServerConnection::didGetOrEstablishIDBDatabaseMetadata):
(WebKit::WebIDBServerConnection::openTransaction): Pipe through the objectStoreIDs and mode.
(WebKit::WebIDBServerConnection::didOpenTransaction):
(WebKit::WebIDBServerConnection::beginTransaction):
(WebKit::WebIDBServerConnection::didBeginTransaction):
(WebKit::WebIDBServerConnection::commitTransaction):
(WebKit::WebIDBServerConnection::didCommitTransaction):
(WebKit::WebIDBServerConnection::resetTransaction):
(WebKit::WebIDBServerConnection::didResetTransaction):
(WebKit::WebIDBServerConnection::rollbackTransaction):
(WebKit::WebIDBServerConnection::didRollbackTransaction):

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

37 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBCursor.h
Source/WebCore/Modules/indexeddb/IDBCursorBackend.cpp
Source/WebCore/Modules/indexeddb/IDBCursorBackend.h
Source/WebCore/Modules/indexeddb/IDBDatabaseBackend.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseBackend.h
Source/WebCore/Modules/indexeddb/IDBFactory.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.h
Source/WebCore/Modules/indexeddb/IndexedDB.h
Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp
Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/CrossThreadCopier.cpp
Source/WebCore/platform/CrossThreadCopier.h
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h
Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h
Source/WebKit2/Platform/Logging.h
Source/WebKit2/Shared/AsyncTask.h
Source/WebKit2/Shared/WebCrossThreadCopier.cpp
Source/WebKit2/Shared/WebCrossThreadCopier.h
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp

index 3188071..76f1190 100644 (file)
@@ -1,3 +1,89 @@
+2013-12-17  Brady Eidson  <beidson@apple.com>
+
+        DatabaseProcess: Pipe through object store IDs and transaction mode for "openTransaction"
+        https://bugs.webkit.org/show_bug.cgi?id=125872
+
+        Reviewed by Alexey Proskuryakov.
+
+        Make these enums into enum classes.
+        Add const maximums for each enum class that might be serialized to allow for conversion later:
+        * Modules/indexeddb/IndexedDB.h:
+
+        Add cross-thread copying for these new enum classes.
+        * platform/CrossThreadCopier.cpp:
+        (WebCore::::copy):
+        * platform/CrossThreadCopier.h:
+
+        Adopt the new enum classes throughout the rest of WebCore:
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::continueFunction):
+        (WebCore::IDBCursor::stringToDirection):
+        (WebCore::IDBCursor::directionToString):
+        * Modules/indexeddb/IDBCursor.h:
+        * Modules/indexeddb/IDBCursorBackend.cpp:
+        (WebCore::IDBCursorBackend::deleteFunction):
+        * Modules/indexeddb/IDBCursorBackend.h:
+        (WebCore::IDBCursorBackend::value):
+        * Modules/indexeddb/IDBDatabaseBackend.cpp:
+        (WebCore::IDBDatabaseBackend::createObjectStore):
+        (WebCore::IDBDatabaseBackend::deleteObjectStore):
+        (WebCore::IDBDatabaseBackend::createIndex):
+        (WebCore::IDBDatabaseBackend::deleteIndex):
+        (WebCore::IDBDatabaseBackend::get):
+        (WebCore::IDBDatabaseBackend::put):
+        (WebCore::IDBDatabaseBackend::setIndexKeys):
+        (WebCore::IDBDatabaseBackend::openCursor):
+        (WebCore::IDBDatabaseBackend::deleteRange):
+        (WebCore::IDBDatabaseBackend::clearObjectStore):
+        (WebCore::IDBDatabaseBackend::transactionStarted):
+        (WebCore::IDBDatabaseBackend::transactionFinished):
+        (WebCore::IDBDatabaseBackend::transactionFinishedAndAbortFired):
+        (WebCore::IDBDatabaseBackend::transactionFinishedAndCompleteFired):
+        (WebCore::IDBDatabaseBackend::createTransaction):
+        (WebCore::IDBDatabaseBackend::runIntVersionChangeTransaction):
+        (WebCore::IDBDatabaseBackend::deleteDatabase):
+        * Modules/indexeddb/IDBDatabaseBackend.h:
+        * Modules/indexeddb/IDBFactory.cpp:
+        (WebCore::IDBFactory::open):
+        (WebCore::IDBFactory::openInternal):
+        (WebCore::IDBFactory::deleteDatabase):
+        * Modules/indexeddb/IDBIndex.cpp:
+        (WebCore::IDBIndex::openCursor):
+        (WebCore::IDBIndex::openKeyCursor):
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::openCursor):
+        * Modules/indexeddb/IDBOpenDBRequest.cpp:
+        (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::IDBRequest):
+        (WebCore::IDBRequest::setResultCursor):
+        (WebCore::IDBRequest::onSuccess):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::create):
+        (WebCore::IDBTransaction::IDBTransaction):
+        (WebCore::IDBTransaction::stringToMode):
+        (WebCore::IDBTransaction::modeToString):
+        * Modules/indexeddb/IDBTransaction.h:
+        * Modules/indexeddb/IDBTransactionBackendOperations.cpp:
+        (WebCore::PutOperation::perform):
+        * Modules/indexeddb/IDBTransactionCoordinator.cpp:
+        (WebCore::IDBTransactionCoordinator::processStartedTransactions):
+        (WebCore::IDBTransactionCoordinator::canRunTransaction):
+        * Modules/indexeddb/IDBVersionChangeEvent.h:
+        (WebCore::IDBVersionChangeEvent::create):
+        (WebCore::IDBVersionChangeEvent::newVersion):
+        * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
+        (WebCore::objectStoreCursorOptions):
+        (WebCore::indexCursorOptions):
+        * Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
+        (WebCore::IDBServerConnectionLevelDB::get):
+        (WebCore::IDBServerConnectionLevelDB::openCursor):
+        (WebCore::IDBServerConnectionLevelDB::count):
+        (WebCore::IDBServerConnectionLevelDB::deleteRange):
+        (WebCore::IDBServerConnectionLevelDB::cursorPrefetchIteration):
+
+        * WebCore.exp.in:
+
 2013-12-17  Gavin Barraclough  <barraclough@apple.com>
 
         Remove PageVisibilityStateUnloaded
index b99d83e..f6ea30e 100644 (file)
@@ -205,7 +205,7 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionCode& ec)
 
     if (key) {
         ASSERT(m_currentKey);
-        if (m_direction == IndexedDB::CursorNext || m_direction == IndexedDB::CursorNextNoDuplicate) {
+        if (m_direction == IndexedDB::CursorDirection::Next || m_direction == IndexedDB::CursorDirection::NextNoDuplicate) {
             if (!m_currentKey->isLessThan(key.get())) {
                 ec = IDBDatabaseException::DataError;
                 return;
@@ -300,31 +300,31 @@ PassRefPtr<IDBObjectStore> IDBCursor::effectiveObjectStore()
 IndexedDB::CursorDirection IDBCursor::stringToDirection(const String& directionString, ExceptionCode& ec)
 {
     if (directionString == IDBCursor::directionNext())
-        return IndexedDB::CursorNext;
+        return IndexedDB::CursorDirection::Next;
     if (directionString == IDBCursor::directionNextUnique())
-        return IndexedDB::CursorNextNoDuplicate;
+        return IndexedDB::CursorDirection::NextNoDuplicate;
     if (directionString == IDBCursor::directionPrev())
-        return IndexedDB::CursorPrev;
+        return IndexedDB::CursorDirection::Prev;
     if (directionString == IDBCursor::directionPrevUnique())
-        return IndexedDB::CursorPrevNoDuplicate;
+        return IndexedDB::CursorDirection::PrevNoDuplicate;
 
     ec = TypeError;
-    return IndexedDB::CursorNext;
+    return IndexedDB::CursorDirection::Next;
 }
 
-const AtomicString& IDBCursor::directionToString(unsigned short direction)
+const AtomicString& IDBCursor::directionToString(IndexedDB::CursorDirection direction)
 {
     switch (direction) {
-    case IndexedDB::CursorNext:
+    case IndexedDB::CursorDirection::Next:
         return IDBCursor::directionNext();
 
-    case IndexedDB::CursorNextNoDuplicate:
+    case IndexedDB::CursorDirection::NextNoDuplicate:
         return IDBCursor::directionNextUnique();
 
-    case IndexedDB::CursorPrev:
+    case IndexedDB::CursorDirection::Prev:
         return IDBCursor::directionPrev();
 
-    case IndexedDB::CursorPrevNoDuplicate:
+    case IndexedDB::CursorDirection::PrevNoDuplicate:
         return IDBCursor::directionPrevUnique();
 
     default:
index 04eb386..b58d5ae 100644 (file)
@@ -56,7 +56,7 @@ public:
     static const AtomicString& directionPrevUnique();
 
     static IndexedDB::CursorDirection stringToDirection(const String& modeString, ExceptionCode&);
-    static const AtomicString& directionToString(unsigned short mode);
+    static const AtomicString& directionToString(IndexedDB::CursorDirection mode);
 
     static PassRefPtr<IDBCursor> create(PassRefPtr<IDBCursorBackend>, IndexedDB::CursorDirection, IDBRequest*, IDBAny* source, IDBTransaction*);
     virtual ~IDBCursor();
index dce754d..af821c0 100644 (file)
@@ -76,7 +76,7 @@ void IDBCursorBackend::advance(unsigned long count, PassRefPtr<IDBCallbacks> prp
 void IDBCursorBackend::deleteFunction(PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode&)
 {
     LOG(StorageAPI, "IDBCursorBackend::delete");
-    ASSERT(m_transaction->mode() != IndexedDB::TransactionReadOnly);
+    ASSERT(m_transaction->mode() != IndexedDB::TransactionMode::ReadOnly);
     RefPtr<IDBKeyRange> keyRange = IDBKeyRange::create(primaryKey());
     m_transaction->database().deleteRange(m_transaction->id(), m_objectStoreID, keyRange.release(), prpCallbacks);
 }
index d18bfd1..1012b17 100644 (file)
@@ -61,7 +61,7 @@ public:
 
     IDBKey* key() const { return m_currentKey.get(); }
     IDBKey* primaryKey() const { return m_currentPrimaryKey.get(); }
-    SharedBuffer* value() const { return (m_cursorType == IndexedDB::CursorKeyOnly) ? 0 : m_currentValue.get(); }
+    SharedBuffer* value() const { return (m_cursorType == IndexedDB::CursorType::KeyOnly) ? 0 : m_currentValue.get(); }
     void updateCursorData(IDBKey*, IDBKey* primaryKey, SharedBuffer* value);
 
     void close();
index 68fafa8..3cef3f3 100644 (file)
@@ -133,7 +133,7 @@ void IDBDatabaseBackend::createObjectStore(int64_t transactionId, int64_t object
     IDBTransactionBackend* transaction = m_transactions.get(transactionId);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() == IndexedDB::TransactionVersionChange);
+    ASSERT(transaction->mode() == IndexedDB::TransactionMode::VersionChange);
 
     ASSERT(!m_metadata.objectStores.contains(objectStoreId));
     IDBObjectStoreMetadata objectStoreMetadata(name, objectStoreId, keyPath, autoIncrement, IDBDatabaseBackend::MinimumIndexId);
@@ -148,7 +148,7 @@ void IDBDatabaseBackend::deleteObjectStore(int64_t transactionId, int64_t object
     IDBTransactionBackend* transaction = m_transactions.get(transactionId);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() == IndexedDB::TransactionVersionChange);
+    ASSERT(transaction->mode() == IndexedDB::TransactionMode::VersionChange);
 
     ASSERT(m_metadata.objectStores.contains(objectStoreId));
     const IDBObjectStoreMetadata& objectStoreMetadata = m_metadata.objectStores.get(objectStoreId);
@@ -163,7 +163,7 @@ void IDBDatabaseBackend::createIndex(int64_t transactionId, int64_t objectStoreI
     IDBTransactionBackend* transaction = m_transactions.get(transactionId);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() == IndexedDB::TransactionVersionChange);
+    ASSERT(transaction->mode() == IndexedDB::TransactionMode::VersionChange);
 
     ASSERT(m_metadata.objectStores.contains(objectStoreId));
     const IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId);
@@ -182,7 +182,7 @@ void IDBDatabaseBackend::deleteIndex(int64_t transactionId, int64_t objectStoreI
     IDBTransactionBackend* transaction = m_transactions.get(transactionId);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() == IndexedDB::TransactionVersionChange);
+    ASSERT(transaction->mode() == IndexedDB::TransactionMode::VersionChange);
 
     ASSERT(m_metadata.objectStores.contains(objectStoreId));
     const IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId);
@@ -223,7 +223,7 @@ void IDBDatabaseBackend::get(int64_t transactionId, int64_t objectStoreId, int64
     if (!transaction)
         return;
 
-    transaction->scheduleGetOperation(m_metadata, objectStoreId, indexId, keyRange, keyOnly ? IndexedDB::CursorKeyOnly : IndexedDB::CursorKeyAndValue, callbacks);
+    transaction->scheduleGetOperation(m_metadata, objectStoreId, indexId, keyRange, keyOnly ? IndexedDB::CursorType::KeyOnly : IndexedDB::CursorType::KeyAndValue, callbacks);
 }
 
 void IDBDatabaseBackend::put(int64_t transactionId, int64_t objectStoreId, PassRefPtr<SharedBuffer> value, PassRefPtr<IDBKey> key, PutMode putMode, PassRefPtr<IDBCallbacks> callbacks, const Vector<int64_t>& indexIds, const Vector<IndexKeys>& indexKeys)
@@ -232,7 +232,7 @@ void IDBDatabaseBackend::put(int64_t transactionId, int64_t objectStoreId, PassR
     IDBTransactionBackend* transaction = m_transactions.get(transactionId);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() != IndexedDB::TransactionReadOnly);
+    ASSERT(transaction->mode() != IndexedDB::TransactionMode::ReadOnly);
 
     const IDBObjectStoreMetadata objectStoreMetadata = m_metadata.objectStores.get(objectStoreId);
 
@@ -250,7 +250,7 @@ void IDBDatabaseBackend::setIndexKeys(int64_t transactionID, int64_t objectStore
     RefPtr<IDBTransactionBackend> transaction = m_transactions.get(transactionID);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() == IndexedDB::TransactionVersionChange);
+    ASSERT(transaction->mode() == IndexedDB::TransactionMode::VersionChange);
 
     RefPtr<IDBKey> primaryKey = prpPrimaryKey;
     m_serverConnection->setIndexKeys(transactionID, m_metadata.id, objectStoreID, m_metadata.objectStores.get(objectStoreID), *primaryKey, indexIDs, indexKeys, [transaction](PassRefPtr<IDBDatabaseError> error) {
@@ -277,7 +277,7 @@ void IDBDatabaseBackend::openCursor(int64_t transactionId, int64_t objectStoreId
     if (!transaction)
         return;
 
-    transaction->scheduleOpenCursorOperation(objectStoreId, indexId, keyRange, direction, keyOnly ? IndexedDB::CursorKeyOnly : IndexedDB::CursorKeyAndValue, taskType, callbacks);
+    transaction->scheduleOpenCursorOperation(objectStoreId, indexId, keyRange, direction, keyOnly ? IndexedDB::CursorType::KeyOnly : IndexedDB::CursorType::KeyAndValue, taskType, callbacks);
 }
 
 void IDBDatabaseBackend::count(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange> keyRange, PassRefPtr<IDBCallbacks> callbacks)
@@ -298,7 +298,7 @@ void IDBDatabaseBackend::deleteRange(int64_t transactionId, int64_t objectStoreI
     IDBTransactionBackend* transaction = m_transactions.get(transactionId);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() != IndexedDB::TransactionReadOnly);
+    ASSERT(transaction->mode() != IndexedDB::TransactionMode::ReadOnly);
 
     transaction->scheduleDeleteRangeOperation(objectStoreId, keyRange, callbacks);
 }
@@ -309,14 +309,14 @@ void IDBDatabaseBackend::clearObjectStore(int64_t transactionId, int64_t objectS
     IDBTransactionBackend* transaction = m_transactions.get(transactionId);
     if (!transaction)
         return;
-    ASSERT(transaction->mode() != IndexedDB::TransactionReadOnly);
+    ASSERT(transaction->mode() != IndexedDB::TransactionMode::ReadOnly);
 
     transaction->scheduleClearObjectStoreOperation(objectStoreId, callbacks);
 }
 
 void IDBDatabaseBackend::transactionStarted(IDBTransactionBackend* transaction)
 {
-    if (transaction->mode() == IndexedDB::TransactionVersionChange) {
+    if (transaction->mode() == IndexedDB::TransactionMode::VersionChange) {
         ASSERT(!m_runningVersionChangeTransaction);
         m_runningVersionChangeTransaction = transaction;
     }
@@ -328,7 +328,7 @@ void IDBDatabaseBackend::transactionFinished(IDBTransactionBackend* rawTransacti
     ASSERT(m_transactions.contains(transaction->id()));
     ASSERT(m_transactions.get(transaction->id()) == transaction.get());
     m_transactions.remove(transaction->id());
-    if (transaction->mode() == IndexedDB::TransactionVersionChange) {
+    if (transaction->mode() == IndexedDB::TransactionMode::VersionChange) {
         ASSERT(transaction.get() == m_runningVersionChangeTransaction.get());
         m_runningVersionChangeTransaction.clear();
     }
@@ -337,7 +337,7 @@ void IDBDatabaseBackend::transactionFinished(IDBTransactionBackend* rawTransacti
 void IDBDatabaseBackend::transactionFinishedAndAbortFired(IDBTransactionBackend* rawTransaction)
 {
     RefPtr<IDBTransactionBackend> transaction = rawTransaction;
-    if (transaction->mode() == IndexedDB::TransactionVersionChange) {
+    if (transaction->mode() == IndexedDB::TransactionMode::VersionChange) {
         // If this was an open-with-version call, there will be a "second
         // half" open call waiting for us in processPendingCalls.
         // FIXME: When we no longer support setVersion, assert such a thing.
@@ -352,7 +352,7 @@ void IDBDatabaseBackend::transactionFinishedAndAbortFired(IDBTransactionBackend*
 void IDBDatabaseBackend::transactionFinishedAndCompleteFired(IDBTransactionBackend* rawTransaction)
 {
     RefPtr<IDBTransactionBackend> transaction = rawTransaction;
-    if (transaction->mode() == IndexedDB::TransactionVersionChange)
+    if (transaction->mode() == IndexedDB::TransactionMode::VersionChange)
         processPendingCalls();
 }
 
@@ -430,9 +430,9 @@ void IDBDatabaseBackend::processPendingOpenCalls(bool success)
     }
 }
 
-void IDBDatabaseBackend::createTransaction(int64_t transactionID, PassRefPtr<IDBDatabaseCallbacks> callbacks, const Vector<int64_t>& objectStoreIDs, unsigned short mode)
+void IDBDatabaseBackend::createTransaction(int64_t transactionID, PassRefPtr<IDBDatabaseCallbacks> callbacks, const Vector<int64_t>& objectStoreIDs, IndexedDB::TransactionMode mode)
 {
-    RefPtr<IDBTransactionBackend> transaction = IDBTransactionBackend::create(this, transactionID, callbacks, objectStoreIDs, static_cast<IndexedDB::TransactionMode>(mode));
+    RefPtr<IDBTransactionBackend> transaction = IDBTransactionBackend::create(this, transactionID, callbacks, objectStoreIDs, mode);
 
     ASSERT(!m_transactions.contains(transactionID));
     m_transactions.add(transactionID, transaction.get());
@@ -501,7 +501,7 @@ void IDBDatabaseBackend::runIntVersionChangeTransaction(PassRefPtr<IDBCallbacks>
     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_metadata.version, requestedVersion, IndexedDB::NullVersion);
+            (*it)->onVersionChange(m_metadata.version, requestedVersion, IndexedDB::VersionNullness::Null);
     }
     // The spec dictates we wait until all the version change events are
     // delivered and then check m_databaseCallbacks.empty() before proceeding
@@ -519,7 +519,7 @@ void IDBDatabaseBackend::runIntVersionChangeTransaction(PassRefPtr<IDBCallbacks>
     }
 
     Vector<int64_t> objectStoreIds;
-    createTransaction(transactionId, databaseCallbacks, objectStoreIds, IndexedDB::TransactionVersionChange);
+    createTransaction(transactionId, databaseCallbacks, objectStoreIds, IndexedDB::TransactionMode::VersionChange);
     RefPtr<IDBTransactionBackend> transaction = m_transactions.get(transactionId);
 
     transaction->scheduleVersionChangeOperation(requestedVersion, callbacks, databaseCallbacks, m_metadata);
@@ -534,7 +534,7 @@ void IDBDatabaseBackend::deleteDatabase(PassRefPtr<IDBCallbacks> prpCallbacks)
     if (isDeleteDatabaseBlocked()) {
         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.
-            (*it)->onVersionChange(m_metadata.version, 0, IndexedDB::NullVersion);
+            (*it)->onVersionChange(m_metadata.version, 0, IndexedDB::VersionNullness::Null);
         }
         // FIXME: Only fire onBlocked if there are open connections after the
         // VersionChangeEvents are received, not just set up to fire.
index e65120e..6815d6c 100644 (file)
@@ -77,7 +77,7 @@ public:
     // IDBDatabaseBackend
     void createObjectStore(int64_t transactionId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement);
     void deleteObjectStore(int64_t transactionId, int64_t objectStoreId);
-    void createTransaction(int64_t transactionId, PassRefPtr<IDBDatabaseCallbacks>, const Vector<int64_t>& objectStoreIds, unsigned short mode);
+    void createTransaction(int64_t transactionId, PassRefPtr<IDBDatabaseCallbacks>, const Vector<int64_t>& objectStoreIds, IndexedDB::TransactionMode);
     void close(PassRefPtr<IDBDatabaseCallbacks>);
 
     void commit(int64_t transactionId);
index d28a57f..7c73d84 100644 (file)
@@ -110,7 +110,7 @@ PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* cont
 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
 {
     LOG(StorageAPI, "IDBFactory::open");
-    return openInternal(context, name, 0, IndexedDB::NullVersion, ec);
+    return openInternal(context, name, 0, IndexedDB::VersionNullness::Null, ec);
 }
 
 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, unsigned long long version, ExceptionCode& ec)
@@ -120,13 +120,13 @@ PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
         ec = TypeError;
         return 0;
     }
-    return openInternal(context, name, version, IndexedDB::NonNullVersion, ec);
+    return openInternal(context, name, version, IndexedDB::VersionNullness::NonNull, ec);
 }
 
 PassRefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* context, const String& name, uint64_t version, IndexedDB::VersionNullness versionNullness, ExceptionCode& ec)
 {
     HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBOpenCall, IDBMethodsMax);
-    ASSERT(version >= 1 || versionNullness == IndexedDB::NullVersion);
+    ASSERT(version >= 1 || versionNullness == IndexedDB::VersionNullness::Null);
     if (name.isNull()) {
         ec = TypeError;
         return 0;
@@ -160,7 +160,7 @@ PassRefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext*
         return 0;
     }
 
-    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, 0, IndexedDB::NullVersion);
+    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, 0, IndexedDB::VersionNullness::Null);
     m_backend->deleteDatabase(name, request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
     return request;
 }
index edf4b39..e6fdf5c 100644 (file)
@@ -70,7 +70,7 @@ PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, Pas
         return 0;
 
     RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
-    request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
+    request->setCursorDetails(IndexedDB::CursorType::KeyAndValue, direction);
     backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, direction, false, IDBDatabaseBackend::NormalTask, request);
     return request;
 }
@@ -125,7 +125,7 @@ PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context,
         return 0;
 
     RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
-    request->setCursorDetails(IndexedDB::CursorKeyOnly, direction);
+    request->setCursorDetails(IndexedDB::CursorType::KeyOnly, direction);
     backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, direction, true, IDBDatabaseBackend::NormalTask, request);
     return request;
 }
index 7867f5e..d42896f 100644 (file)
@@ -528,7 +528,7 @@ PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* contex
         return 0;
 
     RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
-    request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
+    request->setCursorDetails(IndexedDB::CursorType::KeyAndValue, direction);
 
     backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, direction, false, static_cast<IDBDatabaseBackend::TaskType>(taskType), request);
     return request.release();
index cb64433..e929c6c 100644 (file)
@@ -99,7 +99,7 @@ void IDBOpenDBRequest::onUpgradeNeeded(uint64_t oldVersion, PassRefPtr<IDBDataba
     m_transaction = IDBTransaction::create(scriptExecutionContext(), m_transactionId, idbDatabase.get(), this, oldMetadata);
     m_result = IDBAny::create(idbDatabase.release());
 
-    if (m_versionNullness == IndexedDB::NullVersion)
+    if (m_versionNullness == IndexedDB::VersionNullness::Null)
         m_version = 1;
     enqueueEvent(IDBVersionChangeEvent::create(oldVersion, m_version, m_versionNullness, eventNames().upgradeneededEvent));
 }
index d564603..1bc1706 100644 (file)
@@ -78,8 +78,8 @@ IDBRequest::IDBRequest(ScriptExecutionContext* context, PassRefPtr<IDBAny> sourc
     , m_source(source)
     , m_taskType(taskType)
     , m_hasPendingActivity(true)
-    , m_cursorType(IndexedDB::CursorKeyAndValue)
-    , m_cursorDirection(IndexedDB::CursorNext)
+    , m_cursorType(IndexedDB::CursorType::KeyAndValue)
+    , m_cursorDirection(IndexedDB::CursorDirection::Next)
     , m_cursorFinished(false)
     , m_pendingCursor(0)
     , m_didFireUpgradeNeededEvent(false)
@@ -220,7 +220,7 @@ void IDBRequest::setResultCursor(PassRefPtr<IDBCursor> cursor, PassRefPtr<IDBKey
     m_cursorPrimaryKey = primaryKey;
     m_cursorValue = value;
 
-    if (m_cursorType == IndexedDB::CursorKeyOnly) {
+    if (m_cursorType == IndexedDB::CursorType::KeyOnly) {
         m_result = IDBAny::create(cursor);
         return;
     }
@@ -286,10 +286,10 @@ void IDBRequest::onSuccess(PassRefPtr<IDBCursorBackend> backend, PassRefPtr<IDBK
     ASSERT(!m_pendingCursor);
     RefPtr<IDBCursor> cursor;
     switch (m_cursorType) {
-    case IndexedDB::CursorKeyOnly:
+    case IndexedDB::CursorType::KeyOnly:
         cursor = IDBCursor::create(backend, m_cursorDirection, this, m_source.get(), m_transaction.get());
         break;
-    case IndexedDB::CursorKeyAndValue:
+    case IndexedDB::CursorType::KeyAndValue:
         cursor = IDBCursorWithValue::create(backend, m_cursorDirection, this, m_source.get(), m_transaction.get());
         break;
     default:
index bd70004..5d2f3f8 100644 (file)
@@ -54,7 +54,7 @@ PassRefPtr<IDBTransaction> IDBTransaction::create(ScriptExecutionContext* contex
 
 PassRefPtr<IDBTransaction> IDBTransaction::create(ScriptExecutionContext* context, int64_t id, IDBDatabase* db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata)
 {
-    RefPtr<IDBTransaction> transaction(adoptRef(new IDBTransaction(context, id, Vector<String>(), IndexedDB::TransactionVersionChange, db, openDBRequest, previousMetadata)));
+    RefPtr<IDBTransaction> transaction(adoptRef(new IDBTransaction(context, id, Vector<String>(), IndexedDB::TransactionMode::VersionChange, db, openDBRequest, previousMetadata)));
     transaction->suspendIfNeeded();
     return transaction.release();
 }
@@ -102,7 +102,7 @@ IDBTransaction::IDBTransaction(ScriptExecutionContext* context, int64_t id, cons
     , m_contextStopped(false)
     , m_previousMetadata(previousMetadata)
 {
-    if (mode == IndexedDB::TransactionVersionChange) {
+    if (mode == IndexedDB::TransactionMode::VersionChange) {
         // Not active until the callback.
         m_state = Inactive;
     }
@@ -335,26 +335,26 @@ IndexedDB::TransactionMode IDBTransaction::stringToMode(const String& modeString
 {
     if (modeString.isNull()
         || modeString == IDBTransaction::modeReadOnly())
-        return IndexedDB::TransactionReadOnly;
+        return IndexedDB::TransactionMode::ReadOnly;
     if (modeString == IDBTransaction::modeReadWrite())
-        return IndexedDB::TransactionReadWrite;
+        return IndexedDB::TransactionMode::ReadWrite;
 
     ec = TypeError;
-    return IndexedDB::TransactionReadOnly;
+    return IndexedDB::TransactionMode::ReadOnly;
 }
 
 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode)
 {
     switch (mode) {
-    case IndexedDB::TransactionReadOnly:
+    case IndexedDB::TransactionMode::ReadOnly:
         return IDBTransaction::modeReadOnly();
         break;
 
-    case IndexedDB::TransactionReadWrite:
+    case IndexedDB::TransactionMode::ReadWrite:
         return IDBTransaction::modeReadWrite();
         break;
 
-    case IndexedDB::TransactionVersionChange:
+    case IndexedDB::TransactionMode::VersionChange:
         return IDBTransaction::modeVersionChange();
         break;
     }
index 84f440d..94c63f3 100644 (file)
@@ -70,8 +70,8 @@ public:
     int64_t id() const { return m_id; }
     bool isActive() const { return m_state == Active; }
     bool isFinished() const { return m_state == Finished; }
-    bool isReadOnly() const { return m_mode == IndexedDB::TransactionReadOnly; }
-    bool isVersionChange() const { return m_mode == IndexedDB::TransactionVersionChange; }
+    bool isReadOnly() const { return m_mode == IndexedDB::TransactionMode::ReadOnly; }
+    bool isVersionChange() const { return m_mode == IndexedDB::TransactionMode::VersionChange; }
 
     // Implement the IDBTransaction IDL
     const String& mode() const;
index ba43472..841ff7c 100644 (file)
@@ -100,7 +100,7 @@ void GetOperation::perform(std::function<void()> completionCallback)
 void PutOperation::perform(std::function<void()> completionCallback)
 {
     LOG(StorageAPI, "PutOperation");
-    ASSERT(m_transaction->mode() != IndexedDB::TransactionReadOnly);
+    ASSERT(m_transaction->mode() != IndexedDB::TransactionMode::ReadOnly);
     ASSERT(m_indexIDs.size() == m_indexKeys.size());
 
     RefPtr<PutOperation> operation(this);
index f10d9f5..dd4f86f 100644 (file)
@@ -96,7 +96,7 @@ void IDBTransactionCoordinator::processStartedTransactions()
     if (m_queuedTransactions.isEmpty())
         return;
 
-    ASSERT(m_startedTransactions.isEmpty() || (*m_startedTransactions.begin())->mode() != IndexedDB::TransactionVersionChange);
+    ASSERT(m_startedTransactions.isEmpty() || (*m_startedTransactions.begin())->mode() != IndexedDB::TransactionMode::VersionChange);
 
     ListHashSet<IDBTransactionBackend*>::const_iterator it = m_queuedTransactions.begin();
     while (it != m_queuedTransactions.end()) {
@@ -123,22 +123,22 @@ bool IDBTransactionCoordinator::canRunTransaction(IDBTransactionBackend* transac
 {
     ASSERT(m_queuedTransactions.contains(transaction));
     switch (transaction->mode()) {
-    case IndexedDB::TransactionVersionChange:
+    case IndexedDB::TransactionMode::VersionChange:
         ASSERT(m_queuedTransactions.size() == 1);
         ASSERT(m_startedTransactions.isEmpty());
         return true;
 
-    case IndexedDB::TransactionReadOnly:
+    case IndexedDB::TransactionMode::ReadOnly:
         return true;
 
-    case IndexedDB::TransactionReadWrite:
+    case IndexedDB::TransactionMode::ReadWrite:
         for (HashSet<IDBTransactionBackend*>::const_iterator it = m_startedTransactions.begin(); it != m_startedTransactions.end(); ++it) {
-            if ((*it)->mode() == IndexedDB::TransactionReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
+            if ((*it)->mode() == IndexedDB::TransactionMode::ReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
                 return false;
         }
         for (ListHashSet<IDBTransactionBackend*>::const_iterator it = m_queuedTransactions.begin(); *it != transaction; ++it) {
             ASSERT(it != m_queuedTransactions.end());
-            if ((*it)->mode() == IndexedDB::TransactionReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
+            if ((*it)->mode() == IndexedDB::TransactionMode::ReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
                 return false;
         }
         return true;
index 9480ccf..c8d2008 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 
 class IDBVersionChangeEvent : public Event {
 public:
-    static PassRefPtr<IDBVersionChangeEvent> create(unsigned long long oldVersion = 0, unsigned long long newVersion = 0, IndexedDB::VersionNullness newVersionNullness = IndexedDB::NullVersion, const AtomicString& eventType = AtomicString())
+    static PassRefPtr<IDBVersionChangeEvent> create(unsigned long long oldVersion = 0, unsigned long long newVersion = 0, IndexedDB::VersionNullness newVersionNullness = IndexedDB::VersionNullness::Null, const AtomicString& eventType = AtomicString())
     {
         return adoptRef(new IDBVersionChangeEvent(oldVersion, newVersion, newVersionNullness, eventType));
     }
@@ -46,7 +46,7 @@ public:
     virtual ~IDBVersionChangeEvent();
 
     virtual unsigned long long oldVersion() { return m_oldVersion; }
-    virtual unsigned long long newVersion(bool& isNull) { isNull = (m_newVersionNullness == IndexedDB::NullVersion); return m_newVersion; }
+    virtual unsigned long long newVersion(bool& isNull) { isNull = (m_newVersionNullness == IndexedDB::VersionNullness::Null); return m_newVersion; }
 
     virtual EventInterface eventInterface() const;
 
index cb7e8fc..fac3926 100644 (file)
@@ -32,27 +32,30 @@ namespace WebCore {
 
 namespace IndexedDB {
 
-enum TransactionMode {
-    TransactionReadOnly = 0,
-    TransactionReadWrite = 1,
-    TransactionVersionChange = 2
+enum class TransactionMode {
+    ReadOnly = 0,
+    ReadWrite = 1,
+    VersionChange = 2,
 };
+const unsigned TransactionModeMaximum = 2;
 
-enum CursorDirection {
-    CursorNext = 0,
-    CursorNextNoDuplicate = 1,
-    CursorPrev = 2,
-    CursorPrevNoDuplicate = 3,
+enum class CursorDirection {
+    Next = 0,
+    NextNoDuplicate = 1,
+    Prev = 2,
+    PrevNoDuplicate = 3,
 };
+const unsigned CursorDirectionMaximum = 3;
 
-enum CursorType {
-    CursorKeyAndValue = 0,
-    CursorKeyOnly
+enum class CursorType {
+    KeyAndValue = 0,
+    KeyOnly = 1,
 };
+const unsigned CursorTypeMaximum = 1;
 
-enum VersionNullness {
-    NullVersion,
-    NonNullVersion
+enum class VersionNullness {
+    Null,
+    NonNull,
 };
 
 } // namespace IndexedDB
index bff3c93..d436229 100644 (file)
@@ -1765,8 +1765,8 @@ static bool objectStoreCursorOptions(LevelDBTransaction* transaction, int64_t da
 
     bool lowerBound = range && range->lower();
     bool upperBound = range && range->upper();
-    cursorOptions.forward = (direction == IndexedDB::CursorNextNoDuplicate || direction == IndexedDB::CursorNext);
-    cursorOptions.unique = (direction == IndexedDB::CursorNextNoDuplicate || direction == IndexedDB::CursorPrevNoDuplicate);
+    cursorOptions.forward = (direction == IndexedDB::CursorDirection::NextNoDuplicate || direction == IndexedDB::CursorDirection::Next);
+    cursorOptions.unique = (direction == IndexedDB::CursorDirection::NextNoDuplicate || direction == IndexedDB::CursorDirection::PrevNoDuplicate);
 
     if (!lowerBound) {
         cursorOptions.lowKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, minIDBKey());
@@ -1820,8 +1820,8 @@ static bool indexCursorOptions(LevelDBTransaction* transaction, int64_t database
 
     bool lowerBound = range && range->lower();
     bool upperBound = range && range->upper();
-    cursorOptions.forward = (direction == IndexedDB::CursorNextNoDuplicate || direction == IndexedDB::CursorNext);
-    cursorOptions.unique = (direction == IndexedDB::CursorNextNoDuplicate || direction == IndexedDB::CursorPrevNoDuplicate);
+    cursorOptions.forward = (direction == IndexedDB::CursorDirection::NextNoDuplicate || direction == IndexedDB::CursorDirection::Next);
+    cursorOptions.unique = (direction == IndexedDB::CursorDirection::NextNoDuplicate || direction == IndexedDB::CursorDirection::PrevNoDuplicate);
 
     if (!lowerBound) {
         cursorOptions.lowKey = IndexDataKey::encodeMinKey(databaseId, objectStoreId, indexId);
index 77c1708..4eb6f40 100644 (file)
@@ -253,16 +253,16 @@ void IDBServerConnectionLevelDB::get(IDBTransactionBackend& transaction, const G
         int64_t cursorID = m_nextCursorID++;
 
         if (operation.indexID() == IDBIndexMetadata::InvalidId) {
-            ASSERT(operation.cursorType() != IndexedDB::CursorKeyOnly);
+            ASSERT(operation.cursorType() != IndexedDB::CursorType::KeyOnly);
             // ObjectStore Retrieval Operation
-            backingStoreCursor = m_backingStore->openObjectStoreCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.keyRange(), IndexedDB::CursorNext);
+            backingStoreCursor = m_backingStore->openObjectStoreCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.keyRange(), IndexedDB::CursorDirection::Next);
         } else {
-            if (operation.cursorType() == IndexedDB::CursorKeyOnly) {
+            if (operation.cursorType() == IndexedDB::CursorType::KeyOnly) {
                 // Index Value Retrieval Operation
-                backingStoreCursor = m_backingStore->openIndexKeyCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), IndexedDB::CursorNext);
+                backingStoreCursor = m_backingStore->openIndexKeyCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), IndexedDB::CursorDirection::Next);
             } else {
                 // Index Referenced Value Retrieval Operation
-                backingStoreCursor = m_backingStore->openIndexCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), IndexedDB::CursorNext);
+                backingStoreCursor = m_backingStore->openIndexCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), IndexedDB::CursorDirection::Next);
             }
         }
 
@@ -317,7 +317,7 @@ void IDBServerConnectionLevelDB::get(IDBTransactionBackend& transaction, const G
         ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
         return;
     }
-    if (operation.cursorType() == IndexedDB::CursorKeyOnly) {
+    if (operation.cursorType() == IndexedDB::CursorType::KeyOnly) {
         // Index Value Retrieval Operation
         operation.callbacks()->onSuccess(primaryKey.get());
         ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
@@ -442,11 +442,11 @@ void IDBServerConnectionLevelDB::openCursor(IDBTransactionBackend& transaction,
 
     RefPtr<IDBBackingStoreCursorLevelDB> backingStoreCursor;
     if (operation.indexID() == IDBIndexMetadata::InvalidId) {
-        ASSERT(operation.cursorType() != IndexedDB::CursorKeyOnly);
+        ASSERT(operation.cursorType() != IndexedDB::CursorType::KeyOnly);
         backingStoreCursor = m_backingStore->openObjectStoreCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.keyRange(), operation.direction());
     } else {
         ASSERT(operation.taskType() == IDBDatabaseBackend::NormalTask);
-        if (operation.cursorType() == IndexedDB::CursorKeyOnly)
+        if (operation.cursorType() == IndexedDB::CursorType::KeyOnly)
             backingStoreCursor = m_backingStore->openIndexKeyCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), operation.direction());
         else
             backingStoreCursor = m_backingStore->openIndexCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), operation.direction());
@@ -480,9 +480,9 @@ void IDBServerConnectionLevelDB::count(IDBTransactionBackend& transaction, const
     int64_t cursorID = m_nextCursorID++;
 
     if (operation.indexID() == IDBIndexMetadata::InvalidId)
-        backingStoreCursor = m_backingStore->openObjectStoreKeyCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.keyRange(), IndexedDB::CursorNext);
+        backingStoreCursor = m_backingStore->openObjectStoreKeyCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.keyRange(), IndexedDB::CursorDirection::Next);
     else
-        backingStoreCursor = m_backingStore->openIndexKeyCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), IndexedDB::CursorNext);
+        backingStoreCursor = m_backingStore->openIndexKeyCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), operation.keyRange(), IndexedDB::CursorDirection::Next);
     if (!backingStoreCursor) {
         operation.callbacks()->onSuccess(count);
         callOnMainThread([completionCallback]() {
@@ -506,7 +506,7 @@ void IDBServerConnectionLevelDB::deleteRange(IDBTransactionBackend& transaction,
 
     int64_t cursorID = m_nextCursorID++;
 
-    RefPtr<IDBBackingStoreCursorLevelDB> backingStoreCursor = m_backingStore->openObjectStoreCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.keyRange(), IndexedDB::CursorNext);
+    RefPtr<IDBBackingStoreCursorLevelDB> backingStoreCursor = m_backingStore->openObjectStoreCursor(cursorID, *backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.keyRange(), IndexedDB::CursorDirection::Next);
     if (backingStoreCursor) {
         do {
             if (!m_backingStore->deleteRecord(*backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), backingStoreCursor->recordIdentifier())) {
@@ -657,10 +657,10 @@ void IDBServerConnectionLevelDB::cursorPrefetchIteration(IDBCursorBackend& curso
         foundPrimaryKeys.append(backingStoreCursor->primaryKey());
 
         switch (cursor.cursorType()) {
-        case IndexedDB::CursorKeyOnly:
+        case IndexedDB::CursorType::KeyOnly:
             foundValues.append(SharedBuffer::create());
             break;
-        case IndexedDB::CursorKeyAndValue:
+        case IndexedDB::CursorType::KeyAndValue:
             sizeEstimate += backingStoreCursor->value()->size();
             foundValues.append(backingStoreCursor->value());
             break;
index cb5ce73..6250194 100644 (file)
@@ -2923,4 +2923,5 @@ __ZN7WebCore10IDBKeyPathC1ERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowE
 __ZN7WebCore18IDBDatabaseBackend14openConnectionEN3WTF10PassRefPtrINS_12IDBCallbacksEEENS2_INS_20IDBDatabaseCallbacksEEExy
 __ZN7WebCore18IDBDatabaseBackend6createERKN3WTF6StringES4_PNS_26IDBFactoryBackendInterfaceERNS_19IDBServerConnectionE
 __ZN7WebCore18IDBDatabaseBackendD1Ev
+__ZN7WebCore21CrossThreadCopierBaseILb0ELb0ENS_9IndexedDB15TransactionModeEE4copyERKS2_
 #endif
index 65df47d..043ed0f 100644 (file)
@@ -73,6 +73,21 @@ CrossThreadCopierBase<false, false, ResourceResponse>::Type CrossThreadCopierBas
 
 #if ENABLE(INDEXED_DATABASE)
 
+IndexedDB::TransactionMode CrossThreadCopierBase<false, false, IndexedDB::TransactionMode>::copy(const IndexedDB::TransactionMode& mode)
+{
+    return mode;
+}
+
+IndexedDB::CursorDirection CrossThreadCopierBase<false, false, IndexedDB::CursorDirection>::copy(const IndexedDB::CursorDirection& direction)
+{
+    return direction;
+}
+
+IndexedDB::CursorType CrossThreadCopierBase<false, false, IndexedDB::CursorType>::copy(const IndexedDB::CursorType& type)
+{
+    return type;
+}
+
 CrossThreadCopierBase<false, false, IDBDatabaseMetadata>::Type CrossThreadCopierBase<false, false, IDBDatabaseMetadata>::copy(const IDBDatabaseMetadata& metadata)
 {
     return metadata.isolatedCopy();
index f4c93d5..0fb069c 100644 (file)
@@ -146,6 +146,21 @@ namespace WebCore {
     };
 
 #if ENABLE(INDEXED_DATABASE)
+    namespace IndexedDB {
+        enum class TransactionMode;
+        enum class CursorDirection;
+        enum class CursorType;
+    }
+    template<> struct CrossThreadCopierBase<false, false, IndexedDB::TransactionMode> {
+        static IndexedDB::TransactionMode copy(const IndexedDB::TransactionMode&);
+    };
+    template<> struct CrossThreadCopierBase<false, false, IndexedDB::CursorDirection> {
+        static IndexedDB::CursorDirection copy(const IndexedDB::CursorDirection&);
+    };
+    template<> struct CrossThreadCopierBase<false, false, IndexedDB::CursorType> {
+        static IndexedDB::CursorType copy(const IndexedDB::CursorType&);
+    };
+
     struct IDBDatabaseMetadata;
     template<> struct CrossThreadCopierBase<false, false, IDBDatabaseMetadata> {
         typedef IDBDatabaseMetadata Type;
index aeef332..0c8aa95 100644 (file)
@@ -1,3 +1,58 @@
+2013-12-17  Brady Eidson  <beidson@apple.com>
+
+        DatabaseProcess: Pipe through object store IDs and transaction mode for "openTransaction"
+        https://bugs.webkit.org/show_bug.cgi?id=125872
+
+        Reviewed by Alexey Proskuryakov.
+
+        Pipe through the objectStoreIDs and mode:
+        * DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
+        (WebKit::DatabaseProcessIDBConnection::openTransaction):
+        * DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h:
+        * DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in:
+
+        Rework postTransactionOperation to take a pre-made AsyncTask to allow for different
+        transaction operation function signatures:
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+        (WebKit::UniqueIDBDatabase::openTransaction): Pipe through the objectStoreIDs and mode:
+        (WebKit::UniqueIDBDatabase::beginTransaction):
+        (WebKit::UniqueIDBDatabase::commitTransaction):
+        (WebKit::UniqueIDBDatabase::resetTransaction):
+        (WebKit::UniqueIDBDatabase::rollbackTransaction):
+        (WebKit::UniqueIDBDatabase::postTransactionOperation):
+        (WebKit::UniqueIDBDatabase::openBackingStoreTransaction):
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:
+
+        Pipe through the objectStoreIDs and mode:
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::establishTransaction):
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:
+
+        * Platform/Logging.h: Add an IDB logging channel.
+
+        * Shared/AsyncTask.h:
+        (WebKit::createAsyncTask): Add a 3-argument variant.
+
+        * Shared/WebCrossThreadCopier.cpp:
+        (WebCore::::copy): Add a Vector<int64_t> copier.
+        * Shared/WebCrossThreadCopier.h:
+
+        Add logging throughout currently implemented methods:
+        * WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp:
+        (WebKit::WebIDBServerConnection::getOrEstablishIDBDatabaseMetadata):
+        (WebKit::WebIDBServerConnection::didGetOrEstablishIDBDatabaseMetadata):
+        (WebKit::WebIDBServerConnection::openTransaction): Pipe through the objectStoreIDs and mode.
+        (WebKit::WebIDBServerConnection::didOpenTransaction):
+        (WebKit::WebIDBServerConnection::beginTransaction):
+        (WebKit::WebIDBServerConnection::didBeginTransaction):
+        (WebKit::WebIDBServerConnection::commitTransaction):
+        (WebKit::WebIDBServerConnection::didCommitTransaction):
+        (WebKit::WebIDBServerConnection::resetTransaction):
+        (WebKit::WebIDBServerConnection::didResetTransaction):
+        (WebKit::WebIDBServerConnection::rollbackTransaction):
+        (WebKit::WebIDBServerConnection::didRollbackTransaction):
+
 2013-12-17  Gavin Barraclough  <barraclough@apple.com>
 
         Remove PageVisibilityStateUnloaded
index 08b24ad..97713f5 100644 (file)
@@ -35,6 +35,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebIDBServerConnectionMessages.h"
 #include <WebCore/IDBDatabaseMetadata.h>
+#include <WebCore/IndexedDB.h>
 
 using namespace WebCore;
 
@@ -73,12 +74,18 @@ void DatabaseProcessIDBConnection::getOrEstablishIDBDatabaseMetadata(uint64_t re
     });
 }
 
-void DatabaseProcessIDBConnection::openTransaction(uint64_t requestID, int64_t transactionID, int64_t)
+void DatabaseProcessIDBConnection::openTransaction(uint64_t requestID, int64_t transactionID, const Vector<int64_t>& objectStoreIDs, uint64_t intMode)
 {
     ASSERT(m_uniqueIDBDatabase);
 
+    if (intMode > IndexedDB::TransactionModeMaximum) {
+        send(Messages::WebIDBServerConnection::DidOpenTransaction(requestID, false));
+        return;
+    }
+
+    IndexedDB::TransactionMode mode = static_cast<IndexedDB::TransactionMode>(intMode);
     RefPtr<DatabaseProcessIDBConnection> connection(this);
-    m_uniqueIDBDatabase->openTransaction(IDBTransactionIdentifier(*this, transactionID), [connection, requestID](bool success) {
+    m_uniqueIDBDatabase->openTransaction(IDBTransactionIdentifier(*this, transactionID), objectStoreIDs, mode, [connection, requestID](bool success) {
         connection->send(Messages::WebIDBServerConnection::DidOpenTransaction(requestID, success));
     });
 }
index 562296d..a283063 100644 (file)
@@ -63,7 +63,7 @@ private:
     // Message handlers.
     void establishConnection(const String& databaseName, const SecurityOriginData& openingOrigin, const SecurityOriginData& mainFrameOrigin);
     void getOrEstablishIDBDatabaseMetadata(uint64_t requestID);
-    void openTransaction(uint64_t requestID, int64_t transactionID, int64_t transactionMode);
+    void openTransaction(uint64_t requestID, int64_t transactionID, const Vector<int64_t>& objectStoreIDs, uint64_t transactionMode);
     void beginTransaction(uint64_t requestID, int64_t transactionID);
     void commitTransaction(uint64_t requestID, int64_t transactionID);
     void resetTransaction(uint64_t requestID, int64_t transactionID);
index cbe3955..0b8e16d 100644 (file)
@@ -26,7 +26,7 @@ messages -> DatabaseProcessIDBConnection LegacyReceiver {
     EstablishConnection(String databaseName, WebKit::SecurityOriginData openingOrigin, WebKit::SecurityOriginData mainFrameOrigin)
     GetOrEstablishIDBDatabaseMetadata(uint64_t requestID)
 
-    OpenTransaction(uint64_t requestID, int64_t transactionID, int64_t transactionMode)
+    OpenTransaction(uint64_t requestID, int64_t transactionID, Vector<int64_t> objectStoreIDs, uint64_t transactionMode)
     BeginTransaction(uint64_t requestID, int64_t transactionID)
     CommitTransaction(uint64_t requestID, int64_t transactionID)
     ResetTransaction(uint64_t requestID, int64_t transactionID)
index 2257db8..2ed7a3c 100644 (file)
@@ -196,32 +196,32 @@ void UniqueIDBDatabase::didOpenBackingStoreAndReadMetadata(const IDBDatabaseMeta
     }
 }
 
-void UniqueIDBDatabase::openTransaction(const IDBTransactionIdentifier& identifier, std::function<void(bool)> successCallback)
+void UniqueIDBDatabase::openTransaction(const IDBTransactionIdentifier& identifier, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode mode, std::function<void(bool)> successCallback)
 {
-    postTransactionOperation(&UniqueIDBDatabase::openBackingStoreTransaction, identifier, successCallback);
+    postTransactionOperation(identifier, createAsyncTask(*this, &UniqueIDBDatabase::openBackingStoreTransaction, identifier, objectStoreIDs, mode), successCallback);
 }
 
 void UniqueIDBDatabase::beginTransaction(const IDBTransactionIdentifier& identifier, std::function<void(bool)> successCallback)
 {
-    postTransactionOperation(&UniqueIDBDatabase::beginBackingStoreTransaction, identifier, successCallback);
+    postTransactionOperation(identifier, createAsyncTask(*this, &UniqueIDBDatabase::beginBackingStoreTransaction, identifier), successCallback);
 }
 
 void UniqueIDBDatabase::commitTransaction(const IDBTransactionIdentifier& identifier, std::function<void(bool)> successCallback)
 {
-    postTransactionOperation(&UniqueIDBDatabase::commitBackingStoreTransaction, identifier, successCallback);
+    postTransactionOperation(identifier, createAsyncTask(*this, &UniqueIDBDatabase::commitBackingStoreTransaction, identifier), successCallback);
 }
 
 void UniqueIDBDatabase::resetTransaction(const IDBTransactionIdentifier& identifier, std::function<void(bool)> successCallback)
 {
-    postTransactionOperation(&UniqueIDBDatabase::resetBackingStoreTransaction, identifier, successCallback);
+    postTransactionOperation(identifier, createAsyncTask(*this, &UniqueIDBDatabase::resetBackingStoreTransaction, identifier), successCallback);
 }
 
 void UniqueIDBDatabase::rollbackTransaction(const IDBTransactionIdentifier& identifier, std::function<void(bool)> successCallback)
 {
-    postTransactionOperation(&UniqueIDBDatabase::rollbackBackingStoreTransaction, identifier, successCallback);
+    postTransactionOperation(identifier, createAsyncTask(*this, &UniqueIDBDatabase::rollbackBackingStoreTransaction, identifier), successCallback);
 }
 
-void UniqueIDBDatabase::postTransactionOperation(TransactionOperationFunction function, const IDBTransactionIdentifier& identifier, std::function<void(bool)> successCallback)
+void UniqueIDBDatabase::postTransactionOperation(const IDBTransactionIdentifier& identifier, std::unique_ptr<AsyncTask> task, std::function<void(bool)> successCallback)
 {
     ASSERT(isMainThread());
 
@@ -236,7 +236,7 @@ void UniqueIDBDatabase::postTransactionOperation(TransactionOperationFunction fu
         return;
     }
 
-    postDatabaseTask(createAsyncTask(*this, function, identifier));
+    postDatabaseTask(std::move(task));
 
     RefPtr<AsyncRequest> request = AsyncRequestImpl<bool>::create([successCallback](bool success) {
         successCallback(success);
@@ -258,12 +258,12 @@ void UniqueIDBDatabase::didCompleteTransactionOperation(const IDBTransactionIden
     request->completeRequest(success);
 }
 
-void UniqueIDBDatabase::openBackingStoreTransaction(const IDBTransactionIdentifier& identifier)
+void UniqueIDBDatabase::openBackingStoreTransaction(const IDBTransactionIdentifier& identifier, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode mode)
 {
     ASSERT(!isMainThread());
     ASSERT(m_backingStore);
 
-    bool success = m_backingStore->establishTransaction(identifier);
+    bool success = m_backingStore->establishTransaction(identifier, objectStoreIDs, mode);
 
     postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didCompleteTransactionOperation, identifier, success));
 }
index 333da23..aa8cfb1 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "IDBTransactionIdentifier.h"
 #include "UniqueIDBDatabaseIdentifier.h"
+#include <WebCore/IndexedDB.h>
 #include <functional>
 #include <wtf/Deque.h>
 #include <wtf/HashSet.h>
@@ -66,7 +67,7 @@ public:
 
     void getOrEstablishIDBDatabaseMetadata(std::function<void(bool, const WebCore::IDBDatabaseMetadata&)> completionCallback);
 
-    void openTransaction(const IDBTransactionIdentifier&, std::function<void(bool)> successCallback);
+    void openTransaction(const IDBTransactionIdentifier&, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode, std::function<void(bool)> successCallback);
     void beginTransaction(const IDBTransactionIdentifier&, std::function<void(bool)> successCallback);
     void commitTransaction(const IDBTransactionIdentifier&, std::function<void(bool)> successCallback);
     void resetTransaction(const IDBTransactionIdentifier&, std::function<void(bool)> successCallback);
@@ -97,14 +98,13 @@ private:
     // Returns true if this origin can use the same databases as the given origin.
     bool canShareDatabases(const SecurityOriginData&, const SecurityOriginData&) const;
 
-    typedef void (UniqueIDBDatabase::*TransactionOperationFunction)(const IDBTransactionIdentifier&);
-    void postTransactionOperation(TransactionOperationFunction, const IDBTransactionIdentifier&, std::function<void(bool)> successCallback);
+    void postTransactionOperation(const IDBTransactionIdentifier&, std::unique_ptr<AsyncTask>, std::function<void(bool)> successCallback);
     
     // To be called from the database workqueue thread only
     void performNextDatabaseTask();
     void postMainThreadTask(std::unique_ptr<AsyncTask>);
     void openBackingStoreAndReadMetadata(const UniqueIDBDatabaseIdentifier&, const String& databaseDirectory);
-    void openBackingStoreTransaction(const IDBTransactionIdentifier&);
+    void openBackingStoreTransaction(const IDBTransactionIdentifier&, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode);
     void beginBackingStoreTransaction(const IDBTransactionIdentifier&);
     void commitBackingStoreTransaction(const IDBTransactionIdentifier&);
     void resetBackingStoreTransaction(const IDBTransactionIdentifier&);
index c9b0722..9297e14 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
 
+#include <WebCore/IndexedDB.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
@@ -44,7 +45,7 @@ public:
 
     virtual std::unique_ptr<WebCore::IDBDatabaseMetadata> getOrEstablishMetadata() = 0;
 
-    virtual bool establishTransaction(const IDBTransactionIdentifier&) = 0;
+    virtual bool establishTransaction(const IDBTransactionIdentifier&, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode) = 0;
     virtual bool beginTransaction(const IDBTransactionIdentifier&) = 0;
     virtual bool commitTransaction(const IDBTransactionIdentifier&) = 0;
     virtual bool resetTransaction(const IDBTransactionIdentifier&) = 0;
index 5afde37..72d83f5 100644 (file)
@@ -193,10 +193,10 @@ std::unique_ptr<IDBDatabaseMetadata> UniqueIDBDatabaseBackingStoreSQLite::getOrE
     return metadata;
 }
 
-bool UniqueIDBDatabaseBackingStoreSQLite::establishTransaction(const IDBTransactionIdentifier& identifier)
+bool UniqueIDBDatabaseBackingStoreSQLite::establishTransaction(const IDBTransactionIdentifier& identifier, const Vector<int64_t>&, WebCore::IndexedDB::TransactionMode)
 {
     ASSERT(!isMainThread());
-    
+
     if (!m_transactions.add(identifier, SQLiteIDBTransaction::create(identifier)).isNewEntry) {
         LOG_ERROR("Attempt to establish transaction identifier that already exists");
         return false;
index 56264cd..4efd3d0 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     virtual std::unique_ptr<WebCore::IDBDatabaseMetadata> getOrEstablishMetadata() OVERRIDE;
 
-    virtual bool establishTransaction(const IDBTransactionIdentifier&) OVERRIDE;
+    virtual bool establishTransaction(const IDBTransactionIdentifier&, const Vector<int64_t>& objectStoreIDs, WebCore::IndexedDB::TransactionMode) OVERRIDE;
     virtual bool beginTransaction(const IDBTransactionIdentifier&) OVERRIDE;
     virtual bool commitTransaction(const IDBTransactionIdentifier&) OVERRIDE;
     virtual bool resetTransaction(const IDBTransactionIdentifier&) OVERRIDE;
index 586f216..1d0b349 100644 (file)
@@ -50,6 +50,7 @@ namespace WebKit {
     M(StorageAPI) \
     M(TextInput) \
     M(View) \
+    M(IDB) \
 
 #define DECLARE_LOG_CHANNEL(name) \
     extern WTFLogChannel JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, name);
index 5c2064c..3578701 100644 (file)
@@ -100,6 +100,22 @@ std::unique_ptr<AsyncTask> createAsyncTask(
 
 }
 
+template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3>
+std::unique_ptr<AsyncTask> createAsyncTask(
+    T& callee,
+    void (T::*method)(MP1, MP2, MP3),
+    const P1& parameter1,
+    const P2& parameter2,
+    const P3& parameter3)
+{
+    return std::make_unique<AsyncTaskImpl<T, MP1, MP2, MP3>>(
+        &callee,
+        method,
+        WebCore::CrossThreadCopier<P1>::copy(parameter1),
+        WebCore::CrossThreadCopier<P2>::copy(parameter2),
+        WebCore::CrossThreadCopier<P3>::copy(parameter3));
+}
+
 } // namespace WebKit
 
 #endif // AsyncTask_h
index d6c9c7f..5c33c28 100644 (file)
@@ -44,6 +44,13 @@ IDBTransactionIdentifier CrossThreadCopierBase<false, false, IDBTransactionIdent
     return identifier.isolatedCopy();
 }
 
+Vector<int64_t> CrossThreadCopierBase<false, false, Vector<int64_t>>::copy(const Vector<int64_t>& vector)
+{
+    Vector<int64_t> result;
+    result.appendVector(vector);
+    return result;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
index 987cdd1..b12038f 100644 (file)
@@ -27,6 +27,7 @@
 #define WebCrossThreadCopier_h
 
 #include <WebCore/CrossThreadCopier.h>
+#include <wtf/Vector.h>
 
 #if ENABLE(INDEXED_DATABASE)
 
@@ -45,6 +46,10 @@ template<> struct CrossThreadCopierBase<false, false, WebKit::IDBTransactionIden
     static WebKit::IDBTransactionIdentifier copy(const WebKit::IDBTransactionIdentifier&);
 };
 
+template<> struct CrossThreadCopierBase<false, false, Vector<int64_t>> {
+    static Vector<int64_t> copy(const Vector<int64_t>&);
+};
+
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
index 7678299..2cb2abe 100644 (file)
@@ -32,6 +32,7 @@
 #include "AsyncRequest.h"
 #include "DatabaseProcessIDBConnectionMessages.h"
 #include "DatabaseToWebProcessConnectionMessages.h"
+#include "Logging.h"
 #include "SecurityOriginData.h"
 #include "WebProcess.h"
 #include "WebToDatabaseProcessConnection.h"
@@ -95,11 +96,15 @@ void WebIDBServerConnection::getOrEstablishIDBDatabaseMetadata(GetIDBDatabaseMet
     ASSERT(!m_serverRequests.contains(requestID));
     m_serverRequests.add(requestID, serverRequest.release());
 
+    LOG(IDB, "WebProcess getOrEstablishIDBDatabaseMetadata request ID %llu", requestID);
+
     send(Messages::DatabaseProcessIDBConnection::GetOrEstablishIDBDatabaseMetadata(requestID));
 }
 
 void WebIDBServerConnection::didGetOrEstablishIDBDatabaseMetadata(uint64_t requestID, bool success, const IDBDatabaseMetadata& metadata)
 {
+    LOG(IDB, "WebProcess didGetOrEstablishIDBDatabaseMetadata request ID %llu", requestID);
+
     RefPtr<AsyncRequest> serverRequest = m_serverRequests.take(requestID);
 
     if (!serverRequest)
@@ -112,7 +117,7 @@ void WebIDBServerConnection::close()
 {
 }
 
-void WebIDBServerConnection::openTransaction(int64_t transactionID, const HashSet<int64_t>&, IndexedDB::TransactionMode mode, BoolCallbackFunction successCallback)
+void WebIDBServerConnection::openTransaction(int64_t transactionID, const HashSet<int64_t>& objectStoreIDs, IndexedDB::TransactionMode mode, BoolCallbackFunction successCallback)
 {
     RefPtr<AsyncRequest> serverRequest = AsyncRequestImpl<bool>::create(successCallback);
 
@@ -124,11 +129,17 @@ void WebIDBServerConnection::openTransaction(int64_t transactionID, const HashSe
     ASSERT(!m_serverRequests.contains(requestID));
     m_serverRequests.add(requestID, serverRequest.release());
 
-    send(Messages::DatabaseProcessIDBConnection::OpenTransaction(requestID, transactionID, mode));
+    LOG(IDB, "WebProcess openTransaction ID %lli (request ID %llu)", transactionID, requestID);
+
+    Vector<int64_t> objectStoreIDVector;
+    copyToVector(objectStoreIDs, objectStoreIDVector);
+    send(Messages::DatabaseProcessIDBConnection::OpenTransaction(requestID, transactionID, objectStoreIDVector, static_cast<uint64_t>(mode)));
 }
 
 void WebIDBServerConnection::didOpenTransaction(uint64_t requestID, bool success)
 {
+    LOG(IDB, "WebProcess didOpenTransaction request ID %llu", requestID);
+
     RefPtr<AsyncRequest> serverRequest = m_serverRequests.take(requestID);
 
     if (!serverRequest)
@@ -145,11 +156,15 @@ void WebIDBServerConnection::beginTransaction(int64_t transactionID, std::functi
     ASSERT(!m_serverRequests.contains(requestID));
     m_serverRequests.add(requestID, serverRequest.release());
 
+    LOG(IDB, "WebProcess beginTransaction ID %lli (request ID %llu)", transactionID, requestID);
+
     send(Messages::DatabaseProcessIDBConnection::BeginTransaction(requestID, transactionID));
 }
 
 void WebIDBServerConnection::didBeginTransaction(uint64_t requestID, bool)
 {
+    LOG(IDB, "WebProcess didBeginTransaction request ID %llu", requestID);
+
     RefPtr<AsyncRequest> serverRequest = m_serverRequests.take(requestID);
 
     if (!serverRequest)
@@ -170,11 +185,15 @@ void WebIDBServerConnection::commitTransaction(int64_t transactionID, BoolCallba
     ASSERT(!m_serverRequests.contains(requestID));
     m_serverRequests.add(requestID, serverRequest.release());
 
+    LOG(IDB, "WebProcess commitTransaction ID %lli (request ID %llu)", transactionID, requestID);
+
     send(Messages::DatabaseProcessIDBConnection::CommitTransaction(requestID, transactionID));
 }
 
 void WebIDBServerConnection::didCommitTransaction(uint64_t requestID, bool success)
 {
+    LOG(IDB, "WebProcess didCommitTransaction request ID %llu", requestID);
+
     RefPtr<AsyncRequest> serverRequest = m_serverRequests.take(requestID);
 
     if (!serverRequest)
@@ -191,11 +210,15 @@ void WebIDBServerConnection::resetTransaction(int64_t transactionID, std::functi
     ASSERT(!m_serverRequests.contains(requestID));
     m_serverRequests.add(requestID, serverRequest.release());
 
+    LOG(IDB, "WebProcess resetTransaction ID %lli (request ID %llu)", transactionID, requestID);
+
     send(Messages::DatabaseProcessIDBConnection::ResetTransaction(requestID, transactionID));
 }
 
 void WebIDBServerConnection::didResetTransaction(uint64_t requestID, bool)
 {
+    LOG(IDB, "WebProcess didResetTransaction request ID %llu", requestID);
+
     RefPtr<AsyncRequest> serverRequest = m_serverRequests.take(requestID);
 
     if (!serverRequest)
@@ -212,11 +235,15 @@ void WebIDBServerConnection::rollbackTransaction(int64_t transactionID, std::fun
     ASSERT(!m_serverRequests.contains(requestID));
     m_serverRequests.add(requestID, serverRequest.release());
 
+    LOG(IDB, "WebProcess rollbackTransaction ID %lli (request ID %llu)", transactionID, requestID);
+
     send(Messages::DatabaseProcessIDBConnection::RollbackTransaction(requestID, transactionID));
 }
 
 void WebIDBServerConnection::didRollbackTransaction(uint64_t requestID, bool)
 {
+    LOG(IDB, "WebProcess didRollbackTransaction request ID %llu", requestID);
+
     RefPtr<AsyncRequest> serverRequest = m_serverRequests.take(requestID);
 
     if (!serverRequest)