Source/WebCore: IDB: Support IDBObjectStore.clear()
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jan 2014 05:45:09 +0000 (05:45 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jan 2014 05:45:09 +0000 (05:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127541

Reviewed by Anders Carlsson.

The backing store should never be performing callbacks directly:
* Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
(WebCore::IDBServerConnectionLevelDB::clearObjectStore):

Instead, the transaction operations should do that themselves:
* Modules/indexeddb/IDBTransactionBackendOperations.cpp:
(WebCore::ClearObjectStoreOperation::perform):
* Modules/indexeddb/IDBTransactionBackendOperations.h:
(WebCore::ClearObjectStoreOperation::transaction):

Source/WebKit2: IDB: Support IDBObjectStore.clear()
https://bugs.webkit.org/show_bug.cgi?id=127541

Reviewed by Anders Carlsson.

Make the WebProcess call out to the DatabaseProcess with a clear request, and handle the
response from the DatabaseProcess:
* WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp:
(WebKit::WebIDBServerConnection::clearObjectStore):
(WebKit::WebIDBServerConnection::didClearObjectStore):
* WebProcess/Databases/IndexedDB/WebIDBServerConnection.h:
* WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in:

Pass the clear request to the appropriate UniqueIDBDatabase:
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
(WebKit::DatabaseProcessIDBConnection::clearObjectStore):
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h:
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in:

Pass the clear request to the backing store:
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::didClearObjectStore):
(WebKit::UniqueIDBDatabase::clearObjectStore):
(WebKit::UniqueIDBDatabase::clearObjectStoreInBackingStore):
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:

Actually drop the records in the database:
* DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::clearObjectStore):
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.h
Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp
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/WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.h
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in

index b2c934b..1189e55 100644 (file)
@@ -1,3 +1,20 @@
+2014-01-23  Brady Eidson  <beidson@apple.com>
+
+        IDB: Support IDBObjectStore.clear()
+        https://bugs.webkit.org/show_bug.cgi?id=127541
+        
+        Reviewed by Anders Carlsson.
+
+        The backing store should never be performing callbacks directly:
+        * Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
+        (WebCore::IDBServerConnectionLevelDB::clearObjectStore):
+
+        Instead, the transaction operations should do that themselves:
+        * Modules/indexeddb/IDBTransactionBackendOperations.cpp:
+        (WebCore::ClearObjectStoreOperation::perform):
+        * Modules/indexeddb/IDBTransactionBackendOperations.h:
+        (WebCore::ClearObjectStoreOperation::transaction):
+
 2014-01-23  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/15875326> REGRESSION (r162257): Assertion failure (should not be reached) in CSSPreloadScanner::tokenize()
index cefe4c0..4a6f12c 100644 (file)
@@ -184,9 +184,20 @@ void ClearObjectStoreOperation::perform(std::function<void()> completionCallback
     LOG(StorageAPI, "ClearObjectStoreOperation");
 
     RefPtr<ClearObjectStoreOperation> operation(this);
-    STANDARD_DATABASE_ERROR_CALLBACK;
 
-    m_transaction->database().serverConnection().clearObjectStore(*m_transaction, *this, operationCallback);
+    auto clearCallback = [this, operation, completionCallback](PassRefPtr<IDBDatabaseError> prpError) {
+        RefPtr<IDBDatabaseError> error = prpError;
+
+        if (error) {
+            m_callbacks->onError(error);
+            m_transaction->abort(error.release());
+        } else
+            m_callbacks->onSuccess();
+
+        completionCallback();
+    };
+
+    m_transaction->database().serverConnection().clearObjectStore(*m_transaction, *this, clearCallback);
 }
 
 void DeleteObjectStoreOperation::perform(std::function<void()> completionCallback)
index d10b73e..53431a8 100644 (file)
@@ -451,8 +451,8 @@ public:
     }
     virtual void perform(std::function<void()> successCallback) override final;
 
+    IDBTransactionBackend* transaction() const { return m_transaction.get(); }
     int64_t objectStoreID() const { return m_objectStoreID; }
-    IDBCallbacks* callbacks() const { return m_callbacks.get(); }
 
 private:
     ClearObjectStoreOperation(IDBTransactionBackend* transaction, int64_t objectStoreId, PassRefPtr<IDBCallbacks> callbacks)
