Remove legacy sync messaging in some IPC code
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 18:35:20 +0000 (18:35 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 18:35:20 +0000 (18:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194561

Reviewed by Geoffrey Garen.

Changing some LegacySync messages to Delayed messages.  We should probably rename Delayed to Sync.
There are too many ways to send messages.  Let's work to get rid of the old one.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::setAllowsAnySSLCertificateForWebSocket):
(WebKit::NetworkProcess::processWillSuspendImminently):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::handleWheelEvent):
(WebKit::PluginControllerProxy::handleMouseEnterEvent):
(WebKit::PluginControllerProxy::handleMouseLeaveEvent):
(WebKit::PluginControllerProxy::handleKeyboardEvent):
(WebKit::PluginControllerProxy::handleEditingCommand):
(WebKit::PluginControllerProxy::isEditingCommandEnabled):
(WebKit::PluginControllerProxy::handlesPageScaleFactor):
(WebKit::PluginControllerProxy::requiresUnifiedScaleFactor):
(WebKit::PluginControllerProxy::paintEntirePlugin):
(WebKit::PluginControllerProxy::supportsSnapshotting):
(WebKit::PluginControllerProxy::snapshot):
(WebKit::PluginControllerProxy::getPluginScriptableNPObject):
(WebKit::PluginControllerProxy::getFormValue):
* PluginProcess/PluginControllerProxy.h:
* PluginProcess/PluginControllerProxy.messages.in:
* Shared/Plugins/NPObjectMessageReceiver.cpp:
(WebKit::NPObjectMessageReceiver::deallocate):
(WebKit::NPObjectMessageReceiver::hasMethod):
(WebKit::NPObjectMessageReceiver::invoke):
(WebKit::NPObjectMessageReceiver::invokeDefault):
(WebKit::NPObjectMessageReceiver::hasProperty):
(WebKit::NPObjectMessageReceiver::getProperty):
(WebKit::NPObjectMessageReceiver::setProperty):
(WebKit::NPObjectMessageReceiver::removeProperty):
(WebKit::NPObjectMessageReceiver::enumerate):
(WebKit::NPObjectMessageReceiver::construct):
* Shared/Plugins/NPObjectMessageReceiver.h:
* Shared/Plugins/NPObjectMessageReceiver.messages.in:
* UIProcess/mac/SecItemShimProxy.cpp:
(WebKit::SecItemShimProxy::secItemRequest):
* UIProcess/mac/SecItemShimProxy.h:
* UIProcess/mac/SecItemShimProxy.messages.in:

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

13 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/PluginProcess/PluginControllerProxy.cpp
Source/WebKit/PluginProcess/PluginControllerProxy.h
Source/WebKit/PluginProcess/PluginControllerProxy.messages.in
Source/WebKit/Shared/Plugins/NPObjectMessageReceiver.cpp
Source/WebKit/Shared/Plugins/NPObjectMessageReceiver.h
Source/WebKit/Shared/Plugins/NPObjectMessageReceiver.messages.in
Source/WebKit/UIProcess/mac/SecItemShimProxy.cpp
Source/WebKit/UIProcess/mac/SecItemShimProxy.h
Source/WebKit/UIProcess/mac/SecItemShimProxy.messages.in

index 09e4edb..83f54e7 100644 (file)
@@ -1,3 +1,52 @@
+2019-02-13  Alex Christensen  <achristensen@webkit.org>
+
+        Remove legacy sync messaging in some IPC code
+        https://bugs.webkit.org/show_bug.cgi?id=194561
+
+        Reviewed by Geoffrey Garen.
+
+        Changing some LegacySync messages to Delayed messages.  We should probably rename Delayed to Sync.
+        There are too many ways to send messages.  Let's work to get rid of the old one.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::setAllowsAnySSLCertificateForWebSocket):
+        (WebKit::NetworkProcess::processWillSuspendImminently):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * PluginProcess/PluginControllerProxy.cpp:
+        (WebKit::PluginControllerProxy::handleWheelEvent):
+        (WebKit::PluginControllerProxy::handleMouseEnterEvent):
+        (WebKit::PluginControllerProxy::handleMouseLeaveEvent):
+        (WebKit::PluginControllerProxy::handleKeyboardEvent):
+        (WebKit::PluginControllerProxy::handleEditingCommand):
+        (WebKit::PluginControllerProxy::isEditingCommandEnabled):
+        (WebKit::PluginControllerProxy::handlesPageScaleFactor):
+        (WebKit::PluginControllerProxy::requiresUnifiedScaleFactor):
+        (WebKit::PluginControllerProxy::paintEntirePlugin):
+        (WebKit::PluginControllerProxy::supportsSnapshotting):
+        (WebKit::PluginControllerProxy::snapshot):
+        (WebKit::PluginControllerProxy::getPluginScriptableNPObject):
+        (WebKit::PluginControllerProxy::getFormValue):
+        * PluginProcess/PluginControllerProxy.h:
+        * PluginProcess/PluginControllerProxy.messages.in:
+        * Shared/Plugins/NPObjectMessageReceiver.cpp:
+        (WebKit::NPObjectMessageReceiver::deallocate):
+        (WebKit::NPObjectMessageReceiver::hasMethod):
+        (WebKit::NPObjectMessageReceiver::invoke):
+        (WebKit::NPObjectMessageReceiver::invokeDefault):
+        (WebKit::NPObjectMessageReceiver::hasProperty):
+        (WebKit::NPObjectMessageReceiver::getProperty):
+        (WebKit::NPObjectMessageReceiver::setProperty):
+        (WebKit::NPObjectMessageReceiver::removeProperty):
+        (WebKit::NPObjectMessageReceiver::enumerate):
+        (WebKit::NPObjectMessageReceiver::construct):
+        * Shared/Plugins/NPObjectMessageReceiver.h:
+        * Shared/Plugins/NPObjectMessageReceiver.messages.in:
+        * UIProcess/mac/SecItemShimProxy.cpp:
+        (WebKit::SecItemShimProxy::secItemRequest):
+        * UIProcess/mac/SecItemShimProxy.h:
+        * UIProcess/mac/SecItemShimProxy.messages.in:
+
 2019-02-13  Truitt Savell  <tsavell@apple.com>
 
         Unreviewed, rolling out r241433.
index f166fd9..12dd686 100644 (file)
@@ -1774,9 +1774,10 @@ void NetworkProcess::getNetworkProcessStatistics(uint64_t callbackID)
     parentProcessConnection()->send(Messages::WebProcessPool::DidGetStatistics(data, callbackID), 0);
 }
 
