PPAPI: Never re-enter JavaScript for PostMessage.
[chromium-blink-merge.git] / content / renderer / pepper / host_dispatcher_wrapper.h
blobc3b58fb87de679d758974d8539c03950d7e217f7
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"
14 namespace IPC {
15 struct ChannelHandle;
18 namespace content {
19 class PepperHungPluginFilter;
20 class PluginModule;
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 {
26 public:
27 HostDispatcherWrapper(PluginModule* module,
28 base::ProcessId peer_pid,
29 int plugin_child_id,
30 const ppapi::PpapiPermissions& perms,
31 bool is_external);
32 virtual ~HostDispatcherWrapper();
34 bool Init(const IPC::ChannelHandle& channel_handle,
35 PP_GetInterface_Func local_get_interface,
36 const ppapi::Preferences& preferences,
37 scoped_refptr<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
45 // the new instance.
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(); }
57 private:
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.
65 int plugin_child_id_;
67 ppapi::PpapiPermissions permissions_;
68 bool is_external_;
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_