index 6028df4..f7b37d8 100644 (file)
@@ -532,13 +532,12 @@ void IDBServerConnectionLevelDB::clearObjectStore(IDBTransactionBackend& transac
     ASSERT(backingStoreTransaction);
 
     if (!m_backingStore->clearObjectStore(*backingStoreTransaction, transaction.database().id(), operation.objectStoreID())) {
-        operation.callbacks()->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Error clearing object store"));
         callOnMainThread([completionCallback]() {
-            completionCallback(0);
+            completionCallback(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Error clearing object store"));
         });
         return;
     }
-    operation.callbacks()->onSuccess();
+
     ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
 }
 
index e89b725..c9e4373 100644 (file)
@@ -1,3 +1,37 @@
+2014-01-23  Brady Eidson  <beidson@apple.com>
+
+        IDB: Support IDBObjectStore.clear()
+        https://bugs.webkit.org/show_bug.cgi?id=127541
+
+        Reviewed by Anders Carlsson.
+
+        Make the WebProcess call out to the DatabaseProcess with a clear request, and handle the
+        response from the DatabaseProcess:
+        * WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp:
+        (WebKit::WebIDBServerConnection::clearObjectStore):
+        (WebKit::WebIDBServerConnection::didClearObjectStore):
+        * WebProcess/Databases/IndexedDB/WebIDBServerConnection.h:
+        * WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in:
+
+        Pass the clear request to the appropriate UniqueIDBDatabase:
+        * DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
+        (WebKit::DatabaseProcessIDBConnection::clearObjectStore):
+        * DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h:
+        * DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in:
+
+        Pass the clear request to the backing store:
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+        (WebKit::UniqueIDBDatabase::didClearObjectStore):
+        (WebKit::UniqueIDBDatabase::clearObjectStore):
+        (WebKit::UniqueIDBDatabase::clearObjectStoreInBackingStore):
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:
+
+        Actually drop the records in the database:
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::clearObjectStore):
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:
+
 2014-01-23  Anders Carlsson  <andersca@apple.com>
 
         Fix crash when opening the inspector
index bb5fc7a..41b6b51 100644 (file)
@@ -178,6 +178,17 @@ void DatabaseProcessIDBConnection::deleteObjectStore(uint64_t requestID, int64_t
     });
 }
 
+void DatabaseProcessIDBConnection::clearObjectStore(uint64_t requestID, int64_t transactionID, int64_t objectStoreID)
+{
+    ASSERT(m_uniqueIDBDatabase);
+
+    LOG(IDB, "DatabaseProcess clearObjectStore request ID %llu, object store id %lli", requestID, objectStoreID);
+    RefPtr<DatabaseProcessIDBConnection> connection(this);
+    m_uniqueIDBDatabase->clearObjectStore(IDBTransactionIdentifier(*this, transactionID), objectStoreID, [connection, requestID](bool success) {
+        connection->send(Messages::WebIDBServerConnection::DidClearObjectStore(requestID, success));
+    });
+}
+
 void DatabaseProcessIDBConnection::putRecord(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, const WebCore::IDBKeyData& key, const IPC::DataReference& value, int64_t putMode, const Vector<int64_t>& indexIDs, const Vector<Vector<WebCore::IDBKeyData>>& indexKeys)
 {
     ASSERT(m_uniqueIDBDatabase);
index 36b4c6b..742b725 100644 (file)
@@ -76,6 +76,7 @@ private:
     void changeDatabaseVersion(uint64_t requestID, int64_t transactionID, uint64_t newVersion);
     void createObjectStore(uint64_t requestID, int64_t transactionID, WebCore::IDBObjectStoreMetadata);
     void deleteObjectStore(uint64_t requestID, int64_t transactionID, int64_t objectStoreID);
+    void clearObjectStore(uint64_t requestID, int64_t transactionID, int64_t objectStoreID);
     void putRecord(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, const WebCore::IDBKeyData&, const IPC::DataReference& value, int64_t putMode, const Vector<int64_t>& indexIDs, const Vector<Vector<WebCore::IDBKeyData>>& indexKeys);
     void getRecord(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&, int64_t cursorType);
 
index 1513efe..1196a27 100644 (file)
@@ -35,6 +35,7 @@ messages -> DatabaseProcessIDBConnection LegacyReceiver {
     ChangeDatabaseVersion(uint64_t requestID, int64_t transactionID, uint64_t newVersion)
     CreateObjectStore(uint64_t requestID, int64_t transactionID, WebCore::IDBObjectStoreMetadata objectStoreMetadata)
     DeleteObjectStore(uint64_t requestID, int64_t transactionID, int64_t objectStoreID)
+    ClearObjectStore(uint64_t requestID, int64_t transactionID, int64_t objectStoreID);
     PutRecord(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, WebCore::IDBKeyData key, IPC::DataReference value, int64_t putMode, Vector<int64_t> indexIDs, Vector<Vector<WebCore::IDBKeyData>> indexKeys)
     GetRecord(uint64_t requestID, int64_t transactionID, int64_t objectStoreID, int64_t indexID, WebCore::IDBKeyRangeData keyRange, int64_t cursorType);
 }
index 7da2d6d..64d7f7b 100644 (file)
@@ -332,6 +332,11 @@ void UniqueIDBDatabase::didDeleteObjectStore(uint64_t requestID, bool success)
     didCompleteBoolRequest(requestID, success);
 }
 
