Title: [136762] trunk/Source/WebKit2
Revision
136762
Author
ander...@apple.com
Date
2012-12-05 14:16:44 -0800 (Wed, 05 Dec 2012)

Log Message

Connection::waitForMessage shouldn't use the message ID
https://bugs.webkit.org/show_bug.cgi?id=104157

Reviewed by Andreas Kling.

Pass the message receiver name and message name to waitForMessage and use them for lookups instead of
the message ID.

* Platform/CoreIPC/Connection.cpp:
(CoreIPC::Connection::createSyncMessageEncoder):
(CoreIPC::Connection::waitForMessage):
(CoreIPC::Connection::processIncomingMessage):
* Platform/CoreIPC/Connection.h:
(CoreIPC::Connection::waitForAndDispatchImmediately):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (136761 => 136762)


--- trunk/Source/WebKit2/ChangeLog	2012-12-05 22:12:55 UTC (rev 136761)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-05 22:16:44 UTC (rev 136762)
@@ -1,3 +1,20 @@
+2012-12-05  Anders Carlsson  <ander...@apple.com>
+
+        Connection::waitForMessage shouldn't use the message ID
+        https://bugs.webkit.org/show_bug.cgi?id=104157
+
+        Reviewed by Andreas Kling.
+
+        Pass the message receiver name and message name to waitForMessage and use them for lookups instead of
+        the message ID.
+
+        * Platform/CoreIPC/Connection.cpp:
+        (CoreIPC::Connection::createSyncMessageEncoder):
+        (CoreIPC::Connection::waitForMessage):
+        (CoreIPC::Connection::processIncomingMessage):
+        * Platform/CoreIPC/Connection.h:
+        (CoreIPC::Connection::waitForAndDispatchImmediately):
+
 2012-12-05  Jae Hyun Park  <jae.p...@company100.net>
 
         Coordinated Graphics: Move AreaAllocator and UpdateAtlas to CoordinatedGraphics

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp (136761 => 136762)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp	2012-12-05 22:12:55 UTC (rev 136761)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp	2012-12-05 22:16:44 UTC (rev 136762)
@@ -283,7 +283,7 @@
     m_didReceiveInvalidMessage = true;
 }
 
-PassOwnPtr<MessageEncoder> Connection::createSyncMessageEncoder(const StringReference messageReceiverName, const StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID)
+PassOwnPtr<MessageEncoder> Connection::createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID)
 {
     OwnPtr<MessageEncoder> encoder = MessageEncoder::create(messageReceiverName, messageName, destinationID);
 
@@ -319,7 +319,7 @@
     return sendMessage(MessageID(CoreIPCMessage::SyncMessageReply), encoder);
 }
 
