diff options
author | vangelis@google.com <vangelis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 18:10:53 +0000 |
---|---|---|
committer | vangelis@google.com <vangelis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 18:10:53 +0000 |
commit | ee7c5cea02327013f7d00cb022788b9e8c14419b (patch) | |
tree | 91f9792ebfbadc25089bc2cfe12db79074aa6b1c /o3d/plugin/cross | |
parent | af06edfdb5cbadd788c0f3f412b64f3e1f047a3d (diff) | |
download | chromium_src-ee7c5cea02327013f7d00cb022788b9e8c14419b.zip chromium_src-ee7c5cea02327013f7d00cb022788b9e8c14419b.tar.gz chromium_src-ee7c5cea02327013f7d00cb022788b9e8c14419b.tar.bz2 |
Switching asynchronous tick callback in chrome to use the empty data url method instead of NPN_PluginThreadAsyncCall. NPN_PluginThreadAsyncCall causes Chrome to misbehave including freezing up when closing tabs (http://code.google.com/p/o3d/issues/detail?id=149).
Review URL: http://codereview.chromium.org/235059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27634 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin/cross')
-rw-r--r-- | o3d/plugin/cross/o3d_glue.cc | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/o3d/plugin/cross/o3d_glue.cc b/o3d/plugin/cross/o3d_glue.cc index 5911285..91a12f7 100644 --- a/o3d/plugin/cross/o3d_glue.cc +++ b/o3d/plugin/cross/o3d_glue.cc @@ -847,15 +847,46 @@ void PluginObject::AsyncTick() { ++pending_ticks_; - // Invoke Tick asynchronously if NPN_PluginThreadAsyncCall is supported. - // Otherwise invoke it synchronously. - int plugin_major, plugin_minor, browser_major, browser_minor; - NPN_Version(&plugin_major, &plugin_minor, &browser_major, &browser_minor); - if (browser_major > 0 || - browser_minor >= NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) { - NPN_PluginThreadAsyncCall(npp_, TickPluginObject, this); + // In Chrome NPN_PluginThreadAsyncCall doesn't seem to function properly. + // We resort to loading a data: url with zero bytes to get a tick callback + // asynchronously. + // TODO(vangelis): Remove this special path when Chrome's + // NPN_PluginThreadAsyncCall is fixed. + if (IsChrome()) { + class TickCallback : public StreamManager::FinishedCallback { + public: + explicit TickCallback(PluginObject* plugin_object) + : plugin_object_(plugin_object) { + } + + virtual void Run(DownloadStream*, + bool, + const std::string&, + const std::string&) { + plugin_object_->Tick(); + } + + private: + PluginObject* plugin_object_; + }; + + if (!stream_manager_->LoadURL("data:,", NULL, NULL, NULL, + new TickCallback(this), NP_NORMAL)) { + DLOG(ERROR) << "Chrome failed to access data url"; + // If the async call fails then tick synchronously. + Tick(); + } } else { - Tick(); + // Invoke Tick asynchronously if NPN_PluginThreadAsyncCall is supported. + // Otherwise invoke it synchronously. + int plugin_major, plugin_minor, browser_major, browser_minor; + NPN_Version(&plugin_major, &plugin_minor, &browser_major, &browser_minor); + if (browser_major > 0 || + browser_minor >= NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) { + NPN_PluginThreadAsyncCall(npp_, TickPluginObject, this); + } else { + Tick(); + } } } |