2009-03-11 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Mar 2009 20:58:54 +0000 (20:58 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Mar 2009 20:58:54 +0000 (20:58 +0000)
        Reviewed by Sam Weinig.

        WebKit side of <rdar://problem/6656147>.

        * Plugins/Hosted/NetscapePluginHostManager.mm:
        (WebKit::NetscapePluginHostManager::instantiatePlugin):
        Pass the requestID to _WKPHInstantiatePlugin.

        * Plugins/Hosted/NetscapePluginHostProxy.mm:
        Pass the requestID to setCurrentReply.

        * Plugins/Hosted/NetscapePluginInstanceProxy.h:
        (WebKit::NetscapePluginInstanceProxy::setCurrentReply):
        Store the reply in a map with the requestID as the key.

        (WebKit::NetscapePluginInstanceProxy::waitForReply):
        Wait for a reply that matches the given requestID.

        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
        (WebKit::NetscapePluginInstanceProxy::NetscapePluginInstanceProxy):
        Initialize member variables.

        (WebKit::NetscapePluginInstanceProxy::~NetscapePluginInstanceProxy):
        Delete all requests.

        (WebKit::NetscapePluginInstanceProxy::print):
        Pass the requestID to _WKPHPluginInstancePrint.

        (WebKit::NetscapePluginInstanceProxy::loadRequest):
        Rename m_currentRequestID to m_currentURLRequestID.

        (WebKit::NetscapePluginInstanceProxy::processRequestsAndWaitForReply):
        Process requests until we find a reply with the right requestID.

        (WebKit::NetscapePluginInstanceProxy::createBindingsInstance):
        Pass a requestID to the _WKPH function.

        (WebKit::NetscapePluginInstanceProxy::nextRequestID):
        Ditto.

        * Plugins/Hosted/ProxyInstance.mm:
        Pass a requestID to the _WKPH functions.

        * Plugins/Hosted/WebKitPluginClient.defs:
        * Plugins/Hosted/WebKitPluginHost.defs:
        Add requestID parameters.

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

WebKit/mac/ChangeLog
WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
WebKit/mac/Plugins/Hosted/ProxyInstance.mm
WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs
WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs

index bbda6cce39f39fc5a354f638e324c3d183988e7f..b40a0088cc075332a7c8135f15d453260d9805a7 100644 (file)
@@ -1,3 +1,52 @@
+2009-03-11  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKit side of <rdar://problem/6656147>.
+        
+        * Plugins/Hosted/NetscapePluginHostManager.mm:
+        (WebKit::NetscapePluginHostManager::instantiatePlugin):
+        Pass the requestID to _WKPHInstantiatePlugin.
+        
+        * Plugins/Hosted/NetscapePluginHostProxy.mm:
+        Pass the requestID to setCurrentReply.
+        
+        * Plugins/Hosted/NetscapePluginInstanceProxy.h:
+        (WebKit::NetscapePluginInstanceProxy::setCurrentReply):
+        Store the reply in a map with the requestID as the key.
+        
+        (WebKit::NetscapePluginInstanceProxy::waitForReply):
+        Wait for a reply that matches the given requestID.
+        
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::NetscapePluginInstanceProxy):
+        Initialize member variables.
+        
+        (WebKit::NetscapePluginInstanceProxy::~NetscapePluginInstanceProxy):
+        Delete all requests.
+        
+        (WebKit::NetscapePluginInstanceProxy::print):
+        Pass the requestID to _WKPHPluginInstancePrint.
+        
+        (WebKit::NetscapePluginInstanceProxy::loadRequest):
+        Rename m_currentRequestID to m_currentURLRequestID.
+        
+        (WebKit::NetscapePluginInstanceProxy::processRequestsAndWaitForReply):
+        Process requests until we find a reply with the right requestID.
+        
+        (WebKit::NetscapePluginInstanceProxy::createBindingsInstance):
+        Pass a requestID to the _WKPH function.
+        
+        (WebKit::NetscapePluginInstanceProxy::nextRequestID):
+        Ditto.
+        
+        * Plugins/Hosted/ProxyInstance.mm:
+        Pass a requestID to the _WKPH functions.
+        
+        * Plugins/Hosted/WebKitPluginClient.defs:
+        * Plugins/Hosted/WebKitPluginHost.defs:
+        Add requestID parameters.
+
 2009-03-11  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Darin Adler.