-void NetworkProcess::setAllowsAnySSLCertificateForWebSocket(bool allows)
+void NetworkProcess::setAllowsAnySSLCertificateForWebSocket(bool allows, CompletionHandler<void()>&& completionHandler)
 {
     DeprecatedGlobalSettings::setAllowsAnySSLCertificate(allows);
+    completionHandler();
 }
 
 void NetworkProcess::logDiagnosticMessage(uint64_t webPageID, const String& message, const String& description, ShouldSample shouldSample)
@@ -1849,10 +1850,10 @@ void NetworkProcess::actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend
         connection->cleanupForSuspension([delayedTaskCounter] { });
 }
 
-void NetworkProcess::processWillSuspendImminently(bool& handled)
+void NetworkProcess::processWillSuspendImminently(CompletionHandler<void(bool)>&& completionHandler)
 {
     actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend::No);
-    handled = true;
+    completionHandler(true);
 }
 
 void NetworkProcess::prepareToSuspend()
index 335c3ca..28351b2 100644 (file)
@@ -154,7 +154,7 @@ public:
 
     bool canHandleHTTPSServerTrustEvaluation() const { return m_canHandleHTTPSServerTrustEvaluation; }
 
-    void processWillSuspendImminently(bool& handled);
+    void processWillSuspendImminently(CompletionHandler<void(bool)>&&);
     void prepareToSuspend();
     void cancelPrepareToSuspend();
     void processDidResume();
@@ -363,7 +363,7 @@ private:
     void setCanHandleHTTPSServerTrustEvaluation(bool);
     void getNetworkProcessStatistics(uint64_t callbackID);
     void clearCacheForAllOrigins(uint32_t cachesToClear);
-    void setAllowsAnySSLCertificateForWebSocket(bool);
+    void setAllowsAnySSLCertificateForWebSocket(bool, CompletionHandler<void()>&&);
     
     void syncAllCookies();
     void didSyncAllCookies();
