diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 20:14:17 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 20:14:17 +0000 |
commit | 8ad72d593603097cc468e5c308db81aa26613fff (patch) | |
tree | 799b2ebec6c975f1fd06eaff27a82977b2125adb /chrome/plugin | |
parent | 2df19bbe98514cda5a61d0805b62beacd85a85d0 (diff) | |
download | chromium_src-8ad72d593603097cc468e5c308db81aa26613fff.zip chromium_src-8ad72d593603097cc468e5c308db81aa26613fff.tar.gz chromium_src-8ad72d593603097cc468e5c308db81aa26613fff.tar.bz2 |
Fix for the missing plugin message displayed at times on sites like youtube while playing
playlists, etc. The message is displayed when we fail to create a channel for the plugin
process.
The problem occurs because of a race condition between the plugin channel information being
deleted from the channel map and the actual channel being deleted. This race occurs if
the plugin is in the context of a sync call to the renderer which results in the plugin
instance being deleted and the new one getting created in the same context. This results
in the plugin channel information getting deleted from the map. The actual channel gets
deleted only when the plugin sync call unwinds which occurs after the browser sends in
a request to create the channel for the new plugin instance.
Fix is to create the channel name with an incrementing number in the plugin process, if
the mode is server. The channel map is still keyed off the process id and renderer id
as before.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=43595
Bug=43595
Test=Covered by new ui test SelfDeleteCreatePluginInNPNEvaluate.
The other change is a fix in the test plugin to delete a windows timer correctly and
to add support for a new plugin test case.
Review URL: http://codereview.chromium.org/3142039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/plugin_channel.cc | 4 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel_base.cc | 15 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel_base.h | 2 |
3 files changed, 14 insertions, 7 deletions
diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index 2ea37be..941db8c 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -136,12 +136,12 @@ class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter { PluginChannel* PluginChannel::GetPluginChannel(int renderer_id, MessageLoop* ipc_message_loop) { // Map renderer ID to a (single) channel to that process. - std::string channel_name = StringPrintf( + std::string channel_key = StringPrintf( "%d.r%d", base::GetCurrentProcId(), renderer_id); PluginChannel* channel = static_cast<PluginChannel*>(PluginChannelBase::GetChannel( - channel_name, + channel_key, IPC::Channel::MODE_SERVER, ClassFactory, ipc_message_loop, diff --git a/chrome/plugin/plugin_channel_base.cc b/chrome/plugin/plugin_channel_base.cc index 5d18654..df7cccc 100644 --- a/chrome/plugin/plugin_channel_base.cc +++ b/chrome/plugin/plugin_channel_base.cc @@ -9,6 +9,7 @@ #include "base/auto_reset.h" #include "base/hash_tables.h" #include "base/lazy_instance.h" +#include "base/string_number_conversions.h" #include "chrome/common/child_process.h" #include "ipc/ipc_sync_message.h" @@ -24,13 +25,15 @@ static PluginChannelMap g_plugin_channels_; static base::LazyInstance<std::stack<scoped_refptr<PluginChannelBase> > > lazy_plugin_channel_stack_(base::LINKER_INITIALIZED); +static int next_pipe_id = 0; + PluginChannelBase* PluginChannelBase::GetChannel( - const std::string& channel_name, IPC::Channel::Mode mode, + const std::string& channel_key, IPC::Channel::Mode mode, PluginChannelFactory factory, MessageLoop* ipc_message_loop, bool create_pipe_now) { scoped_refptr<PluginChannelBase> channel; - PluginChannelMap::const_iterator iter = g_plugin_channels_.find(channel_name); + PluginChannelMap::const_iterator iter = g_plugin_channels_.find(channel_key); if (iter == g_plugin_channels_.end()) { channel = factory(); } else { @@ -40,10 +43,14 @@ PluginChannelBase* PluginChannelBase::GetChannel( DCHECK(channel != NULL); if (!channel->channel_valid()) { - channel->channel_name_ = channel_name; + channel->channel_name_ = channel_key; + if (mode == IPC::Channel::MODE_SERVER) { + channel->channel_name_.append("."); + channel->channel_name_.append(base::IntToString(next_pipe_id++)); + } channel->mode_ = mode; if (channel->Init(ipc_message_loop, create_pipe_now)) { - g_plugin_channels_[channel_name] = channel; + g_plugin_channels_[channel_key] = channel; } else { channel = NULL; } diff --git a/chrome/plugin/plugin_channel_base.h b/chrome/plugin/plugin_channel_base.h index a67049a..30fdc22 100644 --- a/chrome/plugin/plugin_channel_base.h +++ b/chrome/plugin/plugin_channel_base.h @@ -75,7 +75,7 @@ class PluginChannelBase : public IPC::Channel::Listener, // must still ref count the returned value. When there are no more routes // on the channel and its ref count is 0, the object deletes itself. static PluginChannelBase* GetChannel( - const std::string& channel_name, IPC::Channel::Mode mode, + const std::string& channel_key, IPC::Channel::Mode mode, PluginChannelFactory factory, MessageLoop* ipc_message_loop, bool create_pipe_now); |