diff options
Diffstat (limited to 'content/plugin')
-rw-r--r-- | content/plugin/plugin_channel.cc | 19 | ||||
-rw-r--r-- | content/plugin/plugin_thread.cc | 28 |
2 files changed, 28 insertions, 19 deletions
diff --git a/content/plugin/plugin_channel.cc b/content/plugin/plugin_channel.cc index dd00a75..cd2e99f 100644 --- a/content/plugin/plugin_channel.cc +++ b/content/plugin/plugin_channel.cc @@ -32,19 +32,9 @@ class PluginReleaseTask : public Task { } }; -class PluginProcessExitTask : public Task { - public: - void Run() { - base::KillProcess(base::GetCurrentProcessHandle(), 0, false); - } -}; - // How long we wait before releasing the plugin process. const int kPluginReleaseTimeMs = 5 * 60 * 1000; // 5 minutes -// How long we wait before forcibly shutting down the process. -const int kPluginProcessTerminateTimeoutMs = 3000; - } // namespace // If a sync call to the renderer results in a modal dialog, we need to have a @@ -98,15 +88,6 @@ class PluginChannel::MessageFilter : public IPC::ChannelProxy::MessageFilter { private: void OnFilterAdded(IPC::Channel* channel) { channel_ = channel; } - virtual void OnChannelError() { - // Ensure that we don't wait indefinitely for the plugin to shutdown. - // as the browser does not terminate plugin processes on shutdown. - // We achieve this by posting an exit process task on the IO thread. - MessageLoop::current()->PostDelayedTask(FROM_HERE, - new PluginProcessExitTask(), - kPluginProcessTerminateTimeoutMs); - } - bool OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(PluginChannel::MessageFilter, message) IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_Init, OnInit) diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc index 18455d2..c5d2953 100644 --- a/content/plugin/plugin_thread.cc +++ b/content/plugin/plugin_thread.cc @@ -39,6 +39,33 @@ #include "ui/base/x/x11_util.h" #endif +namespace { + +class EnsureTerminateMessageFilter : public IPC::ChannelProxy::MessageFilter { + public: + EnsureTerminateMessageFilter() {} + ~EnsureTerminateMessageFilter() {} + + private: + virtual void OnChannelError() { + // How long we wait before forcibly shutting down the process. + const int kPluginProcessTerminateTimeoutMs = 3000; + // Ensure that we don't wait indefinitely for the plugin to shutdown. + // as the browser does not terminate plugin processes on shutdown. + // We achieve this by posting an exit process task on the IO thread. + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + NewRunnableMethod(this, &EnsureTerminateMessageFilter::Terminate), + kPluginProcessTerminateTimeoutMs); + } + + void Terminate() { + base::KillProcess(base::GetCurrentProcessHandle(), 0, false); + } +}; + +} // namespace + static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( base::LINKER_INITIALIZED); @@ -91,6 +118,7 @@ PluginThread::PluginThread() // Certain plugins, such as flash, steal the unhandled exception filter // thus we never get crash reports when they fault. This call fixes it. message_loop()->set_exception_restoration(true); + channel()->AddFilter(new EnsureTerminateMessageFilter()); } PluginThread::~PluginThread() { |