Title: [142763] trunk/Source/WebKit2
Revision
142763
Author
[email protected]
Date
2013-02-13 11:18:43 -0800 (Wed, 13 Feb 2013)

Log Message

Make SecItemShimProxy be a WorkQueueMessageReceiver
https://bugs.webkit.org/show_bug.cgi?id=109719

Reviewed by Sam Weinig.

This adds a WantsConnection message attribute to be used for messages whose handlers
should take the connection the message was delivered to.

* Platform/CoreIPC/HandleMessage.h:
(CoreIPC::handleMessage):
Add new handleMessage overload.

* Scripts/webkit2/messages.py:
(async_message_statement):
(generate_message_handler):
Handle the WantsMessage attribute.

* UIProcess/mac/SecItemShimProxy.cpp:
(WebKit::SecItemShimProxy::shared):
Use dispatch_once and adoptRef.

(WebKit::SecItemShimProxy::SecItemShimProxy):
Initialize the queue.

(WebKit::SecItemShimProxy::initializeConnection):
Add the proxy as a work queue message receiver.

(WebKit::SecItemShimProxy::secItemRequest):
This no longer needs to call out to a dispatch queue, it's already on a queue.

* UIProcess/mac/SecItemShimProxy.messages.in:
This doesn't need to be a legacy receiver. Also, add the WantsConnection message.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (142762 => 142763)


--- trunk/Source/WebKit2/ChangeLog	2013-02-13 18:51:56 UTC (rev 142762)
+++ trunk/Source/WebKit2/ChangeLog	2013-02-13 19:18:43 UTC (rev 142763)
@@ -1,3 +1,38 @@
+2013-02-13  Anders Carlsson  <[email protected]>
+
+        Make SecItemShimProxy be a WorkQueueMessageReceiver
+        https://bugs.webkit.org/show_bug.cgi?id=109719
+
+        Reviewed by Sam Weinig.
+
+        This adds a WantsConnection message attribute to be used for messages whose handlers
+        should take the connection the message was delivered to.
+        
+        * Platform/CoreIPC/HandleMessage.h:
+        (CoreIPC::handleMessage):
+        Add new handleMessage overload.
+        
+        * Scripts/webkit2/messages.py:
+        (async_message_statement):
+        (generate_message_handler):
+        Handle the WantsMessage attribute.
+
+        * UIProcess/mac/SecItemShimProxy.cpp:
+        (WebKit::SecItemShimProxy::shared):
+        Use dispatch_once and adoptRef.
+
+        (WebKit::SecItemShimProxy::SecItemShimProxy):
+        Initialize the queue.
+
+        (WebKit::SecItemShimProxy::initializeConnection):
+        Add the proxy as a work queue message receiver.
+
+        (WebKit::SecItemShimProxy::secItemRequest):
+        This no longer needs to call out to a dispatch queue, it's already on a queue.
+
+        * UIProcess/mac/SecItemShimProxy.messages.in:
+        This doesn't need to be a legacy receiver. Also, add the WantsConnection message.
+
 2013-02-13  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r142736.

Modified: trunk/Source/WebKit2/Platform/CoreIPC/HandleMessage.h (142762 => 142763)


--- trunk/Source/WebKit2/Platform/CoreIPC/HandleMessage.h	2013-02-13 18:51:56 UTC (rev 142762)
+++ trunk/Source/WebKit2/Platform/CoreIPC/HandleMessage.h	2013-02-13 19:18:43 UTC (rev 142763)
@@ -341,6 +341,15 @@
 }
 
 template<typename T, typename C, typename MF>
+void handleMessage(Connection* connection, MessageDecoder& decoder, C* object, MF function)
+{
+    typename T::DecodeType::ValueType arguments;
+    if (!decoder.decode(arguments))
+        return;
+    callMemberFunction(connection, arguments, object, function);
+}
+
+template<typename T, typename C, typename MF>
 void handleMessageOnConnectionQueue(Connection* connection, MessageDecoder& decoder, C* object, MF function)
 {
     typename T::DecodeType::ValueType arguments;

Modified: trunk/Source/WebKit2/Scripts/webkit2/messages.py (142762 => 142763)


--- trunk/Source/WebKit2/Scripts/webkit2/messages.py	2013-02-13 18:51:56 UTC (rev 142762)
+++ trunk/Source/WebKit2/Scripts/webkit2/messages.py	2013-02-13 19:18:43 UTC (rev 142763)
@@ -24,6 +24,7 @@
 import re
 from webkit2 import parser
 
+WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection'
 LEGACY_RECEIVER_ATTRIBUTE = 'LegacyReceiver'
 DELAYED_ATTRIBUTE = 'Delayed'
 DISPATCH_ON_CONNECTION_QUEUE_ATTRIBUTE = 'DispatchOnConnectionQueue'
@@ -315,10 +316,14 @@
 
 def async_message_statement(receiver, message):
     dispatch_function_args = ['decoder', 'this', '&%s' % handler_function(receiver, message)]
+
     dispatch_function = 'handleMessage'
     if message.has_attribute(VARIADIC_ATTRIBUTE):
         dispatch_function += 'Variadic'
 
+    if message.has_attribute(WANTS_CONNECTION_ATTRIBUTE):
+        dispatch_function_args.insert(0, 'connection')
+
     result = []
     result.append('    if (decoder.messageName() == Messages::%s::%s::name()) {\n' % (receiver.name, message.name))
     result.append('        CoreIPC::%s<Messages::%s::%s>(%s);\n' % (dispatch_function, receiver.name, message.name, ', '.join(dispatch_function_args)))
@@ -552,7 +557,7 @@
         if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE):
             result.append('void %s::didReceive%sMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder& decoder)\n' % (receiver.name, receiver.name))
         else:
-            result.append('void %s::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder& decoder)\n' % (receiver.name))
+            result.append('void %s::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder)\n' % (receiver.name))
 
         result.append('{\n')
         result += [async_message_statement(receiver, message) for message in async_messages]

Modified: trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.cpp (142762 => 142763)


--- trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.cpp	2013-02-13 18:51:56 UTC (rev 142762)
+++ trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.cpp	2013-02-13 19:18:43 UTC (rev 142763)
@@ -38,20 +38,25 @@
 
 SecItemShimProxy& SecItemShimProxy::shared()
 {
-    AtomicallyInitializedStatic(SecItemShimProxy*, proxy = new SecItemShimProxy);
+    static SecItemShimProxy* proxy;
+    static dispatch_once_t once;
+    dispatch_once(&once, ^{
+        proxy = adoptRef(new SecItemShimProxy).leakRef();
+    });
     return *proxy;
 }
 
 SecItemShimProxy::SecItemShimProxy()
+    : m_queue(WorkQueue::create("com.apple.WebKit.SecItemShimProxy"))
 {
 }
 
 void SecItemShimProxy::initializeConnection(CoreIPC::Connection* connection)
 {
-    connection->addQueueClient(this);
+    connection->addWorkQueueMessageReceiver(Messages::SecItemShimProxy::messageReceiverName(), m_queue.get(), this);
 }
 
-static void handleSecItemRequest(CoreIPC::Connection* connection, uint64_t requestID, const SecItemRequestData& request)
+void SecItemShimProxy::secItemRequest(CoreIPC::Connection* connection, uint64_t requestID, const SecItemRequestData& request)
 {
     SecItemResponseData response;
 
@@ -90,39 +95,6 @@
     connection->send(Messages::SecItemShim::SecItemResponse(requestID, response), 0);
 }
 
-static void dispatchFunctionOnQueue(dispatch_queue_t queue, const Function<void ()>& function)
-{
-#if COMPILER(CLANG)
-    dispatch_async(queue, function);
-#else
-    Function<void ()>* functionPtr = new Function<void ()>(function);
-    dispatch_async(queue, ^{
-        (*functionPtr)();
-        delete functionPtr;
-    });
-#endif
-}
-
-void SecItemShimProxy::secItemRequest(CoreIPC::Connection* connection, uint64_t requestID, const SecItemRequestData& request)
-{
-    // Since we don't want the connection work queue to be held up, we do all
-    // keychain interaction work on a global dispatch queue.
-    dispatch_queue_t keychainWorkQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-    dispatchFunctionOnQueue(keychainWorkQueue, bind(handleSecItemRequest, RefPtr<CoreIPC::Connection>(connection), requestID, request));
-}
-
-void SecItemShimProxy::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, OwnPtr<CoreIPC::MessageDecoder>& decoder)
-{
-    if (decoder->messageReceiverName() == Messages::SecItemShimProxy::messageReceiverName()) {
-        didReceiveSecItemShimProxyMessageOnConnectionWorkQueue(connection, decoder);
-        return;
-    }
-}
-
-void SecItemShimProxy::didCloseOnConnectionWorkQueue(CoreIPC::Connection*)
-{
-}
-
 } // namespace WebKit
 
 #endif // USE(SECURITY_FRAMEWORK)

Modified: trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.h (142762 => 142763)


--- trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.h	2013-02-13 18:51:56 UTC (rev 142762)
+++ trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.h	2013-02-13 19:18:43 UTC (rev 142763)
@@ -34,7 +34,7 @@
 
 class SecItemRequestData;
 
-class SecItemShimProxy : private CoreIPC::Connection::QueueClient {
+class SecItemShimProxy : public CoreIPC::Connection::WorkQueueMessageReceiver {
 WTF_MAKE_NONCOPYABLE(SecItemShimProxy);
 public:
     static SecItemShimProxy& shared();
@@ -44,14 +44,12 @@
 private:
     SecItemShimProxy();
 
-    // CoreIPC::Connection::QueueClient
-    virtual void didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection*, OwnPtr<CoreIPC::MessageDecoder>&) OVERRIDE;
-    virtual void didCloseOnConnectionWorkQueue(CoreIPC::Connection*) OVERRIDE;
+    // CoreIPC::Connection::WorkQueueMessageReceiver
+    virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
 
-    // Implemented in generated SecItemShimProxyMessageReceiver.cpp.
-    void didReceiveSecItemShimProxyMessageOnConnectionWorkQueue(CoreIPC::Connection*, OwnPtr<CoreIPC::MessageDecoder>&);
-
     void secItemRequest(CoreIPC::Connection*, uint64_t requestID, const SecItemRequestData&);
+
+    RefPtr<WorkQueue> m_queue;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.messages.in (142762 => 142763)


--- trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.messages.in	2013-02-13 18:51:56 UTC (rev 142762)
+++ trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.messages.in	2013-02-13 19:18:43 UTC (rev 142763)
@@ -20,10 +20,10 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-messages -> SecItemShimProxy LegacyReceiver {
+messages -> SecItemShimProxy {
 
 #if USE(SECURITY_FRAMEWORK)
-    SecItemRequest(uint64_t requestID, WebKit::SecItemRequestData request) DispatchOnConnectionQueue
+    SecItemRequest(uint64_t requestID, WebKit::SecItemRequestData request) WantsConnection
 #endif
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to