index b7fcbfb5cf3272958e0b71fe5874fd4aac0a247f..866258a41504e4560339004a36a54f737c95a13a 100644 (file)
@@ -214,7 +214,8 @@ PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePl
     ASSERT(data);
     
     RefPtr<NetscapePluginInstanceProxy> instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView);
-    kern_return_t kr = _WKPHInstantiatePlugin(hostProxy->port(), (uint8_t*)[data bytes], [data length], instance->pluginID());
+    uint32_t requestID = instance->nextRequestID();
+    kern_return_t kr = _WKPHInstantiatePlugin(hostProxy->port(), requestID, (uint8_t*)[data bytes], [data length], instance->pluginID());
     if (kr == MACH_SEND_INVALID_DEST) {
         // The plug-in host must have died, but we haven't received the death notification yet.
         pluginHostDied(hostProxy);
@@ -224,10 +225,11 @@ PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePl
         
         // Create a new instance.
         instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView);
-        kr = _WKPHInstantiatePlugin(hostProxy->port(), (uint8_t*)[data bytes], [data length], instance->pluginID());
+        requestID = instance->nextRequestID();
+        kr = _WKPHInstantiatePlugin(hostProxy->port(), requestID, (uint8_t*)[data bytes], [data length], instance->pluginID());
     }
 
-    auto_ptr<NetscapePluginInstanceProxy::InstantiatePluginReply> reply = instance->waitForReply<NetscapePluginInstanceProxy::InstantiatePluginReply>();
+    auto_ptr<NetscapePluginInstanceProxy::InstantiatePluginReply> reply = instance->waitForReply<NetscapePluginInstanceProxy::InstantiatePluginReply>(requestID);
     if (!reply.get() || reply->m_resultCode != KERN_SUCCESS) {
         instance->invalidate();
         return 0;
index e80c2e25489d8d2dabba81b05273161e04fa419c..b8c314aff8eb8c81ec20a44ae69fb814c2e133e1 100644 (file)
@@ -390,7 +390,7 @@ kern_return_t WKPCInvalidateRect(mach_port_t clientPort, uint32_t pluginID, doub
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCGetScriptableNPObjectReply(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID)
+kern_return_t WKPCGetScriptableNPObjectReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
 {
     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
     if (!hostProxy)
@@ -400,11 +400,11 @@ kern_return_t WKPCGetScriptableNPObjectReply(mach_port_t clientPort, uint32_t pl
     if (!instanceProxy)
         return KERN_FAILURE;
 
-    instanceProxy->setCurrentReply(new NetscapePluginInstanceProxy::GetScriptableNPObjectReply(objectID));
+    instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::GetScriptableNPObjectReply(objectID));
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCBooleanReply(mach_port_t clientPort, uint32_t pluginID, boolean_t result)
+kern_return_t WKPCBooleanReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, boolean_t result)
 {
     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
     if (!hostProxy)
@@ -414,11 +414,11 @@ kern_return_t WKPCBooleanReply(mach_port_t clientPort, uint32_t pluginID, boolea
     if (!instanceProxy)
         return KERN_FAILURE;
     
-    instanceProxy->setCurrentReply(new NetscapePluginInstanceProxy::BooleanReply(result));
+    instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::BooleanReply(result));
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCBooleanAndDataReply(mach_port_t clientPort, uint32_t pluginID, boolean_t returnValue, data_t resultData, mach_msg_type_number_t resultLength)
+kern_return_t WKPCBooleanAndDataReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, boolean_t returnValue, data_t resultData, mach_msg_type_number_t resultLength)
 {
     DataDeallocator deallocator(resultData, resultLength);
 
@@ -431,12 +431,12 @@ kern_return_t WKPCBooleanAndDataReply(mach_port_t clientPort, uint32_t pluginID,
         return KERN_FAILURE;
 
     RetainPtr<CFDataRef> result(AdoptCF, CFDataCreate(0, reinterpret_cast<UInt8*>(resultData), resultLength));
-    instanceProxy->setCurrentReply(new NetscapePluginInstanceProxy::BooleanAndDataReply(returnValue, result));
+    instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::BooleanAndDataReply(returnValue, result));
     
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCInstantiatePluginReply(mach_port_t clientPort, uint32_t pluginID, kern_return_t result, uint32_t renderContextID, boolean_t useSoftwareRenderer)
+kern_return_t WKPCInstantiatePluginReply(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, kern_return_t result, uint32_t renderContextID, boolean_t useSoftwareRenderer)
 {
     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
     if (!hostProxy)
@@ -446,7 +446,7 @@ kern_return_t WKPCInstantiatePluginReply(mach_port_t clientPort, uint32_t plugin
     if (!instanceProxy)
         return KERN_FAILURE;
 
-    instanceProxy->setCurrentReply(new NetscapePluginInstanceProxy::InstantiatePluginReply(result, renderContextID, useSoftwareRenderer));
+    instanceProxy->setCurrentReply(requestID, new NetscapePluginInstanceProxy::InstantiatePluginReply(result, renderContextID, useSoftwareRenderer));
     return KERN_SUCCESS;
 }
 
@@ -500,7 +500,7 @@ kern_return_t WKPCReleaseObject(mach_port_t clientPort, uint32_t pluginID, uint3
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID, data_t scriptData, mach_msg_type_number_t scriptLength)
+kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, data_t scriptData, mach_msg_type_number_t scriptLength)
 {
     DataDeallocator deallocator(scriptData, scriptLength);
 
@@ -521,7 +521,7 @@ kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t o
     
     boolean_t returnValue = instanceProxy->evaluate(objectID, script, resultData, resultLength);
     
-    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), returnValue, resultData, resultLength);
+    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
     mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
         
     return KERN_SUCCESS;
@@ -554,7 +554,7 @@ static Identifier identifierFromIdentifierRep(IdentifierRep* identifier)
     return Identifier(JSDOMWindow::commonJSGlobalData(), String::fromUTF8WithLatin1Fallback(str, strlen(str)));
 }
 
-kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID, uint64_t serverIdentifier,
+kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier,
                          data_t argumentsData, mach_msg_type_number_t argumentsLength) 
 {
     DataDeallocator deallocator(argumentsData, argumentsLength);
@@ -571,7 +571,7 @@ kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t obj
     
     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
     if (!IdentifierRep::isValid(identifier)) {
-        _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), false, 0, 0);
+        _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, false, 0, 0);
         return KERN_SUCCESS;
     }
 