+void UniqueIDBDatabase::didClearObjectStore(uint64_t requestID, bool success)
+{
+    didCompleteBoolRequest(requestID, success);
+}
+
 void UniqueIDBDatabase::didCompleteBoolRequest(uint64_t requestID, bool success)
 {
     RefPtr<AsyncRequest> request = m_pendingDatabaseTasks.take(requestID);
@@ -395,6 +400,29 @@ void UniqueIDBDatabase::deleteObjectStore(const IDBTransactionIdentifier& identi
     postDatabaseTask(createAsyncTask(*this, &UniqueIDBDatabase::deleteObjectStoreInBackingStore, requestID, identifier, objectStoreID));
 }
 
+void UniqueIDBDatabase::clearObjectStore(const IDBTransactionIdentifier& identifier, int64_t objectStoreID, std::function<void(bool)> successCallback)
+{
+    ASSERT(isMainThread());
+
+    if (!m_acceptingNewRequests) {
+        successCallback(false);
+        return;
+    }
+
+    ASSERT(m_metadata->objectStores.contains(objectStoreID));
+
+    RefPtr<AsyncRequest> request = AsyncRequestImpl<bool>::create([this, successCallback](bool success) {
+        successCallback(success);
+    }, [this, successCallback]() {
+        successCallback(false);
+    });
+
+    uint64_t requestID = request->requestID();
+    m_pendingDatabaseTasks.add(requestID, request.release());
+
+    postDatabaseTask(createAsyncTask(*this, &UniqueIDBDatabase::clearObjectStoreInBackingStore, requestID, identifier, objectStoreID));
+}
+
 void UniqueIDBDatabase::putRecord(const IDBTransactionIdentifier& identifier, int64_t objectStoreID, const IDBKeyData& keyData, const IPC::DataReference& value, int64_t putMode, const Vector<int64_t>& indexIDs, const Vector<Vector<IDBKeyData>>& indexKeys, std::function<void(const IDBKeyData&, uint32_t, const String&)> callback)
 {
     ASSERT(isMainThread());
@@ -521,6 +549,16 @@ void UniqueIDBDatabase::deleteObjectStoreInBackingStore(uint64_t requestID, cons
     postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didDeleteObjectStore, requestID, success));
 }
 
+void UniqueIDBDatabase::clearObjectStoreInBackingStore(uint64_t requestID, const IDBTransactionIdentifier& identifier, int64_t objectStoreID)
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_backingStore);
+
+    bool success = m_backingStore->clearObjectStore(identifier, objectStoreID);
+
+    postMainThreadTask(createAsyncTask(*this, &UniqueIDBDatabase::didClearObjectStore, requestID, success));
+}
+
 void UniqueIDBDatabase::putRecordInBackingStore(uint64_t requestID, const IDBTransactionIdentifier& transaction, const IDBObjectStoreMetadata& objectStoreMetadata, const IDBKeyData& keyData, const Vector<uint8_t>& value, int64_t putMode, const Vector<int64_t>& indexIDs, const Vector<Vector<IDBKeyData>>& indexKeys)
 {
     ASSERT(!isMainThread());
index 95bd5c8..e1e1046 100644 (file)
@@ -77,6 +77,7 @@ public:
     void changeDatabaseVersion(const IDBTransactionIdentifier&, uint64_t newVersion, std::function<void(bool)> successCallback);
     void createObjectStore(const IDBTransactionIdentifier&, const WebCore::IDBObjectStoreMetadata&, std::function<void(bool)> successCallback);
     void deleteObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, std::function<void(bool)> successCallback);