index 6c4dbb1..283b599 100644 (file)
@@ -60,7 +60,7 @@ messages -> NetworkProcess LegacyReceiver {
     SetQOS(int latencyQOS, int throughputQOS)
     SetStorageAccessAPIEnabled(bool enabled)
 #endif
-    SetAllowsAnySSLCertificateForWebSocket(bool enabled) -> () LegacySync
+    SetAllowsAnySSLCertificateForWebSocket(bool enabled) -> () Delayed
 
     SyncAllCookies()
 
@@ -75,7 +75,7 @@ messages -> NetworkProcess LegacyReceiver {
     ProcessDidTransitionToBackground()
     ProcessDidTransitionToForeground()
 
-    ProcessWillSuspendImminently() -> (bool handled) LegacySync
+    ProcessWillSuspendImminently() -> (bool handled) Delayed
     PrepareToSuspend()
     CancelPrepareToSuspend()
     ProcessDidResume()
index d72add2..6d8a55d 100644 (file)
@@ -529,68 +529,71 @@ void PluginControllerProxy::handleMouseEvent(const WebMouseEvent& mouseEvent)
     m_plugin->handleMouseEvent(mouseEvent);
 }
 
-void PluginControllerProxy::handleWheelEvent(const WebWheelEvent& wheelEvent, bool& handled)
+void PluginControllerProxy::handleWheelEvent(const WebWheelEvent& wheelEvent, CompletionHandler<void(bool)>&& completionHandler)
 {
-    handled = m_plugin->handleWheelEvent(wheelEvent);
+    completionHandler(m_plugin->handleWheelEvent(wheelEvent));
 }
 
-void PluginControllerProxy::handleMouseEnterEvent(const WebMouseEvent& mouseEnterEvent, bool& handled)
+void PluginControllerProxy::handleMouseEnterEvent(const WebMouseEvent& mouseEnterEvent, CompletionHandler<void(bool)>&& completionHandler)
 {
-    handled = m_plugin->handleMouseEnterEvent(mouseEnterEvent);
+    completionHandler(m_plugin->handleMouseEnterEvent(mouseEnterEvent));
 }
 
-void PluginControllerProxy::handleMouseLeaveEvent(const WebMouseEvent& mouseLeaveEvent, bool& handled)
+void PluginControllerProxy::handleMouseLeaveEvent(const WebMouseEvent& mouseLeaveEvent, CompletionHandler<void(bool)>&& completionHandler)
 {
-    handled = m_plugin->handleMouseLeaveEvent(mouseLeaveEvent);
+    completionHandler(m_plugin->handleMouseLeaveEvent(mouseLeaveEvent));
 }
 
-void PluginControllerProxy::handleKeyboardEvent(const WebKeyboardEvent& keyboardEvent, bool& handled)
+void PluginControllerProxy::handleKeyboardEvent(const WebKeyboardEvent& keyboardEvent, CompletionHandler<void(bool)>&& completionHandler)
 {
-    handled = m_plugin->handleKeyboardEvent(keyboardEvent);
+    completionHandler(m_plugin->handleKeyboardEvent(keyboardEvent));
 }
 
-void PluginControllerProxy::handleEditingCommand(const String& commandName, const String& argument, bool& handled)
+void PluginControllerProxy::handleEditingCommand(const String& commandName, const String& argument, CompletionHandler<void(bool)>&& completionHandler)
 {
-    handled = m_plugin->handleEditingCommand(commandName, argument);
+    completionHandler(m_plugin->handleEditingCommand(commandName, argument));
 }
     
-void PluginControllerProxy::isEditingCommandEnabled(const String& commandName, bool& enabled)
+void PluginControllerProxy::isEditingCommandEnabled(const String& commandName, CompletionHandler<void(bool)>&& completionHandler)
 {
-    enabled = m_plugin->isEditingCommandEnabled(commandName);
+    completionHandler(m_plugin->isEditingCommandEnabled(commandName));
 }
     
-void PluginControllerProxy::handlesPageScaleFactor(bool& isHandled)
+void PluginControllerProxy::handlesPageScaleFactor(CompletionHandler<void(bool)>&& completionHandler)
 {
-    isHandled = m_plugin->handlesPageScaleFactor();
+    completionHandler(m_plugin->handlesPageScaleFactor());
 }
 
-void PluginControllerProxy::requiresUnifiedScaleFactor(bool& required)
+void PluginControllerProxy::requiresUnifiedScaleFactor(CompletionHandler<void(bool)>&& completionHandler)
 {
-    required = m_plugin->requiresUnifiedScaleFactor();
+    completionHandler(m_plugin->requiresUnifiedScaleFactor());
 }
 
-void PluginControllerProxy::paintEntirePlugin()
+void PluginControllerProxy::paintEntirePlugin(CompletionHandler<void()>&& completionHandler)
 {
     if (m_pluginSize.isEmpty())
-        return;
+        return completionHandler();
 
     m_dirtyRect = IntRect(IntPoint(), m_pluginSize);
     paint();
+    completionHandler();
 }
 
-void PluginControllerProxy::supportsSnapshotting(bool& isSupported)
+void PluginControllerProxy::supportsSnapshotting(CompletionHandler<void(bool)>&& completionHandler)
 {
-    isSupported = m_plugin->supportsSnapshotting();
+    completionHandler(m_plugin->supportsSnapshotting());
 }
 
-void PluginControllerProxy::snapshot(ShareableBitmap::Handle& backingStoreHandle)
+void PluginControllerProxy::snapshot(CompletionHandler<void(ShareableBitmap::Handle&&)> completionHandler)
 {
     ASSERT(m_plugin);
     RefPtr<ShareableBitmap> bitmap = m_plugin->snapshot();
     if (!bitmap)
-        return;
+        return completionHandler({ });
 
+    ShareableBitmap::Handle backingStoreHandle;
     bitmap->createHandle(backingStoreHandle);
+    completionHandler(WTFMove(backingStoreHandle));
 }
 
 void PluginControllerProxy::setFocus(bool hasFocus)
@@ -604,16 +607,15 @@ void PluginControllerProxy::didUpdate()
     startPaintTimer();
 }
 
