Serialize IndexedDB::ObjectStoreOverwriteMode as an enum
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Mar 2019 20:36:08 +0000 (20:36 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Mar 2019 20:36:08 +0000 (20:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195213

Reviewed by Alex Christensen.

Source/WebCore:

Add traits to enable enum IPC encoding.
No change of behavior.

* Modules/indexeddb/IndexedDB.h:

Source/WebKit:

Make use of enum trait to automatically check for correct enum value when receiving a putOrAdd message.

* NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp:
(WebKit::WebIDBConnectionToClient::putOrAdd):
* NetworkProcess/IndexedDB/WebIDBConnectionToClient.h:
* NetworkProcess/IndexedDB/WebIDBConnectionToClient.messages.in:
* Scripts/webkit/messages.py:
* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
(WebKit::WebIDBConnectionToServer::putOrAdd):

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IndexedDB.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp
Source/WebKit/NetworkProcess/IndexedDB/WebIDBConnectionToClient.h
Source/WebKit/NetworkProcess/IndexedDB/WebIDBConnectionToClient.messages.in
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp

index bf4f5f9..7b16763 100644 (file)
@@ -1,3 +1,15 @@
+2019-03-01  Youenn Fablet  <youenn@apple.com>
+
+        Serialize IndexedDB::ObjectStoreOverwriteMode as an enum
+        https://bugs.webkit.org/show_bug.cgi?id=195213
+
+        Reviewed by Alex Christensen.
+
+        Add traits to enable enum IPC encoding.
+        No change of behavior.
+
+        * Modules/indexeddb/IndexedDB.h:
+
 2019-03-01  Don Olmstead  <don.olmstead@sony.com>
 
         [WinCairo] Enable service worker
index 0ed653e..6af93c4 100644 (file)
@@ -27,6 +27,8 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include <wtf/EnumTraits.h>
+
 namespace WebCore {
 
 namespace IndexedDB {
@@ -106,4 +108,17 @@ enum class GetAllType {
 
 } // namespace WebCore
 
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::IndexedDB::ObjectStoreOverwriteMode> {
+    using values = EnumValues<
+        WebCore::IndexedDB::ObjectStoreOverwriteMode,
+        WebCore::IndexedDB::ObjectStoreOverwriteMode::Overwrite,
+        WebCore::IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor,
+        WebCore::IndexedDB::ObjectStoreOverwriteMode::NoOverwrite
+    >;
+};
+
+}
+
 #endif // ENABLED(INDEXED_DATABASE)
index b4cf318..c5b3217 100644 (file)
@@ -1,3 +1,20 @@
+2019-03-01  Youenn Fablet  <youenn@apple.com>
+
+        Serialize IndexedDB::ObjectStoreOverwriteMode as an enum
+        https://bugs.webkit.org/show_bug.cgi?id=195213
+
+        Reviewed by Alex Christensen.
+
+        Make use of enum trait to automatically check for correct enum value when receiving a putOrAdd message.
+
+        * NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp:
+        (WebKit::WebIDBConnectionToClient::putOrAdd):
+        * NetworkProcess/IndexedDB/WebIDBConnectionToClient.h:
+        * NetworkProcess/IndexedDB/WebIDBConnectionToClient.messages.in:
+        * Scripts/webkit/messages.py:
+        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
+        (WebKit::WebIDBConnectionToServer::putOrAdd):
+
 2019-03-01  Don Olmstead  <don.olmstead@sony.com>
 
         [WinCairo] Enable service worker
index d0e8565..87c69d0 100644 (file)
@@ -275,18 +275,8 @@ void WebIDBConnectionToClient::renameIndex(const IDBRequestData& request, uint64
     m_networkProcess->idbServer(m_sessionID).renameIndex(request, objectStoreIdentifier, indexIdentifier, newName);
 }
 
-void WebIDBConnectionToClient::putOrAdd(const IDBRequestData& request, const IDBKeyData& key, const IDBValue& value, unsigned overwriteMode)
+void WebIDBConnectionToClient::putOrAdd(const IDBRequestData& request, const IDBKeyData& key, const IDBValue& value, IndexedDB::ObjectStoreOverwriteMode mode)
 {
-    if (overwriteMode != static_cast<unsigned>(IndexedDB::ObjectStoreOverwriteMode::NoOverwrite)
-        && overwriteMode != static_cast<unsigned>(IndexedDB::ObjectStoreOverwriteMode::Overwrite)
-        && overwriteMode != static_cast<unsigned>(IndexedDB::ObjectStoreOverwriteMode::OverwriteForCursor)) {
-        // FIXME: This message from the WebProcess is corrupt.
-        // The Network Process should return early at this point, but can we also kill the bad WebProcess?
-        return;
-    }
-
-    IndexedDB::ObjectStoreOverwriteMode mode = static_cast<IndexedDB::ObjectStoreOverwriteMode>(overwriteMode);
-
     m_networkProcess->idbServer(m_sessionID).putOrAdd(request, key, value, mode);
 }
 
index b13434c..cf783f7 100644 (file)
@@ -30,6 +30,7 @@
 #include "MessageSender.h"
 #include "NetworkConnectionToWebProcess.h"
 #include <WebCore/IDBConnectionToClient.h>
+#include <WebCore/IndexedDB.h>
 #include <pal/SessionID.h>
 
 namespace WebCore {
@@ -105,7 +106,7 @@ public:
     void createIndex(const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&);
     void deleteIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);
     void renameIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
-    void putOrAdd(const WebCore::IDBRequestData&, const WebCore::IDBKeyData&, const WebCore::IDBValue&, unsigned overwriteMode);
+    void putOrAdd(const WebCore::IDBRequestData&, const WebCore::IDBKeyData&, const WebCore::IDBValue&, WebCore::IndexedDB::ObjectStoreOverwriteMode);
     void getRecord(const WebCore::IDBRequestData&, const WebCore::IDBGetRecordData&);
     void getAllRecords(const WebCore::IDBRequestData&, const WebCore::IDBGetAllRecordsData&);
     void getCount(const WebCore::IDBRequestData&, const WebCore::IDBKeyRangeData&);
index 4aab026..878af70 100644 (file)
@@ -35,7 +35,7 @@ messages -> WebIDBConnectionToClient {
     CreateIndex(WebCore::IDBRequestData requestData, WebCore::IDBIndexInfo info);
     DeleteIndex(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, String indexName);
     RenameIndex(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, String newName);
-    PutOrAdd(WebCore::IDBRequestData requestData, WebCore::IDBKeyData key, WebCore::IDBValue value, unsigned overwriteMode);
+    PutOrAdd(WebCore::IDBRequestData requestData, WebCore::IDBKeyData key, WebCore::IDBValue value, WebCore::IndexedDB::ObjectStoreOverwriteMode overwriteMode);
     GetRecord(WebCore::IDBRequestData requestData, struct WebCore::IDBGetRecordData getRecordData);
     GetAllRecords(WebCore::IDBRequestData requestData, struct WebCore::IDBGetAllRecordsData getAllRecordsData);
     GetCount(WebCore::IDBRequestData requestData, struct WebCore::IDBKeyRangeData range);
index 6f61413..0fd0c59 100644 (file)
@@ -408,6 +408,7 @@ def headers_for_type(type):
         'WebCore::HasInsecureContent': ['<WebCore/FrameLoaderTypes.h>'],
         'WebCore::Highlight': ['<WebCore/InspectorOverlay.h>'],
         'WebCore::IncludeSecureCookies': ['<WebCore/CookieJar.h>'],
+        'WebCore::IndexedDB::ObjectStoreOverwriteMode': ['<WebCore/IndexedDB.h>'],
         'WebCore::InputMode': ['<WebCore/InputMode.h>'],
         'WebCore::KeyframeValueList': ['<WebCore/GraphicsLayer.h>'],
         'WebCore::KeypressCommand': ['<WebCore/KeyboardEvent.h>'],
index 17c4a94..8f578e4 100644 (file)
@@ -143,7 +143,7 @@ void WebIDBConnectionToServer::renameIndex(const IDBRequestData& requestData, ui
 
 void WebIDBConnectionToServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, const IndexedDB::ObjectStoreOverwriteMode mode)
 {
-    send(Messages::WebIDBConnectionToClient::PutOrAdd(requestData, keyData, value, static_cast<unsigned>(mode)));
+    send(Messages::WebIDBConnectionToClient::PutOrAdd(requestData, keyData, value, mode));
 }
 
 void WebIDBConnectionToServer::getRecord(const IDBRequestData& requestData, const IDBGetRecordData& getRecordData)