+    void clearObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, std::function<void(bool)> successCallback);
     void putRecord(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKeyData&, const IPC::DataReference& value, int64_t putMode, const Vector<int64_t>& indexIDs, const Vector<Vector<WebCore::IDBKeyData>>& indexKeys, std::function<void(const WebCore::IDBKeyData&, uint32_t, const String&)> callback);
     void getRecord(const IDBTransactionIdentifier&, int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyRangeData&, WebCore::IndexedDB::CursorType, std::function<void(const WebCore::IDBGetResult&, uint32_t, const String&)> callback);
 
@@ -120,6 +121,7 @@ private:
     void changeDatabaseVersionInBackingStore(uint64_t requestID, const IDBTransactionIdentifier&, uint64_t newVersion);
     void createObjectStoreInBackingStore(uint64_t requestID, const IDBTransactionIdentifier&, const WebCore::IDBObjectStoreMetadata&);
     void deleteObjectStoreInBackingStore(uint64_t requestID, const IDBTransactionIdentifier&, int64_t objectStoreID);
+    void clearObjectStoreInBackingStore(uint64_t requestID, const IDBTransactionIdentifier&, int64_t objectStoreID);
     void putRecordInBackingStore(uint64_t requestID, const IDBTransactionIdentifier&, const WebCore::IDBObjectStoreMetadata&, const WebCore::IDBKeyData&, const Vector<uint8_t>& value, int64_t putMode, const Vector<int64_t>& indexIDs, const Vector<Vector<WebCore::IDBKeyData>>& indexKeys);
     void getRecordFromBackingStore(uint64_t requestID, const IDBTransactionIdentifier&, const WebCore::IDBObjectStoreMetadata&, int64_t indexID, const WebCore::IDBKeyRangeData&, WebCore::IndexedDB::CursorType);
 
@@ -132,6 +134,7 @@ private:
     void didChangeDatabaseVersion(uint64_t requestID, bool success);
     void didCreateObjectStore(uint64_t requestID, bool success);
     void didDeleteObjectStore(uint64_t requestID, bool success);
+    void didClearObjectStore(uint64_t requestID, bool success);
     void didPutRecordInBackingStore(uint64_t requestID, const WebCore::IDBKeyData&, uint32_t errorCode, const String& errorMessage);
     void didGetRecordFromBackingStore(uint64_t requestID, const WebCore::IDBGetResult&, uint32_t errorCode, const String& errorMessage);
     void didShutdownBackingStore();
index 937978a..a313f07 100644 (file)
@@ -59,6 +59,7 @@ public:
     virtual bool changeDatabaseVersion(const IDBTransactionIdentifier&, uint64_t newVersion) = 0;
     virtual bool createObjectStore(const IDBTransactionIdentifier&, const WebCore::IDBObjectStoreMetadata&) = 0;
     virtual bool deleteObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID) = 0;
+    virtual bool clearObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID) = 0;
 
     virtual PassRefPtr<WebCore::IDBKey> generateKey(const IDBTransactionIdentifier&, int64_t objectStoreID) = 0;
     virtual bool keyExistsInObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKey&, bool& keyExists) = 0;
index 4146d7c..5486b84 100644 (file)
@@ -429,6 +429,36 @@ bool UniqueIDBDatabaseBackingStoreSQLite::deleteObjectStore(const IDBTransaction
     return true;
 }
 
+bool UniqueIDBDatabaseBackingStoreSQLite::clearObjectStore(const IDBTransactionIdentifier& identifier, int64_t objectStoreID)
+{
+    ASSERT(!isMainThread());
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    SQLiteIDBTransaction* transaction = m_transactions.get(identifier);
+    if (!transaction || !transaction->inProgress()) {
+        LOG_ERROR("Attempt to change database version with an establish, in-progress transaction");
+        return false;
+    }
+    if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
+        LOG_ERROR("Attempt to change database version during a read-only transaction");
+        return false;
+    }
+
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM Records WHERE objectStoreID = ?;"));
+        if (sql.prepare() != SQLResultOk
+            || sql.bindInt64(1, objectStoreID) != SQLResultOk
+            || sql.step() != SQLResultDone) {
+            LOG_ERROR("Could not delete records from object store id %lli (%i) - %s", objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return false;
+        }
+    }
+
+    // FIXME <rdar://problem/15779642>: Once indexes are implemented, drop index records.
+    return true;
+}
+
 PassRefPtr<IDBKey> UniqueIDBDatabaseBackingStoreSQLite::generateKey(const IDBTransactionIdentifier&, int64_t objectStoreID)
 {
     // FIXME (<rdar://problem/15877909>): Implement
index c969796..222e24f 100644 (file)
@@ -63,6 +63,7 @@ public:
     virtual bool changeDatabaseVersion(const IDBTransactionIdentifier&, uint64_t newVersion) override;
     virtual bool createObjectStore(const IDBTransactionIdentifier&, const WebCore::IDBObjectStoreMetadata&) override;
     virtual bool deleteObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID) override;