-void PluginControllerProxy::getPluginScriptableNPObject(uint64_t& pluginScriptableNPObjectID)
+void PluginControllerProxy::getPluginScriptableNPObject(CompletionHandler<void(uint64_t)>&& completionHandler)
 {
     NPObject* pluginScriptableNPObject = m_plugin->pluginScriptableNPObject();
-    if (!pluginScriptableNPObject) {
-        pluginScriptableNPObjectID = 0;
-        return;
-    }
+    if (!pluginScriptableNPObject)
+        return completionHandler(0);
     
-    pluginScriptableNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(pluginScriptableNPObject, m_plugin.get());
+    uint64_t pluginScriptableNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(pluginScriptableNPObject, m_plugin.get());
     releaseNPObject(pluginScriptableNPObject);
+    completionHandler(pluginScriptableNPObjectID);
 }
 
 void PluginControllerProxy::storageBlockingStateChanged(bool isStorageBlockingEnabled)
@@ -640,9 +642,11 @@ void PluginControllerProxy::mutedStateChanged(bool isMuted)
     m_plugin->mutedStateChanged(isMuted);
 }
 
-void PluginControllerProxy::getFormValue(bool& returnValue, String& formValue)
+void PluginControllerProxy::getFormValue(CompletionHandler<void(bool, String&&)>&& completionHandler)
 {
-    returnValue = m_plugin->getFormValue(formValue);
+    String formValue;
+    bool returnValue = m_plugin->getFormValue(formValue);
+    completionHandler(returnValue, WTFMove(formValue));
 }
 
 #if PLATFORM(X11)
index 8b5c81a..97e2df3 100644 (file)
@@ -135,20 +135,20 @@ private:
     void manualStreamDidFinishLoading();
     void manualStreamDidFail(bool wasCancelled);
     void handleMouseEvent(const WebMouseEvent&);
-    void handleWheelEvent(const WebWheelEvent&, bool& handled);
-    void handleMouseEnterEvent(const WebMouseEvent&, bool& handled);
-    void handleMouseLeaveEvent(const WebMouseEvent&, bool& handled);
-    void handleKeyboardEvent(const WebKeyboardEvent&, bool& handled);
-    void handleEditingCommand(const String&, const String&, bool&);
-    void isEditingCommandEnabled(const String&, bool&);
-    void handlesPageScaleFactor(bool&);
-    void requiresUnifiedScaleFactor(bool&);
-    void paintEntirePlugin();
-    void supportsSnapshotting(bool&);
-    void snapshot(ShareableBitmap::Handle& backingStoreHandle);
+    void handleWheelEvent(const WebWheelEvent&, CompletionHandler<void(bool handled)>&&);
+    void handleMouseEnterEvent(const WebMouseEvent&, CompletionHandler<void(bool handled)>&&);
+    void handleMouseLeaveEvent(const WebMouseEvent&, CompletionHandler<void(bool handled)>&&);
+    void handleKeyboardEvent(const WebKeyboardEvent&, CompletionHandler<void(bool handled)>&&);
+    void handleEditingCommand(const String&, const String&, CompletionHandler<void(bool handled)>&&);
+    void isEditingCommandEnabled(const String&, CompletionHandler<void(bool)>&&);
+    void handlesPageScaleFactor(CompletionHandler<void(bool)>&&);
+    void requiresUnifiedScaleFactor(CompletionHandler<void(bool)>&&);
+    void paintEntirePlugin(CompletionHandler<void()>&&);
+    void supportsSnapshotting(CompletionHandler<void(bool)>&&);
+    void snapshot(CompletionHandler<void(ShareableBitmap::Handle&&)>);
     void setFocus(bool);
     void didUpdate();
-    void getPluginScriptableNPObject(uint64_t& pluginScriptableNPObjectID);
+    void getPluginScriptableNPObject(CompletionHandler<void(uint64_t pluginScriptableNPObjectID)>&&);
 
     void windowFocusChanged(bool);
     void windowVisibilityChanged(bool);
@@ -165,7 +165,7 @@ private:
     void storageBlockingStateChanged(bool);
     void privateBrowsingStateChanged(bool);
     void mutedStateChanged(bool);
-    void getFormValue(bool& returnValue, String& formValue);
+    void getFormValue(CompletionHandler<void(bool returnValue, String&& formValue)>&&);
 
     void platformInitialize(const PluginCreationParameters&);
     void platformDestroy();
