summaryrefslogtreecommitdiffstats
path: root/content/plugin/plugin_channel.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 23:12:32 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 23:12:32 +0000
commit30fc7a827148fe22782fc8202e9c8602d1448a01 (patch)
tree73d326e932f85ba24ffe8322cde34b94c4525c10 /content/plugin/plugin_channel.cc
parent9c8a1980f7b81a78100034852c59777c2cc4d83d (diff)
downloadchromium_src-30fc7a827148fe22782fc8202e9c8602d1448a01.zip
chromium_src-30fc7a827148fe22782fc8202e9c8602d1448a01.tar.gz
chromium_src-30fc7a827148fe22782fc8202e9c8602d1448a01.tar.bz2
Don't terminate plugin processes from the browser during browser shutdown. This is to allow the plugins to
shutdown gracefully, i.e. NP_Shutdown gets called. To ensure that we handle the case of a hung plugin, we handle the OnChannelError notification in the IPC message filter implementation in the plugin process and post a delayed task to kill the process. Fixes bug http://code.google.com/p/chromium/issues/detail?id=48178 BUG=48178 Review URL: http://codereview.chromium.org/6992006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/plugin/plugin_channel.cc')
-rw-r--r--content/plugin/plugin_channel.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/content/plugin/plugin_channel.cc b/content/plugin/plugin_channel.cc
index cd2e99f..dd00a75 100644
--- a/content/plugin/plugin_channel.cc
+++ b/content/plugin/plugin_channel.cc
@@ -32,9 +32,19 @@ 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
@@ -88,6 +98,15 @@ 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)