+    virtual bool clearObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID) override;
 
     virtual PassRefPtr<WebCore::IDBKey> generateKey(const IDBTransactionIdentifier&, int64_t objectStoreID) override;
     virtual bool keyExistsInObjectStore(const IDBTransactionIdentifier&, int64_t objectStoreID, const WebCore::IDBKey&, bool& keyExists) override;
index eab4347..804ac20 100644 (file)
@@ -382,8 +382,33 @@ void WebIDBServerConnection::deleteRange(IDBTransactionBackend&, const DeleteRan
 {
 }
 
-void WebIDBServerConnection::clearObjectStore(IDBTransactionBackend&, const ClearObjectStoreOperation&, std::function<void(PassRefPtr<IDBDatabaseError>)> completionCallback)
+void WebIDBServerConnection::clearObjectStore(IDBTransactionBackend&, const ClearObjectStoreOperation& operation, std::function<void(PassRefPtr<IDBDatabaseError>)> completionCallback)
 {
+    RefPtr<AsyncRequest> serverRequest = AsyncRequestImpl<PassRefPtr<IDBDatabaseError>>::create(completionCallback);
+
+    serverRequest->setAbortHandler([completionCallback]() {
+        completionCallback(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Unknown error occured clearing object store"));
+    });
+
+    uint64_t requestID = serverRequest->requestID();
+    ASSERT(!m_serverRequests.contains(requestID));
+    m_serverRequests.add(requestID, serverRequest.release());
+
+    LOG(IDB, "WebProcess clearObjectStore request ID %llu", requestID);
+
+    send(Messages::DatabaseProcessIDBConnection::ClearObjectStore(requestID, operation.transaction()->id(), operation.objectStoreID()));
+}
+
+void WebIDBServerConnection::didClearObjectStore(uint64_t requestID, bool success)
+{
+    LOG(IDB, "WebProcess didClearObjectStore request ID %llu", requestID);
+
+    RefPtr<AsyncRequest> serverRequest = m_serverRequests.take(requestID);
+
+    if (!serverRequest)
+        return;
+
+    serverRequest->completeRequest(success ? nullptr : IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Unknown error occured clearing object store"));
 }
 
 void WebIDBServerConnection::deleteObjectStore(IDBTransactionBackend&, const DeleteObjectStoreOperation& operation, std::function<void(PassRefPtr<IDBDatabaseError>)> completionCallback)
index 44da4c3..daf01b1 100644 (file)
@@ -106,6 +106,7 @@ private:
     void didChangeDatabaseVersion(uint64_t requestID, bool success);
     void didCreateObjectStore(uint64_t requestID, bool success);
     void didDeleteObjectStore(uint64_t requestID, bool success);
+    void didClearObjectStore(uint64_t requestID, bool success);
     void didPutRecord(uint64_t requestID, const WebCore::IDBKeyData&, uint32_t errorCode, const String& errorMessage);
     void didGetRecord(uint64_t requestID, const WebCore::IDBGetResult&, uint32_t errorCode, const String& errorMessage);
 
index b9f88b9..a6144b8 100644 (file)
@@ -34,6 +34,7 @@ messages -> WebIDBServerConnection LegacyReceiver {
     DidChangeDatabaseVersion(uint64_t requestID, bool success)
     DidCreateObjectStore(uint64_t requestID, bool success)
     DidDeleteObjectStore(uint64_t requestID, bool success)
+    DidClearObjectStore(uint64_t requestID, bool success)
     DidPutRecord(uint64_t requestID, WebCore::IDBKeyData resultKey, uint32_t errorCode, String errorMessage)
     DidGetRecord(uint64_t requestID, WebCore::IDBGetResult getResult, uint32_t errorCode, String errorMessage)
 }