index fae4a03..6c386c7 100644 (file)
@@ -69,28 +69,28 @@ messages -> PluginControllerProxy LegacyReceiver {
     HandleMouseEvent(WebKit::WebMouseEvent mouseEvent)
     
     # Sent when a mouse wheel event should be processed.
-    HandleWheelEvent(WebKit::WebWheelEvent wheelEvent) -> (bool handled) LegacySync
+    HandleWheelEvent(WebKit::WebWheelEvent wheelEvent) -> (bool handled) Delayed
 
     # Sent when a mouse enter event should be processed.
-    HandleMouseEnterEvent(WebKit::WebMouseEvent mouseEvent) -> (bool handled) LegacySync
+    HandleMouseEnterEvent(WebKit::WebMouseEvent mouseEvent) -> (bool handled) Delayed
     
     # Sent when a mouse leave event should be processed.
-    HandleMouseLeaveEvent(WebKit::WebMouseEvent mouseEvent) -> (bool handled) LegacySync
+    HandleMouseLeaveEvent(WebKit::WebMouseEvent mouseEvent) -> (bool handled) Delayed
 
     # Sent when a keyboard should be processed.
-    HandleKeyboardEvent(WebKit::WebKeyboardEvent keyboardEvent) -> (bool handled) LegacySync
+    HandleKeyboardEvent(WebKit::WebKeyboardEvent keyboardEvent) -> (bool handled) Delayed
     
     # Sent when an editing command should be processed.
-    HandleEditingCommand(String commandName, String argument) -> (bool handled) LegacySync
+    HandleEditingCommand(String commandName, String argument) -> (bool handled) Delayed
     
     # Return whether or not a plugin wants to enable the given editing command.
-    IsEditingCommandEnabled(String commandName) -> (bool enabled) LegacySync
+    IsEditingCommandEnabled(String commandName) -> (bool enabled) Delayed
     
     # Return whether or not a plugin wants to handle page scale factor itself.
-    HandlesPageScaleFactor() -> (bool enabled) LegacySync
+    HandlesPageScaleFactor() -> (bool enabled) Delayed
 
     # Return whether or not a plugin wants page scale, page zoom, and text zoom all to affect page scale.
-    RequiresUnifiedScaleFactor() -> (bool required) LegacySync
+    RequiresUnifiedScaleFactor() -> (bool required) Delayed
 
     # Sent when the plug-in focus changes.
     SetFocus(bool isFocused)
@@ -99,10 +99,10 @@ messages -> PluginControllerProxy LegacyReceiver {
     DidUpdate()
 
     # Paint the entire plug-in.
-    PaintEntirePlugin() -> () LegacySync
+    PaintEntirePlugin() -> () Delayed
 
     # Get a reference to the plug-in's scriptable NPObject.
-    GetPluginScriptableNPObject() -> (uint64_t pluginScriptableNPObjectID) LegacySync
+    GetPluginScriptableNPObject() -> (uint64_t pluginScriptableNPObjectID) Delayed
 
     # Sent when the containing NSWindow's focus changes
     WindowFocusChanged(bool hasFocus)
@@ -122,10 +122,10 @@ messages -> PluginControllerProxy LegacyReceiver {
 #endif
 
     # Does the plugin support snapshotting?
-    SupportsSnapshotting() -> (bool isSupported) LegacySync
+    SupportsSnapshotting() -> (bool isSupported) Delayed
 
     # Return a snapshot of the plugin.
-    Snapshot() -> (WebKit::ShareableBitmap::Handle backingStoreHandle) LegacySync
+    Snapshot() -> (WebKit::ShareableBitmap::Handle backingStoreHandle) Delayed
 
     # Sent when storage blocking policy changes
     StorageBlockingStateChanged(bool storageBlockingEnabled)
@@ -134,7 +134,7 @@ messages -> PluginControllerProxy LegacyReceiver {
     PrivateBrowsingStateChanged(bool isPrivateBrowsingEnabled)
 
     # Gets the string representating the form value of the plug-in
-    GetFormValue() -> (bool returnValue, String formValue) LegacySync
+    GetFormValue() -> (bool returnValue, String formValue) Delayed
 
     # Sent when the browser wants to mute or unmute the plugin.
     MutedStateChanged(bool muted)
index a531935..29f9045 100644 (file)
@@ -53,27 +53,24 @@ NPObjectMessageReceiver::~NPObjectMessageReceiver()
     releaseNPObject(m_npObject);
 }
 
-void NPObjectMessageReceiver::deallocate()
+void NPObjectMessageReceiver::deallocate(CompletionHandler<void()>&& completionHandler)
 {
     delete this;
+    completionHandler();
 }
 
-void NPObjectMessageReceiver::hasMethod(const NPIdentifierData& methodNameData, bool& returnValue)
+void NPObjectMessageReceiver::hasMethod(const NPIdentifierData& methodNameData, CompletionHandler<void(bool)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->hasMethod) {
-        returnValue = false;
-        return;
-    }
-    
-    returnValue = m_npObject->_class->hasMethod(m_npObject, methodNameData.createNPIdentifier());
+    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->hasMethod)
+        return completionHandler(false);
+
+    completionHandler(m_npObject->_class->hasMethod(m_npObject, methodNameData.createNPIdentifier()));
 }
 
-void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData)
+void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, const Vector<NPVariantData>& argumentsData, CompletionHandler<void(bool, NPVariantData&&)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->invoke) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->invoke)
+        return completionHandler(false, { });
 
     Vector<NPVariant> arguments;
     for (size_t i = 0; i < argumentsData.size(); ++i)
@@ -84,7 +81,8 @@ void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, con
 
     PluginController::PluginDestructionProtector protector(m_plugin->controller());
 
