1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_PEPPER_HOST_DISPATCHER_WRAPPER_H_
6 #define CONTENT_RENDERER_PEPPER_HOST_DISPATCHER_WRAPPER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/process/process_handle.h"
10 #include "content/renderer/pepper/pepper_hung_plugin_filter.h"
11 #include "ppapi/c/pp_instance.h"
12 #include "ppapi/c/ppp.h"
13 #include "ppapi/proxy/host_dispatcher.h"
14 #include "ppapi/shared_impl/ppapi_permissions.h"
21 class PepperHungPluginFilter
;
24 // This class wraps a dispatcher and has the same lifetime. A dispatcher has
25 // the same lifetime as a plugin module, which is longer than any particular
26 // RenderView or plugin instance.
27 class HostDispatcherWrapper
{
29 HostDispatcherWrapper(PluginModule
* module
,
30 base::ProcessId peer_pid
,
32 const ppapi::PpapiPermissions
& perms
,
34 virtual ~HostDispatcherWrapper();
36 bool Init(const IPC::ChannelHandle
& channel_handle
,
37 PP_GetInterface_Func local_get_interface
,
38 const ppapi::Preferences
& preferences
,
39 scoped_refptr
<PepperHungPluginFilter
> filter
);
41 // Implements GetInterface for the proxied plugin.
42 const void* GetProxiedInterface(const char* name
);
44 // Notification to the out-of-process layer that the given plugin instance
45 // has been created. This will happen before the normal PPB_Instance method
46 // calls so the out-of-process code can set up the tracking information for
48 void AddInstance(PP_Instance instance
);
50 // Like AddInstance but removes the given instance. This is called after
51 // regular instance shutdown so the out-of-process code can clean up its
52 // tracking information.
53 void RemoveInstance(PP_Instance instance
);
55 base::ProcessId
peer_pid() { return peer_pid_
; }
56 int plugin_child_id() { return plugin_child_id_
; }
57 ppapi::proxy::HostDispatcher
* dispatcher() { return dispatcher_
.get(); }
60 PluginModule
* module_
;
62 base::ProcessId peer_pid_
;
64 // ID that the browser process uses to idetify the child process for the
65 // plugin. This isn't directly useful from our process (the renderer) except
66 // in messages to the browser to disambiguate plugins.
69 ppapi::PpapiPermissions permissions_
;
72 scoped_ptr
<ppapi::proxy::HostDispatcher
> dispatcher_
;
73 scoped_ptr
<ppapi::proxy::ProxyChannel::Delegate
> dispatcher_delegate_
;
74 // We hold the hung_plugin_filter_ to guarantee it outlives |dispatcher_|,
75 // since it is an observer of |dispatcher_| for sync calls.
76 scoped_refptr
<PepperHungPluginFilter
> hung_plugin_filter_
;
79 } // namespace content
81 #endif // CONTENT_RENDERER_PEPPER_HOST_DISPATCHER_WRAPPER_H_