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. 4 5 #ifndef CONTENT_RENDERER_PEPPER_HOST_DISPATCHER_WRAPPER_H_ 6 #define CONTENT_RENDERER_PEPPER_HOST_DISPATCHER_WRAPPER_H_ 7 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" 13 14 namespace IPC { 15 struct ChannelHandle; 16 } 17 18 namespace content { 19 class PepperHungPluginFilter; 20 class PluginModule; 21 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(); 33 34 bool Init(const IPC::ChannelHandle& channel_handle, 35 PP_GetInterface_Func local_get_interface, 36 const ppapi::Preferences& preferences, 37 PepperHungPluginFilter* filter); 38 39 // Implements GetInterface for the proxied plugin. 40 const void* GetProxiedInterface(const char* name); 41 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); 47 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); 52 peer_pid()53 base::ProcessId peer_pid() { return peer_pid_; } plugin_child_id()54 int plugin_child_id() { return plugin_child_id_; } dispatcher()55 ppapi::proxy::HostDispatcher* dispatcher() { return dispatcher_.get(); } 56 57 private: 58 PluginModule* module_; 59 60 base::ProcessId peer_pid_; 61 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_; 66 67 ppapi::PpapiPermissions permissions_; 68 bool is_external_; 69 70 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; 71 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; 72 }; 73 74 } // namespace content 75 76 #endif // CONTENT_RENDERER_PEPPER_HOST_DISPATCHER_WRAPPER_H_ 77