-    returnValue = m_npObject->_class->invoke(m_npObject, methodNameData.createNPIdentifier(), arguments.data(), arguments.size(), &result);
+    NPVariantData resultData;
+    bool returnValue = m_npObject->_class->invoke(m_npObject, methodNameData.createNPIdentifier(), arguments.data(), arguments.size(), &result);
     if (returnValue) {
         // Convert the NPVariant to an NPVariantData.
         resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin);
@@ -96,14 +94,13 @@ void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, con
     
     // And release the result.
     releaseNPVariantValue(&result);
+    completionHandler(returnValue, WTFMove(resultData));
 }
 
-void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData)
+void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumentsData, CompletionHandler<void(bool, NPVariantData&&)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->invokeDefault) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->invokeDefault)
+        return completionHandler(false, { });
 
     Vector<NPVariant> arguments;
     for (size_t i = 0; i < argumentsData.size(); ++i)
@@ -114,7 +111,8 @@ void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumen
 
     PluginController::PluginDestructionProtector protector(m_plugin->controller());
 
-    returnValue = m_npObject->_class->invokeDefault(m_npObject, arguments.data(), arguments.size(), &result);
+    NPVariantData resultData;
+    bool returnValue = m_npObject->_class->invokeDefault(m_npObject, arguments.data(), arguments.size(), &result);
     if (returnValue) {
         // Convert the NPVariant to an NPVariantData.
         resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin);
@@ -126,92 +124,85 @@ void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumen
     
     // And release the result.
     releaseNPVariantValue(&result);
+    completionHandler(returnValue, WTFMove(resultData));
 }
 
-void NPObjectMessageReceiver::hasProperty(const NPIdentifierData& propertyNameData, bool& returnValue)
+void NPObjectMessageReceiver::hasProperty(const NPIdentifierData& propertyNameData, CompletionHandler<void(bool)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->hasProperty) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->hasProperty)
+        return completionHandler(false);
 
-    returnValue = m_npObject->_class->hasProperty(m_npObject, propertyNameData.createNPIdentifier());
+    completionHandler(m_npObject->_class->hasProperty(m_npObject, propertyNameData.createNPIdentifier()));
 }
 
-void NPObjectMessageReceiver::getProperty(const NPIdentifierData& propertyNameData, bool& returnValue, NPVariantData& resultData)
+void NPObjectMessageReceiver::getProperty(const NPIdentifierData& propertyNameData, CompletionHandler<void(bool, NPVariantData&&)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->getProperty) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->getProperty)
+        return completionHandler(false, { });
 
     NPVariant result;
     VOID_TO_NPVARIANT(result);
 
     PluginController::PluginDestructionProtector protector(m_plugin->controller());
 
-    returnValue = m_npObject->_class->getProperty(m_npObject, propertyNameData.createNPIdentifier(), &result);
+    bool returnValue = m_npObject->_class->getProperty(m_npObject, propertyNameData.createNPIdentifier(), &result);
     if (!returnValue)
-        return;
+        return completionHandler(false, { });
 
 
-    resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin);
+    NPVariantData resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin);
 
     releaseNPVariantValue(&result);
+    completionHandler(true, WTFMove(resultData));
 }
 
-void NPObjectMessageReceiver::setProperty(const NPIdentifierData& propertyNameData, const NPVariantData& propertyValueData, bool& returnValue)
+void NPObjectMessageReceiver::setProperty(const NPIdentifierData& propertyNameData, const NPVariantData& propertyValueData, CompletionHandler<void(bool)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->setProperty) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->setProperty)
+        return completionHandler(false);
 
     NPVariant propertyValue = m_npRemoteObjectMap->npVariantDataToNPVariant(propertyValueData, m_plugin);
 
     PluginController::PluginDestructionProtector protector(m_plugin->controller());
 
-    returnValue = m_npObject->_class->setProperty(m_npObject, propertyNameData.createNPIdentifier(), &propertyValue);
+    bool returnValue = m_npObject->_class->setProperty(m_npObject, propertyNameData.createNPIdentifier(), &propertyValue);
 
     releaseNPVariantValue(&propertyValue);
+    completionHandler(returnValue);
 }
 
-void NPObjectMessageReceiver::removeProperty(const NPIdentifierData& propertyNameData, bool& returnValue)
+void NPObjectMessageReceiver::removeProperty(const NPIdentifierData& propertyNameData, CompletionHandler<void(bool)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->removeProperty) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !m_npObject->_class->removeProperty)
+        return completionHandler(false);
 
-    returnValue = m_npObject->_class->removeProperty(m_npObject, propertyNameData.createNPIdentifier());
+    completionHandler(m_npObject->_class->removeProperty(m_npObject, propertyNameData.createNPIdentifier()));
 }
 
