Changeset 142763 in webkit


Ignore:
Timestamp:
Feb 13, 2013 11:18:43 AM (11 years ago)
Author:
andersca@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r142762 r142763  
     12013-02-13  Anders Carlsson  <andersca@apple.com>
     2
     3        Make SecItemShimProxy be a WorkQueueMessageReceiver
     4        https://bugs.webkit.org/show_bug.cgi?id=109719
     5
     6        Reviewed by Sam Weinig.
     7
     8        This adds a WantsConnection message attribute to be used for messages whose handlers
     9        should take the connection the message was delivered to.
     10       
     11        * Platform/CoreIPC/HandleMessage.h:
     12        (CoreIPC::handleMessage):
     13        Add new handleMessage overload.
     14       
     15        * Scripts/webkit2/messages.py:
     16        (async_message_statement):
     17        (generate_message_handler):
     18        Handle the WantsMessage attribute.
     19
     20        * UIProcess/mac/SecItemShimProxy.cpp:
     21        (WebKit::SecItemShimProxy::shared):
     22        Use dispatch_once and adoptRef.
     23
     24        (WebKit::SecItemShimProxy::SecItemShimProxy):
     25        Initialize the queue.
     26
     27        (WebKit::SecItemShimProxy::initializeConnection):
     28        Add the proxy as a work queue message receiver.
     29
     30        (WebKit::SecItemShimProxy::secItemRequest):
     31        This no longer needs to call out to a dispatch queue, it's already on a queue.
     32
     33        * UIProcess/mac/SecItemShimProxy.messages.in:
     34        This doesn't need to be a legacy receiver. Also, add the WantsConnection message.
     35
    1362013-02-13  Sheriff Bot  <webkit.review.bot@gmail.com>
    237
  • trunk/Source/WebKit2/Platform/CoreIPC/HandleMessage.h

    r141648 r142763  
    342342
    343343template<typename T, typename C, typename MF>
     344void handleMessage(Connection* connection, MessageDecoder& decoder, C* object, MF function)
     345{
     346    typename T::DecodeType::ValueType arguments;
     347    if (!decoder.decode(arguments))
     348        return;
     349    callMemberFunction(connection, arguments, object, function);
     350}
     351
     352template<typename T, typename C, typename MF>
    344353void handleMessageOnConnectionQueue(Connection* connection, MessageDecoder& decoder, C* object, MF function)
    345354{
  • trunk/Source/WebKit2/Scripts/webkit2/messages.py

    r142690 r142763  
    2525from webkit2 import parser
    2626
     27WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection'
    2728LEGACY_RECEIVER_ATTRIBUTE = 'LegacyReceiver'
    2829DELAYED_ATTRIBUTE = 'Delayed'
     
    316317def async_message_statement(receiver, message):
    317318    dispatch_function_args = ['decoder', 'this', '&%s' % handler_function(receiver, message)]
     319
    318320    dispatch_function = 'handleMessage'
    319321    if message.has_attribute(VARIADIC_ATTRIBUTE):
    320322        dispatch_function += 'Variadic'
     323
     324    if message.has_attribute(WANTS_CONNECTION_ATTRIBUTE):
     325        dispatch_function_args.insert(0, 'connection')
    321326
    322327    result = []
     
    553558            result.append('void %s::didReceive%sMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder& decoder)\n' % (receiver.name, receiver.name))
    554559        else:
    555             result.append('void %s::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder& decoder)\n' % (receiver.name))
     560            result.append('void %s::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder)\n' % (receiver.name))
    556561
    557562        result.append('{\n')
  • trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.cpp

    r142656 r142763  
    3939SecItemShimProxy& SecItemShimProxy::shared()
    4040{
    41     AtomicallyInitializedStatic(SecItemShimProxy*, proxy = new SecItemShimProxy);
     41    static SecItemShimProxy* proxy;
     42    static dispatch_once_t once;
     43    dispatch_once(&once, ^{
     44        proxy = adoptRef(new SecItemShimProxy).leakRef();
     45    });
    4246    return *proxy;
    4347}
    4448
    4549SecItemShimProxy::SecItemShimProxy()
     50    : m_queue(WorkQueue::create("com.apple.WebKit.SecItemShimProxy"))
    4651{
    4752}
     
    4954void SecItemShimProxy::initializeConnection(CoreIPC::Connection* connection)
    5055{
    51     connection->addQueueClient(this);
     56    connection->addWorkQueueMessageReceiver(Messages::SecItemShimProxy::messageReceiverName(), m_queue.get(), this);
    5257}
    5358
    54 static void handleSecItemRequest(CoreIPC::Connection* connection, uint64_t requestID, const SecItemRequestData& request)
     59void SecItemShimProxy::secItemRequest(CoreIPC::Connection* connection, uint64_t requestID, const SecItemRequestData& request)
    5560{
    5661    SecItemResponseData response;
     
    9196}
    9297
    93 static void dispatchFunctionOnQueue(dispatch_queue_t queue, const Function<void ()>& function)
    94 {
    95 #if COMPILER(CLANG)
    96     dispatch_async(queue, function);
    97 #else
    98     Function<void ()>* functionPtr = new Function<void ()>(function);
    99     dispatch_async(queue, ^{
    100         (*functionPtr)();
    101         delete functionPtr;
    102     });
    103 #endif
    104 }
    105 
    106 void SecItemShimProxy::secItemRequest(CoreIPC::Connection* connection, uint64_t requestID, const SecItemRequestData& request)
    107 {
    108     // Since we don't want the connection work queue to be held up, we do all
    109     // keychain interaction work on a global dispatch queue.
    110     dispatch_queue_t keychainWorkQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    111     dispatchFunctionOnQueue(keychainWorkQueue, bind(handleSecItemRequest, RefPtr<CoreIPC::Connection>(connection), requestID, request));
    112 }
    113 
    114 void SecItemShimProxy::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, OwnPtr<CoreIPC::MessageDecoder>& decoder)
    115 {
    116     if (decoder->messageReceiverName() == Messages::SecItemShimProxy::messageReceiverName()) {
    117         didReceiveSecItemShimProxyMessageOnConnectionWorkQueue(connection, decoder);
    118         return;
    119     }
    120 }
    121 
    122 void SecItemShimProxy::didCloseOnConnectionWorkQueue(CoreIPC::Connection*)
    123 {
    124 }
    125 
    12698} // namespace WebKit
    12799
  • trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.h

    r142656 r142763  
    3535class SecItemRequestData;
    3636
    37 class SecItemShimProxy : private CoreIPC::Connection::QueueClient {
     37class SecItemShimProxy : public CoreIPC::Connection::WorkQueueMessageReceiver {
    3838WTF_MAKE_NONCOPYABLE(SecItemShimProxy);
    3939public:
     
    4545    SecItemShimProxy();
    4646
    47     // CoreIPC::Connection::QueueClient
    48     virtual void didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection*, OwnPtr<CoreIPC::MessageDecoder>&) OVERRIDE;
    49     virtual void didCloseOnConnectionWorkQueue(CoreIPC::Connection*) OVERRIDE;
    50 
    51     // Implemented in generated SecItemShimProxyMessageReceiver.cpp.
    52     void didReceiveSecItemShimProxyMessageOnConnectionWorkQueue(CoreIPC::Connection*, OwnPtr<CoreIPC::MessageDecoder>&);
     47    // CoreIPC::Connection::WorkQueueMessageReceiver
     48    virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
    5349
    5450    void secItemRequest(CoreIPC::Connection*, uint64_t requestID, const SecItemRequestData&);
     51
     52    RefPtr<WorkQueue> m_queue;
    5553};
    5654
  • trunk/Source/WebKit2/UIProcess/mac/SecItemShimProxy.messages.in

    r140605 r142763  
    2121# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2222
    23 messages -> SecItemShimProxy LegacyReceiver {
     23messages -> SecItemShimProxy {
    2424
    2525#if USE(SECURITY_FRAMEWORK)
    26     SecItemRequest(uint64_t requestID, WebKit::SecItemRequestData request) DispatchOnConnectionQueue
     26    SecItemRequest(uint64_t requestID, WebKit::SecItemRequestData request) WantsConnection
    2727#endif
    2828
Note: See TracChangeset for help on using the changeset viewer.