@@ -582,13 +582,13 @@ kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t obj
     
     boolean_t returnValue = instanceProxy->invoke(objectID, methodNameIdentifier, argumentsData, argumentsLength, resultData, resultLength);
     
-    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), returnValue, resultData, resultLength);
+    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
     mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
     
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID,
+kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID,
                                 data_t argumentsData, mach_msg_type_number_t argumentsLength)
 {
     DataDeallocator deallocator(argumentsData, argumentsLength);
@@ -608,7 +608,7 @@ kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint3
     
     boolean_t returnValue = instanceProxy->invokeDefault(objectID, argumentsData, argumentsLength, resultData, resultLength);
     
-    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), returnValue, resultData, resultLength);
+    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
     mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
     
     return KERN_SUCCESS;
@@ -635,7 +635,7 @@ kern_return_t WKPCConstruct(mach_port_t clientPort, uint32_t pluginID, uint32_t
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID, uint64_t serverIdentifier)
+kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
 {
     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
     if (!hostProxy)
@@ -661,7 +661,7 @@ kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
     } else 
         returnValue = instanceProxy->setProperty(objectID, identifier->number(), resultData, resultLength);
     
-    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), returnValue, resultData, resultLength);
+    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
     mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
     
     return KERN_SUCCESS;
@@ -719,7 +719,7 @@ kern_return_t WKPCRemoveProperty(mach_port_t clientPort, uint32_t pluginID, uint
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID, uint64_t serverIdentifier)
+kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
 {
     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
     if (!hostProxy)
@@ -733,7 +733,7 @@ kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
 
     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
     if (!IdentifierRep::isValid(identifier)) {
-        _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), false);
+        _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, false);
         return KERN_SUCCESS;
     }    
     
@@ -744,12 +744,12 @@ kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_
     } else 
         returnValue = instanceProxy->hasProperty(objectID, identifier->number());
     
