| Index: webkit/glue/plugins/pepper_plugin_module.cc
|
| ===================================================================
|
| --- webkit/glue/plugins/pepper_plugin_module.cc (revision 65099)
|
| +++ webkit/glue/plugins/pepper_plugin_module.cc (working copy)
|
| @@ -47,6 +47,8 @@
|
| #include "ppapi/c/ppb_var.h"
|
| #include "ppapi/c/ppp.h"
|
| #include "ppapi/c/ppp_instance.h"
|
| +#include "ppapi/proxy/host_dispatcher.h"
|
| +#include "ppapi/proxy/ppapi_messages.h"
|
| #include "webkit/glue/plugins/pepper_audio.h"
|
| #include "webkit/glue/plugins/pepper_buffer.h"
|
| #include "webkit/glue/plugins/pepper_char_set.h"
|
| @@ -80,6 +82,10 @@
|
| #include "webkit/glue/plugins/pepper_graphics_3d.h"
|
| #endif // ENABLE_GPU
|
|
|
| +#if defined(OS_POSIX)
|
| +#include "ipc/ipc_channel_posix.h"
|
| +#endif
|
| +
|
| namespace pepper {
|
|
|
| namespace {
|
| @@ -330,6 +336,7 @@
|
| return lib;
|
| }
|
|
|
| +// static
|
| scoped_refptr<PluginModule> PluginModule::CreateInternalModule(
|
| EntryPoints entry_points) {
|
| scoped_refptr<PluginModule> lib(new PluginModule());
|
| @@ -340,6 +347,17 @@
|
| }
|
|
|
| // static
|
| +scoped_refptr<PluginModule> PluginModule::CreateOutOfProcessModule(
|
| + MessageLoop* ipc_message_loop,
|
| + const IPC::ChannelHandle& handle,
|
| + base::WaitableEvent* shutdown_event) {
|
| + scoped_refptr<PluginModule> lib(new PluginModule);
|
| + if (!lib->InitForOutOfProcess(ipc_message_loop, handle, shutdown_event))
|
| + return NULL;
|
| + return lib;
|
| +}
|
| +
|
| +// static
|
| const PPB_Core* PluginModule::GetCore() {
|
| return &core_interface;
|
| }
|
| @@ -381,10 +399,41 @@
|
| return true;
|
| }
|
|
|
| +bool PluginModule::InitForOutOfProcess(MessageLoop* ipc_message_loop,
|
| + const IPC::ChannelHandle& handle,
|
| + base::WaitableEvent* shutdown_event) {
|
| + const PPB_Var_Deprecated* var_interface =
|
| + reinterpret_cast<const PPB_Var_Deprecated*>(
|
| + GetInterface(PPB_VAR_DEPRECATED_INTERFACE));
|
| + dispatcher_.reset(new pp::proxy::HostDispatcher(var_interface,
|
| + pp_module(), &GetInterface));
|
| +
|
| +#if defined(OS_POSIX)
|
| + // If we received a ChannelHandle, register it now.
|
| + if (handle.socket.fd >= 0)
|
| + IPC::AddChannelSocket(handle.name, handle.socket.fd);
|
| +#endif
|
| +
|
| + if (!dispatcher_->InitWithChannel(ipc_message_loop, handle.name, true,
|
| + shutdown_event)) {
|
| + dispatcher_.reset();
|
| + return false;
|
| + }
|
| +
|
| + bool init_result = false;
|
| + dispatcher_->Send(new PpapiMsg_InitializeModule(pp_module(), &init_result));
|
| +
|
| + if (!init_result) {
|
| + // TODO(brettw) does the module get unloaded in this case?
|
| + dispatcher_.reset();
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| // static
|
| bool PluginModule::LoadEntryPoints(const base::NativeLibrary& library,
|
| EntryPoints* entry_points) {
|
| -
|
| entry_points->get_interface =
|
| reinterpret_cast<PPP_GetInterfaceFunc>(
|
| base::GetFunctionPointerFromNativeLibrary(library,
|
| @@ -421,7 +470,13 @@
|
| LOG(WARNING) << "Plugin doesn't support instance interface, failing.";
|
| return NULL;
|
| }
|
| - return new PluginInstance(delegate, this, plugin_instance_interface);
|
| + PluginInstance* instance = new PluginInstance(delegate, this,
|
| + plugin_instance_interface);
|
| + if (dispatcher_.get()) {
|
| + pp::proxy::HostDispatcher::SetForInstance(instance->pp_instance(),
|
| + dispatcher_.get());
|
| + }
|
| + return instance;
|
| }
|
|
|
| PluginInstance* PluginModule::GetSomeInstance() const {
|
| @@ -432,6 +487,10 @@
|
| }
|
|
|
| const void* PluginModule::GetPluginInterface(const char* name) const {
|
| + if (dispatcher_.get())
|
| + return dispatcher_->GetProxiedInterface(name);
|
| +
|
| + // In-process plugins.
|
| if (!entry_points_.get_interface)
|
| return NULL;
|
| return entry_points_.get_interface(name);
|
| @@ -442,6 +501,7 @@
|
| }
|
|
|
| void PluginModule::InstanceDeleted(PluginInstance* instance) {
|
| + pp::proxy::HostDispatcher::RemoveForInstance(instance->pp_instance());
|
| instances_.erase(instance);
|
| }
|
|
|
|
|