Title: [90328] trunk/Source/WebKit2
Revision
90328
Author
[email protected]
Date
2011-07-02 16:55:54 -0700 (Sat, 02 Jul 2011)

Log Message

2011-07-02  Anders Carlsson  <[email protected]>

        Implement NPN_PluginThreadAsyncCall
        https://bugs.webkit.org/show_bug.cgi?id=63868

        Reviewed by Dan Bernstein.

        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
        (WebKit::NPN_PluginThreadAsyncCall):
        Call NetscapePlugin::pluginThreadAsyncCall.

        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
        (WebKit::NetscapePlugin::pluginThreadAsyncCall):
        Schedule a work item to call the function on the main run loop.

        (WebKit::NetscapePlugin::handlePluginThreadAsyncCall):
        If the plug-in is still running, run the function.

        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
        Add new member function.

        * WebProcess/Plugins/Plugin.h:
        Make plug-in inherit from ThreadSafeRefCounted since plug-ins can potentially
        ref the plug-in from other threads.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (90327 => 90328)


--- trunk/Source/WebKit2/ChangeLog	2011-07-02 23:41:26 UTC (rev 90327)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-02 23:55:54 UTC (rev 90328)
@@ -1,5 +1,30 @@
 2011-07-02  Anders Carlsson  <[email protected]>
 
+        Implement NPN_PluginThreadAsyncCall
+        https://bugs.webkit.org/show_bug.cgi?id=63868
+
+        Reviewed by Dan Bernstein.
+
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_PluginThreadAsyncCall):
+        Call NetscapePlugin::pluginThreadAsyncCall.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::pluginThreadAsyncCall):
+        Schedule a work item to call the function on the main run loop.
+
+        (WebKit::NetscapePlugin::handlePluginThreadAsyncCall):
+        If the plug-in is still running, run the function.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        Add new member function.
+
+        * WebProcess/Plugins/Plugin.h:
+        Make plug-in inherit from ThreadSafeRefCounted since plug-ins can potentially
+        ref the plug-in from other threads.
+
+2011-07-02  Anders Carlsson  <[email protected]>
+
         Fix Windows build.
 
         * WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp:

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (90327 => 90328)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-07-02 23:41:26 UTC (rev 90327)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-07-02 23:55:54 UTC (rev 90328)
@@ -797,9 +797,11 @@
     return false;
 }
 
-static void NPN_PluginThreadAsyncCall(NPP instance, void (*func) (void*), void* userData)
+static void NPN_PluginThreadAsyncCall(NPP npp, void (*function)(void*), void* userData)
 {
-    notImplemented();
+    RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+
+    plugin->pluginThreadAsyncCall(function, userData);
 }
 
 static bool NPN_Construct(NPP npp, NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (90327 => 90328)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-07-02 23:41:26 UTC (rev 90327)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-07-02 23:55:54 UTC (rev 90328)
@@ -31,6 +31,7 @@
 #include "NetscapePluginStream.h"
 #include "PluginController.h"
 #include "ShareableBitmap.h"
+#include "WorkItem.h"
 #include <WebCore/GraphicsContext.h>
 #include <WebCore/HTTPHeaderMap.h>
 #include <WebCore/IntRect.h>
@@ -289,6 +290,19 @@
     m_popupEnabledStates.removeLast();
 }
 
+void NetscapePlugin::pluginThreadAsyncCall(void (*function)(void*), void* userData)
+{
+    RunLoop::main()->scheduleWork(WorkItem::create(this, &NetscapePlugin::handlePluginThreadAsyncCall, function, userData));
+}
+    
+void NetscapePlugin::handlePluginThreadAsyncCall(void (*function)(void*), void* userData)
+{
+    if (!m_isStarted)
+        return;
+
+    function(userData);
+}
+
 String NetscapePlugin::proxiesForURL(const String& urlString)
 {
     return controller()->proxiesForURL(urlString);

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (90327 => 90328)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-07-02 23:41:26 UTC (rev 90327)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-07-02 23:55:54 UTC (rev 90328)
@@ -101,6 +101,11 @@
     void pushPopupsEnabledState(bool enabled);
     void popPopupsEnabledState();
 
+    void pluginThreadAsyncCall(void (*function)(void*), void* userData);
+
+    // Called on the plug-in run loop (which is currently the main thread run loop).
+    void handlePluginThreadAsyncCall(void (*function)(void*), void* userData);
+
     String proxiesForURL(const String& urlString);
     String cookiesForURL(const String& urlString);
     void setCookiesForURL(const String& urlString, const String& cookieString);

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (90327 => 90328)


--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2011-07-02 23:41:26 UTC (rev 90327)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2011-07-02 23:55:54 UTC (rev 90328)
@@ -52,7 +52,7 @@
     
 class PluginController;
 
-class Plugin : public RefCounted<Plugin> {
+class Plugin : public ThreadSafeRefCounted<Plugin> {
 public:
     struct Parameters {
         WebCore::KURL url;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to