-    _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), returnValue);
+    _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
     
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID, uint64_t serverIdentifier)
+kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier)
 {
     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
     if (!hostProxy)
@@ -763,14 +763,14 @@ kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t
 
     IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier);
     if (!IdentifierRep::isValid(identifier)) {
-        _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), false);
+        _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, false);
         return KERN_SUCCESS;
     }
     
     Identifier methodNameIdentifier = identifierFromIdentifierRep(identifier);        
     boolean_t returnValue = instanceProxy->hasMethod(objectID, methodNameIdentifier);
 
-    _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), returnValue);
+    _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue);
 
     return KERN_SUCCESS;
 }
@@ -799,7 +799,7 @@ kern_return_t WKPCIdentifierInfo(mach_port_t clientPort, uint64_t serverIdentifi
     return KERN_SUCCESS;
 }
 
-kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t objectID)
+kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID)
 {
     NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
     if (!hostProxy)
@@ -814,7 +814,7 @@ kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t
     
     boolean_t returnValue = instanceProxy->enumerate(objectID, resultData, resultLength);
     
-    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), returnValue, resultData, resultLength);
+    _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength);
     mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength);
     
     return KERN_SUCCESS;
index ba34e0ae9dc7407479355f81e9723a7779d07032..acb3f8c2291e15246003b97d7a835e7df6a2c4e8 100644 (file)
@@ -137,6 +137,8 @@ public:
     void didCallPluginFunction();
     bool shouldStop();
     
+    uint32_t nextRequestID();
+    
     // Reply structs
     struct Reply {
         enum Type {
@@ -146,7 +148,11 @@ public:
             Boolean
         };
         
-        Reply(Type type) : m_type(type) { }
+        Reply(Type type) 
+            : m_type(type)
+        {
+        }
+        
         virtual ~Reply() { }
     
         Type m_type;
@@ -206,24 +212,23 @@ public:
         RetainPtr<CFDataRef> m_result;
     };
     
-    void setCurrentReply(Reply* reply)
+    void setCurrentReply(uint32_t requestID, Reply* reply)
     {
-        ASSERT(!m_currentReply.get());
-        m_currentReply = std::auto_ptr<Reply>(reply);
+        ASSERT(!m_replies.contains(requestID));
+        m_replies.set(requestID, reply);
     }
     
     template <typename T>
-    std::auto_ptr<T> waitForReply()
+    std::auto_ptr<T> waitForReply(uint32_t requestID)
     {
         m_waitingForReply = true;
-        
-        processRequestsAndWaitForReply();
-        
-        if (m_currentReply.get()) 
-            ASSERT(m_currentReply->m_type == T::ReplyType);
+
+        Reply* reply = processRequestsAndWaitForReply(requestID);
+        if (reply)
+            ASSERT(reply->m_type == T::ReplyType);
         
         m_waitingForReply = false;
-        return std::auto_ptr<T>(static_cast<T*>(m_currentReply.release()));
+        return std::auto_ptr<T>(static_cast<T*>(reply));
     }
     
 private:
@@ -236,7 +241,7 @@ private:
     void evaluateJavaScript(PluginRequest*);
     
     void stopAllStreams();
-    void processRequestsAndWaitForReply();
+    Reply* processRequestsAndWaitForReply(uint32_t requestID);
     
     void cleanup();
     
@@ -249,14 +254,14 @@ private:
     
     HashMap<uint32_t, RefPtr<HostedNetscapePluginStream> > m_streams;
 
-    uint32_t m_currentRequestID;
+    uint32_t m_currentURLRequestID;
     
     uint32_t m_pluginID;
     uint32_t m_renderContextID;
     boolean_t m_useSoftwareRenderer;
     
     bool m_waitingForReply;
-    std::auto_ptr<Reply> m_currentReply;
+    HashMap<uint32_t, Reply*> m_replies;
     
     // NPRuntime
     uint32_t idForObject(JSC::JSObject*);
@@ -275,6 +280,7 @@ private:
     
     unsigned m_pluginFunctionCallDepth;
     bool m_shouldStopSoon;
+    uint32_t m_currentRequestID;
 };
     
 } // namespace WebKit
