Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: content/renderer/pepper/pepper_plugin_delegate_impl.cc

Issue 10014013: Add a hang monitor for Pepper plugins (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/pepper/pepper_hung_plugin_filter.cc ('k') | ppapi/proxy/dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/renderer/pepper/pepper_plugin_delegate_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 23 matching lines...) Expand all
34 #include "content/public/common/media_stream_request.h" 34 #include "content/public/common/media_stream_request.h"
35 #include "content/public/renderer/content_renderer_client.h" 35 #include "content/public/renderer/content_renderer_client.h"
36 #include "content/renderer/gamepad_shared_memory_reader.h" 36 #include "content/renderer/gamepad_shared_memory_reader.h"
37 #include "content/renderer/media/audio_hardware.h" 37 #include "content/renderer/media/audio_hardware.h"
38 #include "content/renderer/media/media_stream_dispatcher.h" 38 #include "content/renderer/media/media_stream_dispatcher.h"
39 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" 39 #include "content/renderer/media/pepper_platform_video_decoder_impl.h"
40 #include "content/renderer/p2p/p2p_transport_impl.h" 40 #include "content/renderer/p2p/p2p_transport_impl.h"
41 #include "content/renderer/p2p/socket_dispatcher.h" 41 #include "content/renderer/p2p/socket_dispatcher.h"
42 #include "content/renderer/pepper/pepper_broker_impl.h" 42 #include "content/renderer/pepper/pepper_broker_impl.h"
43 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" 43 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h"
44 #include "content/renderer/pepper/pepper_hung_plugin_filter.h"
44 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h" 45 #include "content/renderer/pepper/pepper_platform_audio_input_impl.h"
45 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" 46 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h"
46 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h" 47 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
47 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h" 48 #include "content/renderer/pepper/pepper_platform_image_2d_impl.h"
48 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h" 49 #include "content/renderer/pepper/pepper_platform_video_capture_impl.h"
49 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h" 50 #include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
50 #include "content/renderer/render_thread_impl.h" 51 #include "content/renderer/render_thread_impl.h"
51 #include "content/renderer/render_view_impl.h" 52 #include "content/renderer/render_view_impl.h"
52 #include "content/renderer/render_widget_fullscreen_pepper.h" 53 #include "content/renderer/render_widget_fullscreen_pepper.h"
53 #include "content/renderer/renderer_clipboard_client.h" 54 #include "content/renderer/renderer_clipboard_client.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 class HostDispatcherWrapper 99 class HostDispatcherWrapper
99 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { 100 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy {
100 public: 101 public:
101 HostDispatcherWrapper() {} 102 HostDispatcherWrapper() {}
102 virtual ~HostDispatcherWrapper() {} 103 virtual ~HostDispatcherWrapper() {}
103 104
104 bool Init(base::ProcessHandle plugin_process_handle, 105 bool Init(base::ProcessHandle plugin_process_handle,
105 const IPC::ChannelHandle& channel_handle, 106 const IPC::ChannelHandle& channel_handle,
106 PP_Module pp_module, 107 PP_Module pp_module,
107 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface, 108 ppapi::proxy::Dispatcher::GetInterfaceFunc local_get_interface,
108 const ppapi::Preferences& preferences) { 109 const ppapi::Preferences& preferences,
110 PepperHungPluginFilter* filter) {
109 if (channel_handle.name.empty()) 111 if (channel_handle.name.empty())
110 return false; 112 return false;
111 113
112 #if defined(OS_POSIX) 114 #if defined(OS_POSIX)
113 DCHECK_NE(-1, channel_handle.socket.fd); 115 DCHECK_NE(-1, channel_handle.socket.fd);
114 if (channel_handle.socket.fd == -1) 116 if (channel_handle.socket.fd == -1)
115 return false; 117 return false;
116 #endif 118 #endif
117 119
118 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl); 120 dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
119 dispatcher_.reset(new ppapi::proxy::HostDispatcher( 121 dispatcher_.reset(new ppapi::proxy::HostDispatcher(
120 plugin_process_handle, pp_module, local_get_interface)); 122 plugin_process_handle, pp_module, local_get_interface, filter));
121 123
122 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), 124 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(),
123 channel_handle, 125 channel_handle,
124 true, // Client. 126 true, // Client.
125 preferences)) { 127 preferences)) {
126 dispatcher_.reset(); 128 dispatcher_.reset();
127 dispatcher_delegate_.reset(); 129 dispatcher_delegate_.reset();
128 return false; 130 return false;
129 } 131 }
130 dispatcher_->channel()->SetRestrictDispatchChannelGroup( 132 dispatcher_->channel()->SetRestrictDispatchChannelGroup(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 *pepper_plugin_was_registered = false; 229 *pepper_plugin_was_registered = false;
228 return scoped_refptr<webkit::ppapi::PluginModule>(); 230 return scoped_refptr<webkit::ppapi::PluginModule>();
229 } else if (!info->is_out_of_process) { 231 } else if (!info->is_out_of_process) {
230 // In-process plugin not preloaded, it probably couldn't be initialized. 232 // In-process plugin not preloaded, it probably couldn't be initialized.
231 return scoped_refptr<webkit::ppapi::PluginModule>(); 233 return scoped_refptr<webkit::ppapi::PluginModule>();
232 } 234 }
233 235
234 // Out of process: have the browser start the plugin process for us. 236 // Out of process: have the browser start the plugin process for us.
235 base::ProcessHandle plugin_process_handle = base::kNullProcessHandle; 237 base::ProcessHandle plugin_process_handle = base::kNullProcessHandle;
236 IPC::ChannelHandle channel_handle; 238 IPC::ChannelHandle channel_handle;
239 int plugin_child_id = 0;
237 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( 240 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin(
238 path, &plugin_process_handle, &channel_handle)); 241 path, &plugin_process_handle, &channel_handle, &plugin_child_id));
239 if (channel_handle.name.empty()) { 242 if (channel_handle.name.empty()) {
240 // Couldn't be initialized. 243 // Couldn't be initialized.
241 return scoped_refptr<webkit::ppapi::PluginModule>(); 244 return scoped_refptr<webkit::ppapi::PluginModule>();
242 } 245 }
243 246
247 scoped_refptr<PepperHungPluginFilter> hung_filter(
248 new PepperHungPluginFilter(path, render_view_->routing_id(),
249 plugin_child_id));
250
244 // Create a new HostDispatcher for the proxying, and hook it to a new 251 // Create a new HostDispatcher for the proxying, and hook it to a new
245 // PluginModule. Note that AddLiveModule must be called before any early 252 // PluginModule. Note that AddLiveModule must be called before any early
246 // returns since the module's destructor will remove itself. 253 // returns since the module's destructor will remove itself.
247 module = new webkit::ppapi::PluginModule(info->name, path, 254 module = new webkit::ppapi::PluginModule(info->name, path,
248 PepperPluginRegistry::GetInstance()); 255 PepperPluginRegistry::GetInstance());
249 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); 256 PepperPluginRegistry::GetInstance()->AddLiveModule(path, module);
250 scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper); 257 scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper);
251 if (!dispatcher->Init( 258 if (!dispatcher->Init(
252 plugin_process_handle, 259 plugin_process_handle,
253 channel_handle, 260 channel_handle,
254 module->pp_module(), 261 module->pp_module(),
255 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(), 262 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(),
256 GetPreferences())) 263 GetPreferences(),
264 hung_filter.get()))
257 return scoped_refptr<webkit::ppapi::PluginModule>(); 265 return scoped_refptr<webkit::ppapi::PluginModule>();
258 module->InitAsProxied(dispatcher.release()); 266 module->InitAsProxied(dispatcher.release());
259 return module; 267 return module;
260 } 268 }
261 269
262 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker( 270 scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker(
263 webkit::ppapi::PluginModule* plugin_module) { 271 webkit::ppapi::PluginModule* plugin_module) {
264 DCHECK(plugin_module); 272 DCHECK(plugin_module);
265 DCHECK(!plugin_module->GetBroker()); 273 DCHECK(!plugin_module->GetBroker());
266 274
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 mouse_lock_instances_.erase(it); 1622 mouse_lock_instances_.erase(it);
1615 } 1623 }
1616 } 1624 }
1617 1625
1618 webkit_glue::ClipboardClient* 1626 webkit_glue::ClipboardClient*
1619 PepperPluginDelegateImpl::CreateClipboardClient() const { 1627 PepperPluginDelegateImpl::CreateClipboardClient() const {
1620 return new RendererClipboardClient; 1628 return new RendererClipboardClient;
1621 } 1629 }
1622 1630
1623 } // namespace content 1631 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_hung_plugin_filter.cc ('k') | ppapi/proxy/dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698