-void NPObjectMessageReceiver::enumerate(bool& returnValue, Vector<NPIdentifierData>& identifiersData)
+void NPObjectMessageReceiver::enumerate(CompletionHandler<void(bool, Vector<NPIdentifierData>&&)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !NP_CLASS_STRUCT_VERSION_HAS_ENUM(m_npObject->_class) || !m_npObject->_class->enumerate) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !NP_CLASS_STRUCT_VERSION_HAS_ENUM(m_npObject->_class) || !m_npObject->_class->enumerate)
+        return completionHandler(false, { });
 
     NPIdentifier* identifiers = 0;
     uint32_t identifierCount = 0;
 
-    returnValue = m_npObject->_class->enumerate(m_npObject, &identifiers, &identifierCount);
+    bool returnValue = m_npObject->_class->enumerate(m_npObject, &identifiers, &identifierCount);
     if (!returnValue)
-        return;
+        return completionHandler(false, { });
 
+    Vector<WebKit::NPIdentifierData> identifiersData;
     for (uint32_t i = 0; i < identifierCount; ++i)
         identifiersData.append(NPIdentifierData::fromNPIdentifier(identifiers[i]));
 
     npnMemFree(identifiers);
+    completionHandler(true, WTFMove(identifiersData));
 }
 
-void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData)
+void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsData, CompletionHandler<void(bool, NPVariantData&&)>&& completionHandler)
 {
-    if (m_plugin->isBeingDestroyed() || !NP_CLASS_STRUCT_VERSION_HAS_CTOR(m_npObject->_class) || !m_npObject->_class->construct) {
-        returnValue = false;
-        return;
-    }
+    if (m_plugin->isBeingDestroyed() || !NP_CLASS_STRUCT_VERSION_HAS_CTOR(m_npObject->_class) || !m_npObject->_class->construct)
+        return completionHandler(false, { });
 
     Vector<NPVariant> arguments;
     for (size_t i = 0; i < argumentsData.size(); ++i)
@@ -222,7 +213,8 @@ void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsDa
 
     PluginController::PluginDestructionProtector protector(m_plugin->controller());
 
-    returnValue = m_npObject->_class->construct(m_npObject, arguments.data(), arguments.size(), &result);
+    bool returnValue = m_npObject->_class->construct(m_npObject, arguments.data(), arguments.size(), &result);
+    NPVariantData resultData;
     if (returnValue)
         resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin);
 
@@ -230,6 +222,7 @@ void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsDa
         releaseNPVariantValue(&arguments[i]);
     
     releaseNPVariantValue(&result);
+    completionHandler(returnValue, WTFMove(resultData));
 }
 
 } // namespace WebKit
index 2759893..1a05475 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef NPObjectMessageReceiver_h
-#define NPObjectMessageReceiver_h
+#pragma once
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
@@ -53,16 +52,16 @@ public:
     
 private:
     // Message handlers.
-    void deallocate();
-    void hasMethod(const NPIdentifierData&, bool& returnValue);
-    void invoke(const NPIdentifierData&, const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData);
-    void invokeDefault(const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData);
-    void hasProperty(const NPIdentifierData&, bool& returnValue);
-    void getProperty(const NPIdentifierData&, bool& returnValue, NPVariantData& resultData);
-    void setProperty(const NPIdentifierData&, const NPVariantData& propertyValueData, bool& returnValue);
-    void removeProperty(const NPIdentifierData&, bool& returnValue);
-    void enumerate(bool& returnValue, Vector<NPIdentifierData>& identifiersData);
-    void construct(const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData);
+    void deallocate(CompletionHandler<void()>&&);
+    void hasMethod(const NPIdentifierData&, CompletionHandler<void(bool)>&&);
+    void invoke(const NPIdentifierData&, const Vector<NPVariantData>& argumentsData, CompletionHandler<void(bool, NPVariantData&&)>&&);
+    void invokeDefault(const Vector<NPVariantData>& argumentsData, CompletionHandler<void(bool, NPVariantData&&)>&&);
+    void hasProperty(const NPIdentifierData&, CompletionHandler<void(bool)>&&);
+    void getProperty(const NPIdentifierData&, CompletionHandler<void(bool, NPVariantData&&)>&&);
+    void setProperty(const NPIdentifierData&, const NPVariantData& propertyValueData, CompletionHandler<void(bool)>&&);
+    void removeProperty(const NPIdentifierData&, CompletionHandler<void(bool)>&&);
+    void enumerate(CompletionHandler<void(bool, Vector<NPIdentifierData>&&)>&&);
+    void construct(const Vector<NPVariantData>& argumentsData, CompletionHandler<void(bool, NPVariantData&&)>&&);
 
     NPRemoteObjectMap* m_npRemoteObjectMap;
     Plugin* m_plugin;