index fe0f3f052cd88c119484f17cd3c504bc689c4fb5..b44ac922f771f6cc19312b3d579de949e272ba7a 100644 (file)
@@ -94,13 +94,14 @@ NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy
     : m_pluginHostProxy(pluginHostProxy)
     , m_pluginView(pluginView)
     , m_requestTimer(this, &NetscapePluginInstanceProxy::requestTimerFired)
-    , m_currentRequestID(0)
+    , m_currentURLRequestID(0)
     , m_renderContextID(0)
     , m_useSoftwareRenderer(false)
     , m_waitingForReply(false)
     , m_objectIDCounter(0)
     , m_pluginFunctionCallDepth(0)
     , m_shouldStopSoon(false)
+    , m_currentRequestID(0)
 {
     ASSERT(m_pluginView);
     
@@ -117,6 +118,7 @@ NetscapePluginInstanceProxy::~NetscapePluginInstanceProxy()
     ASSERT(!m_pluginHostProxy);
     
     m_pluginID = 0;
+    deleteAllValues(m_replies);
 }
 
 void NetscapePluginInstanceProxy::resize(NSRect size, NSRect clipRect)
@@ -258,9 +260,10 @@ void NetscapePluginInstanceProxy::insertText(NSString *text)
 
 void NetscapePluginInstanceProxy::print(CGContextRef context, unsigned width, unsigned height)
 {
-    _WKPHPluginInstancePrint(m_pluginHostProxy->port(), m_pluginID, width, height);
+    uint32_t requestID = nextRequestID();
+    _WKPHPluginInstancePrint(m_pluginHostProxy->port(), m_pluginID, requestID, width, height);
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
     if (!reply.get() || !reply->m_returnValue)
         return;
 
@@ -489,7 +492,7 @@ NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const ch
     }
     
     // FIXME: Handle wraparound
-    requestID = ++m_currentRequestID;
+    requestID = ++m_currentURLRequestID;
         
     if (cTarget || JSString) {
         // Make when targetting a frame or evaluating a JS string, perform the request after a delay because we don't
@@ -513,14 +516,17 @@ NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const ch
     return NPERR_NO_ERROR;
 }
 
