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/process/process_handle.h"
9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/c/ppp.h"
11 #include "ppapi/proxy/host_dispatcher.h"
12 #include "ppapi/shared_impl/ppapi_permissions.h"
19 class PepperHungPluginFilter
;
22 // This class wraps a dispatcher and has the same lifetime. A dispatcher has
23 // the same lifetime as a plugin module, which is longer than any particular
24 // RenderView or plugin instance.
25 class HostDispatcherWrapper
{
27 HostDispatcherWrapper(PluginModule
* module
,
28 base::ProcessId peer_pid
,
30 const ppapi::PpapiPermissions
& perms
,
32 virtual ~HostDispatcherWrapper();
34 bool Init(const IPC::ChannelHandle
& channel_handle
,
35 PP_GetInterface_Func local_get_interface
,
36 const ppapi::Preferences
& preferences
,
37 PepperHungPluginFilter
* filter
);
39 // Implements GetInterface for the proxied plugin.
40 const void* GetProxiedInterface(const char* name
);
42 // Notification to the out-of-process layer that the given plugin instance
43 // has been created. This will happen before the normal PPB_Instance method
44 // calls so the out-of-process code can set up the tracking information for
46 void AddInstance(PP_Instance instance
);
48 // Like AddInstance but removes the given instance. This is called after
49 // regular instance shutdown so the out-of-process code can clean up its
50 // tracking information.
51 void RemoveInstance(PP_Instance instance
);
53 base::ProcessId
peer_pid() { return peer_pid_
; }
54 int plugin_child_id() { return plugin_child_id_
; }
55 ppapi::proxy::HostDispatcher
* dispatcher() { return dispatcher_
.get(); }
58 PluginModule
* module_
;
60 base::ProcessId peer_pid_
;
62 // ID that the browser process uses to idetify the child process for the
63 // plugin. This isn't directly useful from our process (the renderer) except
64 // in messages to the browser to disambiguate plugins.
67 ppapi::PpapiPermissions permissions_
;
70 scoped_ptr
<ppapi::proxy::HostDispatcher
> dispatcher_
;
71 scoped_ptr
<ppapi::proxy::ProxyChannel::Delegate
> dispatcher_delegate_
;
74 } // namespace content
76 #endif // CONTENT_RENDERER_PEPPER_HOST_DISPATCHER_WRAPPER_H_