@@ -73,6 +72,3 @@ private:
 } // namespace WebKit
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
-
-
-#endif // NPObjectMessageReceiver_h
index 0fc7f1c..6d16fa3 100644 (file)
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 messages -> NPObjectMessageReceiver LegacyReceiver {
-    Deallocate() -> () LegacySync
-    HasMethod(WebKit::NPIdentifierData methodName) -> (bool returnValue) LegacySync
-    Invoke(WebKit::NPIdentifierData methodName, Vector<WebKit::NPVariantData> argumentsData) -> (bool returnValue, WebKit::NPVariantData resultData) LegacySync
-    InvokeDefault(Vector<WebKit::NPVariantData> argumentsData) -> (bool returnValue, WebKit::NPVariantData resultData) LegacySync
-    HasProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue) LegacySync
-    GetProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue, WebKit::NPVariantData resultData) LegacySync
-    SetProperty(WebKit::NPIdentifierData propertyName, WebKit::NPVariantData propertyValueData) -> (bool returnValue) LegacySync
-    RemoveProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue) LegacySync
-    Enumerate() -> (bool returnValue, Vector<WebKit::NPIdentifierData> identifiersData) LegacySync
-    Construct(Vector<WebKit::NPVariantData> argumentsData) -> (bool returnValue, WebKit::NPVariantData resultData) LegacySync
+    Deallocate() -> () Delayed
+    HasMethod(WebKit::NPIdentifierData methodName) -> (bool returnValue) Delayed
+    Invoke(WebKit::NPIdentifierData methodName, Vector<WebKit::NPVariantData> argumentsData) -> (bool returnValue, WebKit::NPVariantData resultData) Delayed
+    InvokeDefault(Vector<WebKit::NPVariantData> argumentsData) -> (bool returnValue, WebKit::NPVariantData resultData) Delayed
+    HasProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue) Delayed
+    GetProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue, WebKit::NPVariantData resultData) Delayed
+    SetProperty(WebKit::NPIdentifierData propertyName, WebKit::NPVariantData propertyValueData) -> (bool returnValue) Delayed
+    RemoveProperty(WebKit::NPIdentifierData propertyName) -> (bool returnValue) Delayed
+    Enumerate() -> (bool returnValue, Vector<WebKit::NPIdentifierData> identifiersData) Delayed
+    Construct(Vector<WebKit::NPVariantData> argumentsData) -> (bool returnValue, WebKit::NPVariantData resultData) Delayed
 }
 
 #endif
index 729cfdd..d2bb69a 100644 (file)
@@ -60,18 +60,18 @@ void SecItemShimProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&)
 {
 }
 
-void SecItemShimProxy::secItemRequest(const SecItemRequestData& request, SecItemResponseData& response)
+void SecItemShimProxy::secItemRequest(const SecItemRequestData& request, CompletionHandler<void(SecItemResponseData&&)>&& response)
 {
     switch (request.type()) {
     case SecItemRequestData::Invalid:
         LOG_ERROR("SecItemShimProxy::secItemRequest received an invalid data request. Please file a bug if you know how you caused this.");
-        response = SecItemResponseData(errSecParam, nullptr);
+        response(SecItemResponseData(errSecParam, nullptr));
         break;
 
     case SecItemRequestData::CopyMatching: {
         CFTypeRef resultObject = 0;
         OSStatus resultCode = SecItemCopyMatching(request.query(), &resultObject);
-        response = SecItemResponseData(resultCode, adoptCF(resultObject).get());
+        response(SecItemResponseData(resultCode, adoptCF(resultObject).get()));
         break;
     }
 
@@ -79,19 +79,19 @@ void SecItemShimProxy::secItemRequest(const SecItemRequestData& request, SecItem
         // Return value of SecItemAdd is often ignored. Even if it isn't, we don't have the ability to
         // serialize SecKeychainItemRef.
         OSStatus resultCode = SecItemAdd(request.query(), nullptr);
-        response = SecItemResponseData(resultCode, nullptr);
+        response(SecItemResponseData(resultCode, nullptr));
         break;
     }
 
     case SecItemRequestData::Update: {
         OSStatus resultCode = SecItemUpdate(request.query(), request.attributesToMatch());
-        response = SecItemResponseData(resultCode, 0);
+        response(SecItemResponseData(resultCode, 0));
         break;
     }
 
     case SecItemRequestData::Delete: {
         OSStatus resultCode = SecItemDelete(request.query());
-        response = SecItemResponseData(resultCode, 0);
+        response(SecItemResponseData(resultCode, 0));
         break;
     }
     }
index edfa777..e72a102 100644 (file)
@@ -48,7 +48,7 @@ private:
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
 
-    void secItemRequest(const SecItemRequestData&, SecItemResponseData&);
+    void secItemRequest(const SecItemRequestData&, CompletionHandler<void(SecItemResponseData&&)>&&);
 
     Ref<WorkQueue> m_queue;
 };
index cd262d1..ab40ae6 100644 (file)
@@ -23,7 +23,7 @@
 messages -> SecItemShimProxy {
 
 #if ENABLE(SEC_ITEM_SHIM)
-    SecItemRequest(WebKit::SecItemRequestData request) -> (WebKit::SecItemResponseData response) LegacySync
+    SecItemRequest(WebKit::SecItemRequestData request) -> (WebKit::SecItemResponseData response) Delayed
 #endif
 
 }