-void NetscapePluginInstanceProxy::processRequestsAndWaitForReply()
+NetscapePluginInstanceProxy::Reply* NetscapePluginInstanceProxy::processRequestsAndWaitForReply(uint32_t requestID)
 {
-    while (!m_currentReply.get()) {
-        if (!m_pluginHostProxy->processRequests()) {
-            m_currentReply.reset();
-            break;
-        }
+    Reply* reply = 0;
+    
+    while (!(reply = m_replies.take(requestID))) {
+        if (!m_pluginHostProxy->processRequests())
+            return 0;
     }
+    
+    ASSERT(reply);
+    return reply;
 }
     
 uint32_t NetscapePluginInstanceProxy::idForObject(JSObject* object)
@@ -1056,10 +1062,12 @@ void NetscapePluginInstanceProxy::demarshalValues(ExecState* exec, data_t values
 
 PassRefPtr<Instance> NetscapePluginInstanceProxy::createBindingsInstance(PassRefPtr<RootObject> rootObject)
 {
-    if (_WKPHGetScriptableNPObject(m_pluginHostProxy->port(), m_pluginID) != KERN_SUCCESS)
+    uint32_t requestID = nextRequestID();
+    
+    if (_WKPHGetScriptableNPObject(m_pluginHostProxy->port(), m_pluginID, requestID) != KERN_SUCCESS)
         return 0;
     
-    auto_ptr<GetScriptableNPObjectReply> reply = waitForReply<GetScriptableNPObjectReply>();
+    auto_ptr<GetScriptableNPObjectReply> reply = waitForReply<GetScriptableNPObjectReply>(requestID);
     if (!reply.get())
         return 0;
 
@@ -1111,6 +1119,18 @@ bool NetscapePluginInstanceProxy::shouldStop()
     return true;
 }
 
+uint32_t NetscapePluginInstanceProxy::nextRequestID()
+{
+    uint32_t requestID = ++m_currentRequestID;
+    
+    // We don't want to return the HashMap empty/deleted "special keys"
+    if (requestID == 0 || requestID == static_cast<uint32_t>(-1))
+        return nextRequestID();
+    
+    return requestID;
+}
+
+
 } // namespace WebKit
 
 #endif // USE(PLUGIN_HOST_PROCESS)
index 2f230f383a4a0b2ea67ec3dd776a05c1e82c8c75..01e64ba5c14e160f7f8e4df84148521fba9a76be 100644 (file)
@@ -137,12 +137,14 @@ JSC::Bindings::Class *ProxyInstance::getClass() const
 JSValuePtr ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t identifier, const JSC::ArgList& args)
 {
     RetainPtr<NSData*> arguments(m_instanceProxy->marshalValues(exec, args));
-    
-    if (_WKPHNPObjectInvoke(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), m_objectID,
+
+    uint32_t requestID = m_instanceProxy->nextRequestID();
+
+    if (_WKPHNPObjectInvoke(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), requestID, m_objectID,
                             type, identifier, (char*)[arguments.get() bytes], [arguments.get() length]) != KERN_SUCCESS)
         return jsUndefined();
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
     if (!reply.get() || !reply->m_returnValue)
         return jsUndefined();
     
@@ -160,12 +162,14 @@ JSValuePtr ProxyInstance::invokeMethod(ExecState* exec, const MethodList& method
 
 bool ProxyInstance::supportsInvokeDefaultMethod() const
 {
+    uint32_t requestID = m_instanceProxy->nextRequestID();
+    
     if (_WKPHNPObjectHasInvokeDefaultMethod(m_instanceProxy->hostProxy()->port(),
-                                            m_instanceProxy->pluginID(),
+                                            m_instanceProxy->pluginID(), requestID,
                                             m_objectID) != KERN_SUCCESS)
         return false;
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
     if (reply.get() && reply->m_result)
         return true;
         
@@ -179,12 +183,14 @@ JSValuePtr ProxyInstance::invokeDefaultMethod(ExecState* exec, const ArgList& ar
 
 bool ProxyInstance::supportsConstruct() const
 {
+    uint32_t requestID = m_instanceProxy->nextRequestID();
+    
     if (_WKPHNPObjectHasConstructMethod(m_instanceProxy->hostProxy()->port(),
-                                        m_instanceProxy->pluginID(),
+                                        m_instanceProxy->pluginID(), requestID,
                                         m_objectID) != KERN_SUCCESS)
         return false;
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
     if (reply.get() && reply->m_result)
         return true;
         
@@ -230,10 +236,12 @@ JSValuePtr ProxyInstance::valueOf(ExecState* exec) const
 
 void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray)
 {
-    if (_WKPHNPObjectEnumerate(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), m_objectID) != KERN_SUCCESS)
+    uint32_t requestID = m_instanceProxy->nextRequestID();
+    
+    if (_WKPHNPObjectEnumerate(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), requestID, m_objectID) != KERN_SUCCESS)
         return;
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
   
     if (!reply.get() || !reply->m_returnValue)
         return;
@@ -265,12 +273,14 @@ MethodList ProxyInstance::methodsNamed(const Identifier& identifier)
     }
 
     uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(identifier.ascii()));
+    uint32_t requestID = m_instanceProxy->nextRequestID();
+    
     if (_WKPHNPObjectHasMethod(m_instanceProxy->hostProxy()->port(),
-                               m_instanceProxy->pluginID(),
+                               m_instanceProxy->pluginID(), requestID,
                                m_objectID, methodName) != KERN_SUCCESS)
         return MethodList();
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
     if (reply.get() && reply->m_result) {
         Method* method = new ProxyMethod(methodName);
         
@@ -290,12 +300,14 @@ Field* ProxyInstance::fieldNamed(const Identifier& identifier)
         return field;
     
     uint64_t propertyName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(identifier.ascii()));
+    uint32_t requestID = m_instanceProxy->nextRequestID();
+    
     if (_WKPHNPObjectHasProperty(m_instanceProxy->hostProxy()->port(),
-                                 m_instanceProxy->pluginID(),
+                                 m_instanceProxy->pluginID(), requestID,
                                  m_objectID, propertyName) != KERN_SUCCESS)
         return 0;
         
-    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
     if (reply.get() && reply->m_result) {
         Field* field = new ProxyField(propertyName);
         
@@ -310,13 +322,14 @@ Field* ProxyInstance::fieldNamed(const Identifier& identifier)
 JSC::JSValuePtr ProxyInstance::fieldValue(ExecState* exec, const Field* field) const
 {
     uint64_t serverIdentifier = static_cast<const ProxyField*>(field)->serverIdentifier();
+    uint32_t requestID = m_instanceProxy->nextRequestID();
     
     if (_WKPHNPObjectGetProperty(m_instanceProxy->hostProxy()->port(),
-                                 m_instanceProxy->pluginID(),
+                                 m_instanceProxy->pluginID(), requestID,
                                  m_objectID, serverIdentifier) != KERN_SUCCESS)
         return jsUndefined();
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
     if (!reply.get() || !reply->m_returnValue)
         return jsUndefined();
     
@@ -326,19 +339,20 @@ JSC::JSValuePtr ProxyInstance::fieldValue(ExecState* exec, const Field* field) c
 void ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValuePtr value) const
 {
     uint64_t serverIdentifier = static_cast<const ProxyField*>(field)->serverIdentifier();
+    uint32_t requestID = m_instanceProxy->nextRequestID();
     
     data_t valueData;
     mach_msg_type_number_t valueLength;
 
     m_instanceProxy->marshalValue(exec, value, valueData, valueLength);
     kern_return_t kr = _WKPHNPObjectSetProperty(m_instanceProxy->hostProxy()->port(),
-                                                m_instanceProxy->pluginID(),
+                                                m_instanceProxy->pluginID(), requestID,
                                                 m_objectID, serverIdentifier, valueData, valueLength);
     mig_deallocate(reinterpret_cast<vm_address_t>(valueData), valueLength);
     if (kr != KERN_SUCCESS)
         return;
     
-    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>();
+    auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
 }
 
 void ProxyInstance::invalidate()
index 34a294f755da229e6f47e9bef9a2a67b904d9282..61285176ab4f50b619f4521b24668558fdece6f8 100644 (file)
@@ -79,17 +79,20 @@ routine PCReleaseObject(clientPort :mach_port_t;
                       
 simpleroutine PCEvaluate(clientPort :mach_port_t;
                        pluginID :uint32_t;
+                       requestID :uint32_t;
                        objectID :uint32_t;
                        script :data_t);
 
 simpleroutine PCInvoke(clientPort :mach_port_t;
                      pluginID :uint32_t;
+                     requestID :uint32_t;
                      objectID :uint32_t;
                      methodNameIdentifier :uint64_t;
                      arguments :data_t);
 
 simpleroutine PCInvokeDefault(clientPort :mach_port_t;
                pluginID :uint32_t;
+               requestID :uint32_t;
                objectID :uint32_t;
                arguments :data_t);
 
@@ -102,6 +105,7 @@ routine PCConstruct(clientPort :mach_port_t;
 
 simpleroutine PCGetProperty(clientPort :mach_port_t;
                             pluginID :uint32_t;
+                            requestID :uint32_t;
                             objectID :uint32_t;
                             propertyNameIdentifier :uint64_t);
 
@@ -120,11 +124,13 @@ routine PCRemoveProperty(clientPort :mach_port_t;
 
 simpleroutine PCHasProperty(clientPort :mach_port_t;
                             pluginID :uint32_t;
+                            requestID :uint32_t;
                             objectID :uint32_t;
                             propertyNameIdentifier :uint64_t);
 
 simpleroutine PCHasMethod(clientPort :mach_port_t;
                            pluginID :uint32_t;
+                           requestID :uint32_t;
                            objectID :uint32_t;
                            methodNameIdentifier :uint64_t);
 
@@ -134,6 +140,7 @@ routine PCIdentifierInfo(clientPort :mach_port_t;
 
 simpleroutine PCEnumerate(clientPort :mach_port_t;
                           pluginID :uint32_t;
+                          requestID :uint32_t;
                           objectID :uint32_t);
 
 // Misc
@@ -147,21 +154,23 @@ simpleroutine PCSetModal(clientPort :mach_port_t;
 // Replies
 simpleroutine PCInstantiatePluginReply(clientPort :mach_port_t;
                                      pluginID :uint32_t;
+                                     requestID :uint32_t;
                                      result :kern_return_t;
                                      renderContextID :uint32_t;
                                      useSoftwareRenderer :boolean_t);
 
 simpleroutine PCGetScriptableNPObjectReply(clientPort :mach_port_t;
                                          pluginID :uint32_t;
+                                         requestID :uint32_t;
                                          objectID :uint32_t);
 
 simpleroutine PCBooleanReply(clientPort :mach_port_t;
                              pluginID :uint32_t;
+                             requestID :uint32_t;
                              result :boolean_t);
                            
 simpleroutine PCBooleanAndDataReply(clientPort :mach_port_t;
                                     pluginID :uint32_t;
+                                    requestID :uint32_t;
                                     returnValue :boolean_t;
                                     result :data_t);  
-
-
index 51530a0ebc0250670e4486e49a4125e4d9baf97b..c89f8485394c2dae4163d05356579a0818f12d10 100644 (file)
@@ -40,6 +40,7 @@ routine PHCheckInWithPluginHost(pluginHostPort :mach_port_t;
                               out pluginHostPSNLow :uint32_t);
 
 simpleroutine PHInstantiatePlugin(pluginHostPort :mach_port_t;
+                                requestID :uint32_t;
                                 options :plist_bytes_t;
                                 pluginID :uint32_t);
                                 
@@ -101,6 +102,7 @@ simpleroutine PHPluginInstanceStopTimers(pluginHostPort :mach_port_t;
 
 simpleroutine PHPluginInstancePrint(pluginHostPort :mach_port_t;
                                     pluginID :uint32_t;
+                                    requestID :uint32_t;
                                     width :uint32_t;
                                     height :uint32_t);
 
@@ -140,20 +142,24 @@ simpleroutine PHLoadURLNotify(pluginHostPort :mach_port_t;
 // NPRuntime
 
 simpleroutine PHGetScriptableNPObject(pluginHostPort :mach_port_t;
-                                    pluginID :uint32_t);
+                                      pluginID :uint32_t;
+                                      requestID :uint32_t);
 
 simpleroutine PHNPObjectHasProperty(pluginHostPort :mach_port_t;
                                   pluginID :uint32_t;
+                                  requestID :uint32_t;
                                   objectID :uint32_t;
                                   propertyName :uint64_t);
 
 simpleroutine PHNPObjectHasMethod(pluginHostPort :mach_port_t;
                                 pluginID :uint32_t;
+                                requestID :uint32_t;
                                 objectID :uint32_t;
                                 methodName :uint64_t);
 
 simpleroutine PHNPObjectInvoke(pluginHostPort :mach_port_t;
                              pluginID :uint32_t;
+                             requestID :uint32_t;
                              objectID :uint32_t;
                              invokeType :uint32_t;
                              methodName :uint64_t;
@@ -161,19 +167,23 @@ simpleroutine PHNPObjectInvoke(pluginHostPort :mach_port_t;
 
 simpleroutine PHNPObjectHasInvokeDefaultMethod(pluginHostPort :mach_port_t;
                                              pluginID :uint32_t;
+                                             requestID :uint32_t;
                                              objectID :uint32_t);
 
 simpleroutine PHNPObjectHasConstructMethod(pluginHostPort :mach_port_t;
                                          pluginID :uint32_t;
+                                         requestID :uint32_t;
                                          objectID :uint32_t);
                                        
 simpleroutine PHNPObjectGetProperty(pluginHostPort :mach_port_t;
                                   pluginID :uint32_t;
+                                  requestID :uint32_t;
                                   objectID :uint32_t;
                                   propertyName :uint64_t);
 
 simpleroutine PHNPObjectSetProperty(pluginHostPort :mach_port_t;
                                   pluginID :uint32_t;
+                                  requestID :uint32_t;
                                   objectID :uint32_t;
                                   propertyName :uint64_t;
                                   value :data_t);
@@ -184,15 +194,18 @@ simpleroutine PHNPObjectRelease(pluginHostPort :mach_port_t;
 
 simpleroutine PHNPObjectEnumerate(pluginHostPort :mach_port_t;
                                   pluginID :uint32_t;
+                                  requestID :uint32_t;
                                   objectID :uint32_t);
                                   
 // Replies
 
 simpleroutine PHBooleanReply(clientPort :mach_port_t;
                              pluginID :uint32_t;
+                             requestID :uint32_t;
                              result :boolean_t);
                            
 simpleroutine PHBooleanAndDataReply(pluginHostPort :mach_port_t;
                                     pluginID :uint32_t;
+                                    requestID :uint32_t;
                                     returnValue :boolean_t;
                                     result :data_t);