diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 19:49:29 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 19:49:29 +0000 |
commit | 8be45847f76ec798c1241ed7e98cfb19f68b7e96 (patch) | |
tree | 7198fc01d68a1a5f4110c3167635f2000444054c /content/browser | |
parent | 43095f23d76d2ae3d50e1e8bb55c71152025d76c (diff) | |
download | chromium_src-8be45847f76ec798c1241ed7e98cfb19f68b7e96.zip chromium_src-8be45847f76ec798c1241ed7e98cfb19f68b7e96.tar.gz chromium_src-8be45847f76ec798c1241ed7e98cfb19f68b7e96.tar.bz2 |
This adds a hang monitor for Pepper plugins. It monitors sync messages on the I/O thread of the renderer and sends a message to the browser if it's blocked for too long.
The browser will show an infobar allowing you to terminate the plugin.
BUG=122795
Review URL: https://chromiumcodereview.appspot.com/10014013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r-- | content/browser/plugin_data_remover_impl.cc | 3 | ||||
-rw-r--r-- | content/browser/plugin_service_impl.cc | 21 | ||||
-rw-r--r-- | content/browser/plugin_service_impl.h | 1 | ||||
-rw-r--r-- | content/browser/ppapi_plugin_process_host.cc | 15 | ||||
-rw-r--r-- | content/browser/ppapi_plugin_process_host.h | 9 | ||||
-rw-r--r-- | content/browser/renderer_host/render_message_filter.cc | 8 | ||||
-rw-r--r-- | content/browser/web_contents/web_contents_impl.cc | 8 | ||||
-rw-r--r-- | content/browser/web_contents/web_contents_impl.h | 3 |
8 files changed, 49 insertions, 19 deletions
diff --git a/content/browser/plugin_data_remover_impl.cc b/content/browser/plugin_data_remover_impl.cc index 0d83135..fd62447 100644 --- a/content/browser/plugin_data_remover_impl.cc +++ b/content/browser/plugin_data_remover_impl.cc @@ -168,7 +168,8 @@ class PluginDataRemoverImpl::Context virtual void OnPpapiChannelOpened( base::ProcessHandle plugin_process_handle, - const IPC::ChannelHandle& channel_handle) OVERRIDE { + const IPC::ChannelHandle& channel_handle, + int /* child_id */) OVERRIDE { if (plugin_process_handle != base::kNullProcessHandle) ConnectToChannel(channel_handle, true); diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index 99924b1..29909c2 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -342,7 +342,7 @@ void PluginServiceImpl::OpenChannelToPpapiPlugin( } else { // Send error. client->OnPpapiChannelOpened(base::kNullProcessHandle, - IPC::ChannelHandle()); + IPC::ChannelHandle(), 0); } } @@ -355,7 +355,7 @@ void PluginServiceImpl::OpenChannelToPpapiBroker( } else { // Send error. client->OnPpapiChannelOpened(base::kNullProcessHandle, - IPC::ChannelHandle()); + IPC::ChannelHandle(), 0); } } @@ -483,6 +483,23 @@ bool PluginServiceImpl::GetPluginInfoByPath(const FilePath& plugin_path, return false; } +string16 PluginServiceImpl::GetPluginDisplayNameByPath(const FilePath& path) { + string16 plugin_name = path.LossyDisplayName(); + webkit::WebPluginInfo info; + if (PluginService::GetInstance()->GetPluginInfoByPath(path, &info) && + !info.name.empty()) { + plugin_name = info.name; +#if defined(OS_MACOSX) + // Many plugins on the Mac have .plugin in the actual name, which looks + // terrible, so look for that and strip it off if present. + const std::string kPluginExtension = ".plugin"; + if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) + plugin_name.erase(plugin_name.length() - kPluginExtension.length()); +#endif // OS_MACOSX + } + return plugin_name; +} + void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) { scoped_refptr<base::MessageLoopProxy> target_loop( MessageLoop::current()->message_loop_proxy()); diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index be36075..bc8f112 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h @@ -97,6 +97,7 @@ class CONTENT_EXPORT PluginServiceImpl std::string* actual_mime_type) OVERRIDE; virtual bool GetPluginInfoByPath(const FilePath& plugin_path, webkit::WebPluginInfo* info) OVERRIDE; + virtual string16 GetPluginDisplayNameByPath(const FilePath& path) OVERRIDE; virtual void GetPlugins(const GetPluginsCallback& callback) OVERRIDE; virtual void GetPluginGroups( const GetPluginGroupsCallback& callback) OVERRIDE; diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc index ceee322..98218ad 100644 --- a/content/browser/ppapi_plugin_process_host.cc +++ b/content/browser/ppapi_plugin_process_host.cc @@ -111,16 +111,14 @@ PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver) : filter_(new PepperMessageFilter(PepperMessageFilter::PLUGIN, host_resolver)), network_observer_(new PluginNetworkObserver(this)), - is_broker_(false), - process_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()) { + is_broker_(false) { process_.reset(new BrowserChildProcessHostImpl( content::PROCESS_TYPE_PPAPI_PLUGIN, this)); process_->GetHost()->AddFilter(filter_.get()); } PpapiPluginProcessHost::PpapiPluginProcessHost() - : is_broker_(true), - process_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()) { + : is_broker_(true) { process_.reset(new BrowserChildProcessHostImpl( content::PROCESS_TYPE_PPAPI_BROKER, this)); } @@ -211,7 +209,7 @@ void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { sent_requests_.push(client); } else { client->OnPpapiChannelOpened(base::kNullProcessHandle, - IPC::ChannelHandle()); + IPC::ChannelHandle(), 0); } } @@ -259,13 +257,13 @@ void PpapiPluginProcessHost::CancelRequests() { << "CancelRequests()"; for (size_t i = 0; i < pending_requests_.size(); i++) { pending_requests_[i]->OnPpapiChannelOpened(base::kNullProcessHandle, - IPC::ChannelHandle()); + IPC::ChannelHandle(), 0); } pending_requests_.clear(); while (!sent_requests_.empty()) { sent_requests_.front()->OnPpapiChannelOpened(base::kNullProcessHandle, - IPC::ChannelHandle()); + IPC::ChannelHandle(), 0); sent_requests_.pop(); } } @@ -297,5 +295,6 @@ void PpapiPluginProcessHost::OnRendererPluginChannelCreated( base::ProcessHandle renderers_plugin_handle = plugin_process; #endif - client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle); + client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle, + process_->GetData().id); } diff --git a/content/browser/ppapi_plugin_process_host.h b/content/browser/ppapi_plugin_process_host.h index 02e1f83..3d7436e 100644 --- a/content/browser/ppapi_plugin_process_host.h +++ b/content/browser/ppapi_plugin_process_host.h @@ -42,10 +42,12 @@ class PpapiPluginProcessHost : public content::BrowserChildProcessHostDelegate, // Called when the channel is asynchronously opened to the plugin or on // error. On error, the parameters should be: // base::kNullProcessHandle - // IPC::ChannelHandle() + // IPC::ChannelHandle(), + // 0 virtual void OnPpapiChannelOpened( base::ProcessHandle plugin_process_handle, - const IPC::ChannelHandle& channel_handle) = 0; + const IPC::ChannelHandle& channel_handle, + int plugin_child_id) = 0; }; class PluginClient : public Client { @@ -120,9 +122,6 @@ class PpapiPluginProcessHost : public content::BrowserChildProcessHostDelegate, const bool is_broker_; - // The unique id created for the process. - int process_id_; - scoped_ptr<BrowserChildProcessHostImpl> process_; DISALLOW_COPY_AND_ASSIGN(PpapiPluginProcessHost); diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 98904ba..8d0eb4b 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -131,9 +131,10 @@ class OpenChannelToPpapiPluginCallback } virtual void OnPpapiChannelOpened(base::ProcessHandle plugin_process_handle, - const IPC::ChannelHandle& channel_handle) { + const IPC::ChannelHandle& channel_handle, + int plugin_child_id) { ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams( - reply_msg(), plugin_process_handle, channel_handle); + reply_msg(), plugin_process_handle, channel_handle, plugin_child_id); SendReplyAndDeleteThis(); } @@ -165,7 +166,8 @@ class OpenChannelToPpapiBrokerCallback } virtual void OnPpapiChannelOpened(base::ProcessHandle broker_process_handle, - const IPC::ChannelHandle& channel_handle) { + const IPC::ChannelHandle& channel_handle, + int /* plugin_child_id */) { filter_->Send(new ViewMsg_PpapiBrokerChannelCreated(routing_id_, request_id_, broker_process_handle, diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 48ffa6c..fa1907c 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -574,6 +574,7 @@ bool WebContentsImpl::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewHostMsg_EndColorChooser, OnEndColorChooser) IPC_MESSAGE_HANDLER(ViewHostMsg_SetSelectedColorInColorChooser, OnSetSelectedColorInColorChooser) + IPC_MESSAGE_HANDLER(ViewHostMsg_PepperPluginHung, OnPepperPluginHung) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -1769,6 +1770,13 @@ void WebContentsImpl::OnSetSelectedColorInColorChooser(int color_chooser_id, color_chooser_->SetSelectedColor(color); } +void TabContents::OnPepperPluginHung(int plugin_child_id, + const FilePath& path, + bool is_hung) { + if (delegate_) + delegate_->PluginHungStatusChanged(this, plugin_child_id, path, is_hung); +} + // Notifies the RenderWidgetHost instance about the fact that the page is // loading, or done loading and calls the base implementation. void WebContentsImpl::SetIsLoading(bool is_loading, diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 1c0287b..d37dc44 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -461,6 +461,9 @@ class CONTENT_EXPORT WebContentsImpl void OnEndColorChooser(int color_chooser_id); void OnSetSelectedColorInColorChooser(int color_chooser_id, const SkColor& color); + void OnPepperPluginHung(int plugin_child_id, + const FilePath& path, + bool is_hung); // Changes the IsLoading state and notifies delegate as needed // |details| is used to provide details on the load that just finished |