summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
authoramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 21:02:00 +0000
committeramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-13 21:02:00 +0000
commit9ee23c5ba23ad61130471514e874ccefcc7ea25c (patch)
treea9fcb7bbd32575c9839ad6dab6a967d44451171d /webkit/glue/plugins
parent8abd2aa9413476480e6607aee8293cc62366a1a8 (diff)
downloadchromium_src-9ee23c5ba23ad61130471514e874ccefcc7ea25c.zip
chromium_src-9ee23c5ba23ad61130471514e874ccefcc7ea25c.tar.gz
chromium_src-9ee23c5ba23ad61130471514e874ccefcc7ea25c.tar.bz2
Remove the carbon event dispatcher from the main thread of the plugin process
and replace it with a pump for null events on the plugin thread. This removes a deadlock that the previous code inadvertently created, and is a much more focused solution to the problem. BUG=10809 TEST=none Review URL: http://codereview.chromium.org/155439 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h8
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm30
2 files changed, 31 insertions, 7 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 35302dc7..4d928ab 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -272,6 +272,14 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
static HCURSOR WINAPI SetCursorPatch(HCURSOR cursor);
#endif
+#if defined(OS_MACOSX)
+ // Runnable Method Factory used to drip null events into the plugin
+ ScopedRunnableMethodFactory<WebPluginDelegateImpl> null_event_factory_;
+
+ // indicates that it's time to send the plugin a null event
+ void OnNullEvent();
+#endif
+
// Holds the current cursor set by the windowless plugin.
WebCursor current_windowless_cursor_;
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 9232fca..c6d0d5a 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -38,16 +38,15 @@ using WebKit::WebMouseEvent;
namespace {
-// The fastest we are willing to process idle events for Flash.
-// Flash can easily exceed the limits of our CPU if we don't throttle it.
-// The throttle has been chosen by testing various delays and compromising
-// on acceptable Flash performance and reasonable CPU consumption.
+// The fastest we are willing to process idle events for plugins.
+// Some can easily exceed the limits of our CPU if we don't throttle them.
+// The throttle has been chosen by using the same value as Apple's WebKit port.
//
// We'd like to make the throttle delay variable, based on the amount of
-// time currently required to paint Flash plugins. There isn't a good
+// time currently required to paint plugins. There isn't a good
// way to count the time spent in aggregate plugin painting, however, so
// this seems to work well enough.
-const int kFlashIdleThrottleDelayMs = 20; // 20ms (50Hz)
+const int kPluginIdleThrottleDelayMs = 20; // 20ms (50Hz)
// The current instance of the plugin which entered the modal loop.
WebPluginDelegateImpl* g_current_plugin_instance = NULL;
@@ -84,7 +83,8 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
windowless_needs_set_window_(true),
handle_event_depth_(0),
user_gesture_message_posted_(this),
- user_gesture_msg_factory_(this) {
+ user_gesture_msg_factory_(this),
+ null_event_factory_(this) {
memset(&window_, 0, sizeof(window_));
}
@@ -126,6 +126,10 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url,
plugin->SetWindow(NULL);
plugin_url_ = url.spec();
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ null_event_factory_.NewRunnableMethod(
+ &WebPluginDelegateImpl::OnNullEvent),
+ kPluginIdleThrottleDelayMs);
return true;
}
@@ -507,3 +511,15 @@ void WebPluginDelegateImpl::URLRequestRouted(const std::string&url,
instance()->SetURLLoadData(GURL(url.c_str()), notify_data);
}
}
+
+void WebPluginDelegateImpl::OnNullEvent() {
+ NPEvent np_event = {0};
+ np_event.what = nullEvent;
+ np_event.when = TickCount();
+ instance()->NPP_HandleEvent(&np_event);
+
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ null_event_factory_.NewRunnableMethod(
+ &WebPluginDelegateImpl::OnNullEvent),
+ kPluginIdleThrottleDelayMs);
+}