-PassOwnPtr<MessageDecoder> Connection::waitForMessage(MessageID messageID, uint64_t destinationID, double timeout)
+PassOwnPtr<MessageDecoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, double timeout)
 {
     // First, check if this message is already in the incoming messages queue.
     {
@@ -328,7 +328,7 @@
         for (Deque<IncomingMessage>::iterator it = m_incomingMessages.begin(), end = m_incomingMessages.end(); it != end; ++it) {
             IncomingMessage& message = *it;
 
-            if (message.messageID() == messageID && message.arguments()->destinationID() == destinationID) {
+            if (message.arguments()->messageReceiverName() == messageReceiverName && message.arguments()->messageName() == messageName && message.arguments()->destinationID() == destinationID) {
                 OwnPtr<MessageDecoder> decoder = message.releaseArguments();
 
                 m_incomingMessages.remove(it);
@@ -336,10 +336,10 @@
             }
         }
     }
-    
+
     double absoluteTime = currentTime() + timeout;
     
-    std::pair<unsigned, uint64_t> messageAndDestination(std::make_pair(messageID.toInt(), destinationID));
+    std::pair<std::pair<StringReference, StringReference>, uint64_t> messageAndDestination(std::make_pair(std::make_pair(messageReceiverName, messageName), destinationID));
     
     {
         MutexLocker locker(m_waitForMessageMutex);
@@ -348,20 +348,18 @@
         ASSERT(!m_waitForMessageMap.contains(messageAndDestination));
     
         // Insert our pending wait.
-        m_waitForMessageMap.set(messageAndDestination, 0);
+        m_waitForMessageMap.set(messageAndDestination, nullptr);
     }
     
     // Now wait for it to be set.
     while (true) {
         MutexLocker locker(m_waitForMessageMutex);
 
-        HashMap<std::pair<unsigned, uint64_t>, MessageDecoder*>::iterator it = m_waitForMessageMap.find(messageAndDestination);
+        HashMap<std::pair<std::pair<StringReference, StringReference>, uint64_t>, OwnPtr<MessageDecoder> >::iterator it = m_waitForMessageMap.find(messageAndDestination);
         if (it->value) {
-            // FIXME: m_waitForMessageMap should really hold OwnPtrs to
-            // ArgumentDecoders, but HashMap doesn't currently support OwnPtrs.
-            OwnPtr<MessageDecoder> decoder = adoptPtr(it->value);
+            OwnPtr<MessageDecoder> decoder = it->value.release();
             m_waitForMessageMap.remove(it);
-            
+
             return decoder.release();
         }
         
@@ -373,7 +371,7 @@
             break;
         }
     }
-    
+
     return nullptr;
 }
 
@@ -523,10 +521,10 @@
     // Check if we're waiting for this message.
     {
         MutexLocker locker(m_waitForMessageMutex);
-        
-        HashMap<std::pair<unsigned, uint64_t>, MessageDecoder*>::iterator it = m_waitForMessageMap.find(std::make_pair(messageID.toInt(), incomingMessage.destinationID()));
+
+        HashMap<std::pair<std::pair<StringReference, StringReference>, uint64_t>, OwnPtr<MessageDecoder> >::iterator it = m_waitForMessageMap.find(std::make_pair(std::make_pair(incomingMessage.arguments()->messageReceiverName(), incomingMessage.arguments()->messageName()), incomingMessage.destinationID()));
         if (it != m_waitForMessageMap.end()) {
-            it->value = incomingMessage.releaseArguments().leakPtr();
+            it->value = incomingMessage.releaseArguments();
             ASSERT(it->value);
         
             m_waitForMessageCondition.signal();

Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.h (136761 => 136762)


--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2012-12-05 22:12:55 UTC (rev 136761)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.h	2012-12-05 22:16:44 UTC (rev 136762)
@@ -242,7 +242,7 @@
     
     bool isValid() const { return m_client; }
     
-    PassOwnPtr<MessageDecoder> waitForMessage(MessageID, uint64_t destinationID, double timeout);
+    PassOwnPtr<MessageDecoder> waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, double timeout);
     
     PassOwnPtr<MessageDecoder> waitForSyncReply(uint64_t syncRequestID, double timeout, unsigned syncSendFlags);
 
@@ -300,7 +300,7 @@
     
     ThreadCondition m_waitForMessageCondition;
     Mutex m_waitForMessageMutex;
-    HashMap<std::pair<unsigned, uint64_t>, MessageDecoder*> m_waitForMessageMap;
+    HashMap<std::pair<std::pair<StringReference, StringReference>, uint64_t>, OwnPtr<MessageDecoder> > m_waitForMessageMap;
 
     // Represents a sync request for which we're waiting on a reply.
     struct PendingSyncReply {
@@ -426,7 +426,7 @@
 
 template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, double timeout)
 {
-    OwnPtr<MessageDecoder> decoder = waitForMessage(MessageID(T::messageID), destinationID, timeout);
+    OwnPtr<MessageDecoder> decoder = waitForMessage(T::receiverName(), T::name(), destinationID, timeout);
     if (!decoder)
         return false;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to