| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/plugin/plugin_thread.h" | 5 #include "content/plugin/plugin_thread.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(TOOLKIT_GTK) | 9 #if defined(TOOLKIT_GTK) |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 #if defined(USE_X11) | 38 #if defined(USE_X11) |
| 39 #include "ui/base/x/x11_util.h" | 39 #include "ui/base/x/x11_util.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 class EnsureTerminateMessageFilter : public IPC::ChannelProxy::MessageFilter { | 44 class EnsureTerminateMessageFilter : public IPC::ChannelProxy::MessageFilter { |
| 45 public: | 45 public: |
| 46 EnsureTerminateMessageFilter() {} | 46 EnsureTerminateMessageFilter() {} |
| 47 ~EnsureTerminateMessageFilter() {} | |
| 48 | 47 |
| 49 private: | 48 protected: |
| 49 virtual ~EnsureTerminateMessageFilter() {} |
| 50 |
| 51 // IPC::ChannelProxy::MessageFilter: |
| 50 virtual void OnChannelError() { | 52 virtual void OnChannelError() { |
| 51 // How long we wait before forcibly shutting down the process. | 53 // How long we wait before forcibly shutting down the process. |
| 52 const base::TimeDelta kPluginProcessTerminateTimeout = | 54 const base::TimeDelta kPluginProcessTerminateTimeout = |
| 53 base::TimeDelta::FromSeconds(3); | 55 base::TimeDelta::FromSeconds(3); |
| 54 // Ensure that we don't wait indefinitely for the plugin to shutdown. | 56 // Ensure that we don't wait indefinitely for the plugin to shutdown. |
| 55 // as the browser does not terminate plugin processes on shutdown. | 57 // as the browser does not terminate plugin processes on shutdown. |
| 56 // We achieve this by posting an exit process task on the IO thread. | 58 // We achieve this by posting an exit process task on the IO thread. |
| 57 MessageLoop::current()->PostDelayedTask( | 59 MessageLoop::current()->PostDelayedTask( |
| 58 FROM_HERE, | 60 FROM_HERE, |
| 59 base::Bind(&EnsureTerminateMessageFilter::Terminate, this), | 61 base::Bind(&EnsureTerminateMessageFilter::Terminate, this), |
| 60 kPluginProcessTerminateTimeout); | 62 kPluginProcessTerminateTimeout); |
| 61 } | 63 } |
| 62 | 64 |
| 65 private: |
| 63 void Terminate() { | 66 void Terminate() { |
| 64 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 67 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
| 65 } | 68 } |
| 66 }; | 69 }; |
| 67 | 70 |
| 68 } // namespace | 71 } // namespace |
| 69 | 72 |
| 70 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls = | 73 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls = |
| 71 LAZY_INSTANCE_INITIALIZER; | 74 LAZY_INSTANCE_INITIALIZER; |
| 72 | 75 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 #endif | 176 #endif |
| 174 channel->set_incognito(incognito); | 177 channel->set_incognito(incognito); |
| 175 } | 178 } |
| 176 | 179 |
| 177 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); | 180 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); |
| 178 } | 181 } |
| 179 | 182 |
| 180 void PluginThread::OnNotifyRenderersOfPendingShutdown() { | 183 void PluginThread::OnNotifyRenderersOfPendingShutdown() { |
| 181 PluginChannel::NotifyRenderersOfPendingShutdown(); | 184 PluginChannel::NotifyRenderersOfPendingShutdown(); |
| 182 } | 185 } |
| OLD | NEW |