Changeset 85503 in webkit


Ignore:
Timestamp:
May 2, 2011 12:41:26 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-05-02 Anders Carlsson <andersca@apple.com>

Reviewed by Adam Roben.

Need a way to handle CoreIPC messages on the connection work queue
https://bugs.webkit.org/show_bug.cgi?id=59954

Add a Connection::QueueClient abstract class. This class has a single pure virtual
member function, willProcessMessageOnClientRunLoop which should return true if the message
should be forwarded to the next Connection::QueueClient in the list or Connection::Client's
run loop for processing and false otherwise. Users of Connection can use addQueueClient to
add clients and all messages will be dispatched to the queue clients first.

  • Platform/CoreIPC/Connection.cpp: (CoreIPC::Connection::addQueueClient): (CoreIPC::Connection::removeQueueClient): (CoreIPC::Connection::processIncomingMessage):
  • Platform/CoreIPC/Connection.h: (CoreIPC::Connection::QueueClient::~QueueClient):
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r85502 r85503  
     12011-05-02  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Need a way to handle CoreIPC messages on the connection work queue
     6        https://bugs.webkit.org/show_bug.cgi?id=59954
     7
     8        Add a Connection::QueueClient abstract class. This class has a single pure virtual
     9        member function, willProcessMessageOnClientRunLoop which should return true if the message
     10        should be forwarded to the next Connection::QueueClient in the list or Connection::Client's
     11        run loop for processing and false otherwise. Users of Connection can use addQueueClient to
     12        add clients and all messages will be dispatched  to the queue clients first.
     13
     14        * Platform/CoreIPC/Connection.cpp:
     15        (CoreIPC::Connection::addQueueClient):
     16        (CoreIPC::Connection::removeQueueClient):
     17        (CoreIPC::Connection::processIncomingMessage):
     18        * Platform/CoreIPC/Connection.h:
     19        (CoreIPC::Connection::QueueClient::~QueueClient):
     20
    1212011-05-02  Jeff Miller  <jeffm@apple.com>
    222
  • trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp

    r85088 r85503  
    236236}
    237237
     238void Connection::addQueueClient(QueueClient* queueClient)
     239{
     240    MutexLocker locker(m_connectionQueueClientsMutex);
     241    ASSERT(!m_connectionQueueClients.contains(queueClient));
     242
     243    m_connectionQueueClients.append(queueClient);
     244}
     245
     246void Connection::removeQueueClient(QueueClient* queueClient)
     247{
     248    MutexLocker locker(m_connectionQueueClientsMutex);
     249    size_t index = m_connectionQueueClients.find(queueClient);
     250
     251    ASSERT(index != notFound);
     252    m_connectionQueueClients.remove(index);
     253}
     254
    238255void Connection::setDidCloseOnConnectionWorkQueueCallback(DidCloseOnConnectionWorkQueueCallback callback)
    239256{
     
    518535    }
    519536
     537    // Hand off the message to the connection queue clients.
     538    {
     539        MutexLocker locker(m_connectionQueueClientsMutex);
     540
     541        for (size_t i = 0; i < m_connectionQueueClients.size(); ++i) {
     542            if (!m_connectionQueueClients[i]->willProcessMessageOnClientRunLoop(this, incomingMessage.messageID(), incomingMessage.arguments())) {
     543                // A connection queue client handled the message, our work here is done.
     544                incomingMessage.releaseArguments();
     545                return;
     546            }
     547        }
     548    }
     549
    520550    enqueueIncomingMessage(incomingMessage);
    521551}
  • trunk/Source/WebKit2/Platform/CoreIPC/Connection.h

    r84293 r85503  
    7979public:
    8080    class MessageReceiver {
    81     protected:
    82         virtual ~MessageReceiver() { }
    83 
    8481    public:
    8582        virtual void didReceiveMessage(Connection*, MessageID, ArgumentDecoder*) = 0;
    8683        virtual SyncReplyMode didReceiveSyncMessage(Connection*, MessageID, ArgumentDecoder*, ArgumentEncoder*) { ASSERT_NOT_REACHED(); return AutomaticReply; }
     84
     85    protected:
     86        virtual ~MessageReceiver() { }
    8787    };
    8888   
    8989    class Client : public MessageReceiver {
    90     protected:
    91         virtual ~Client() { }
    92 
    9390    public:
    9491        virtual void didClose(Connection*) = 0;
     
    9996        virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply() = 0;
    10097#endif
     98
     99    protected:
     100        virtual ~Client() { }
     101    };
     102
     103    class QueueClient {
     104    public:
     105        virtual bool willProcessMessageOnClientRunLoop(Connection*, MessageID, ArgumentDecoder*) = 0;
     106
     107    protected:
     108        virtual ~QueueClient() { }
    101109    };
    102110
     
    130138    typedef void (*DidCloseOnConnectionWorkQueueCallback)(WorkQueue&, Connection*);
    131139    void setDidCloseOnConnectionWorkQueueCallback(DidCloseOnConnectionWorkQueueCallback callback);
    132                                                
     140
     141    void addQueueClient(QueueClient*);
     142    void removeQueueClient(QueueClient*);
     143
    133144    bool open();
    134145    void invalidate();
     
    234245    WorkQueue m_connectionQueue;
    235246    RunLoop* m_clientRunLoop;
     247
     248    Mutex m_connectionQueueClientsMutex;
     249    Vector<QueueClient*> m_connectionQueueClients;
    236250
    237251    unsigned m_inDispatchMessageCount;
Note: See TracChangeset for help on using the changeset viewer.